Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / components / favicon / core / favicon_driver.h
blob59fc333def57a0af7356046c3c122f40286916bf
1 // Copyright 2014 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 COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_
6 #define COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_
8 #include "base/macros.h"
9 #include "base/strings/string16.h"
11 class GURL;
13 namespace gfx {
14 class Image;
17 namespace favicon {
19 // Interface that allows Favicon core code to interact with its driver (i.e.,
20 // obtain information from it and give information to it). A concrete
21 // implementation must be provided by the driver.
22 class FaviconDriver {
23 public:
24 // Starts the download for the given favicon. When finished, the driver
25 // will call OnDidDownloadFavicon() with the results.
26 // Returns the unique id of the download request. The id will be passed
27 // in OnDidDownloadFavicon().
28 // Bitmaps with pixel sizes larger than |max_bitmap_size| are filtered out
29 // from the bitmap results. If there are no bitmap results <=
30 // |max_bitmap_size|, the smallest bitmap is resized to |max_bitmap_size| and
31 // is the only result. A |max_bitmap_size| of 0 means unlimited.
32 virtual int StartDownload(const GURL& url, int max_bitmap_size) = 0;
34 // Returns whether the user is operating in an off-the-record context.
35 virtual bool IsOffTheRecord() = 0;
37 // Returns whether |url| is bookmarked.
38 virtual bool IsBookmarked(const GURL& url) = 0;
40 // Returns the URL of the current page, if any. Returns an invalid URL
41 // otherwise.
42 virtual GURL GetActiveURL() = 0;
44 // Returns the title of the current page. Requires GetActiveURL() to be valid.
45 virtual base::string16 GetActiveTitle() = 0;
47 // Returns whether the page's favicon is valid (returns false if the default
48 // favicon is being used). Requires GetActiveURL() to be valid.
49 virtual bool GetActiveFaviconValidity() = 0;
51 // Sets whether the page's favicon is valid (if false, the default favicon is
52 // being used).
53 virtual void SetActiveFaviconValidity(bool valid) = 0;
55 // Returns the URL of the current page's favicon. Requires GetActiveURL() to
56 // be valid.
57 virtual GURL GetActiveFaviconURL() = 0;
59 // Sets the URL of the favicon's bitmap.
60 virtual void SetActiveFaviconURL(const GURL& url) = 0;
62 // Returns the bitmap of the current page's favicon. Requires GetActiveURL()
63 // to be valid.
64 virtual gfx::Image GetActiveFaviconImage() = 0;
66 // Sets the bitmap of the current page's favicon.
67 virtual void SetActiveFaviconImage(const gfx::Image& image) = 0;
69 // Notifies the driver a favicon image is available. |image| is not
70 // necessarily 16x16. |icon_url| is the url the image is from. If
71 // |is_active_favicon| is true the image corresponds to the favicon
72 // (possibly empty) of the page.
73 virtual void OnFaviconAvailable(const gfx::Image& image,
74 const GURL& icon_url,
75 bool is_active_favicon) = 0;
77 protected:
78 FaviconDriver() {}
79 virtual ~FaviconDriver() {}
81 private:
82 DISALLOW_COPY_AND_ASSIGN(FaviconDriver);
85 } // namespace favicon
87 #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_