15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_THUMBNAILS_THUMBNAIL_SERVICE_IMPL_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_THUMBNAILS_THUMBNAIL_SERVICE_IMPL_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/ref_counted.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/history/top_sites.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/profiles/profile.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/thumbnails/thumbnail_service.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace base {
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class RefCountedMemory;
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace thumbnails {
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// An implementation of ThumbnailService which delegates storage and most of
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// logic to an underlying TopSites instances.
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ThumbnailServiceImpl : public ThumbnailService {
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  explicit ThumbnailServiceImpl(Profile* profile);
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Implementation of ThumbnailService.
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool SetPageThumbnail(const ThumbnailingContext& context,
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                const gfx::Image& thumbnail) OVERRIDE;
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ThumbnailingAlgorithm* GetThumbnailingAlgorithm() const OVERRIDE;
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool GetPageThumbnail(
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const GURL& url,
31d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)      bool prefix_match,
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      scoped_refptr<base::RefCountedMemory>* bytes) OVERRIDE;
33f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void AddForcedURL(const GURL& url) OVERRIDE;
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool ShouldAcquirePageThumbnail(const GURL& url) OVERRIDE;
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // Implementation of RefcountedBrowserContextKeyedService.
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ShutdownOnUIThread() OVERRIDE;
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~ThumbnailServiceImpl();
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_refptr<history::TopSites> top_sites_;
43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  bool use_thumbnail_retargeting_;
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(ThumbnailServiceImpl);
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
48d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)}  // namespace thumbnails
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_THUMBNAILS_THUMBNAIL_SERVICE_IMPL_H_
51