Disabling NativeViewAcccessibilityWinTest.RetrieveAllAlerts.
[chromium-blink-merge.git] / chrome / browser / thumbnails / thumbnail_service.h
blob97000d2e07ed8668b18931b53a6674f07b4c73a3
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_THUMBNAILS_THUMBNAIL_SERVICE_H_
6 #define CHROME_BROWSER_THUMBNAILS_THUMBNAIL_SERVICE_H_
8 #include "components/history/core/common/thumbnail_score.h"
9 #include "components/keyed_service/core/refcounted_keyed_service.h"
10 #include "ui/gfx/image/image.h"
12 class GURL;
14 namespace base {
15 class RefCountedMemory;
18 namespace thumbnails {
20 class ThumbnailingAlgorithm;
21 struct ThumbnailingContext;
23 // An interface abstracting access to thumbnails. Intended as a temporary
24 // bridge facilitating switch from TopSites as the thumbnail source to a more
25 // robust way of handling these artefacts.
26 class ThumbnailService : public RefcountedKeyedService {
27 public:
28 // Sets the given thumbnail for the given URL. Returns true if the thumbnail
29 // was updated. False means either the URL wasn't known to us, or we felt
30 // that our current thumbnail was superior to the given one.
31 virtual bool SetPageThumbnail(const ThumbnailingContext& context,
32 const gfx::Image& thumbnail) = 0;
34 // Returns the ThumbnailingAlgorithm used for processing thumbnails.
35 // It is always a new instance, the caller owns it. It will encapsulate the
36 // process of creating a thumbnail from tab contents. The lifetime of these
37 // instances is limited to the act of processing a single tab image. They
38 // are permitted to hold the state of such process.
39 virtual ThumbnailingAlgorithm* GetThumbnailingAlgorithm() const = 0;
41 // Gets a thumbnail for a given page. Returns true iff we have the thumbnail.
42 // This may be invoked on any thread.
43 // If an exact thumbnail URL match fails, |prefix_match| specifies whether or
44 // not to try harder by matching the query thumbnail URL as URL prefix (as
45 // defined by UrlIsPrefix()).
46 // As this method may be invoked on any thread the ref count needs to be
47 // incremented before this method returns, so this takes a scoped_refptr*.
48 virtual bool GetPageThumbnail(
49 const GURL& url,
50 bool prefix_match,
51 scoped_refptr<base::RefCountedMemory>* bytes) = 0;
53 // Add or updates a |url| for which we should force the capture of a thumbnail
54 // next time it's visited.
55 virtual void AddForcedURL(const GURL& url) = 0;
57 // Returns true if the page thumbnail should be updated.
58 virtual bool ShouldAcquirePageThumbnail(const GURL& url) = 0;
60 protected:
61 ~ThumbnailService() override {}
64 } // namespace thumbnails
66 #endif // CHROME_BROWSER_THUMBNAILS_THUMBNAIL_SERVICE_H_