Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: components/favicon/core/favicon_driver.h

Issue 1064823002: Componentize FaviconTabHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@favicon-notification
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_ 5 #ifndef COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_
6 #define COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_ 6 #define COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/observer_list.h"
9 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
10 11
11 class GURL; 12 class GURL;
12 13
13 namespace gfx { 14 namespace gfx {
14 class Image; 15 class Image;
15 } 16 }
16 17
17 namespace favicon { 18 namespace favicon {
18 19
20 class FaviconDriverObserver;
21
19 // Interface that allows Favicon core code to interact with its driver (i.e., 22 // 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 23 // obtain information from it and give information to it). A concrete
21 // implementation must be provided by the driver. 24 // implementation must be provided by the driver.
droger 2015/04/07 15:33:24 Is this comment up to date? It seems that the driv
sdefresne 2015/04/07 16:50:06 Acknowledged.
22 class FaviconDriver { 25 class FaviconDriver {
23 public: 26 public:
27 // Adds/Removes an observer.
28 void AddObserver(FaviconDriverObserver* observer);
29 void RemoveObserver(FaviconDriverObserver* observer);
30
31 // Initiates loading the favicon for the specified url.
32 virtual void FetchFavicon(const GURL& url) = 0;
33
34 // Saves the favicon for the current page.
35 virtual void SaveFavicon() = 0;
36
37 // Returns the favicon for this tab, or IDR_DEFAULT_FAVICON if the tab does
38 // not have a favicon. The default implementation uses the current navigation
39 // entry. This will return an empty bitmap if there are no navigation
droger 2015/04/07 15:33:24 s/This will return/Returns/
sdefresne 2015/04/07 16:50:06 Done.
40 // entries, which should rarely happen.
41 virtual gfx::Image GetFavicon() const = 0;
42
43 // Returns true if we have the favicon for the page.
44 virtual bool FaviconIsValid() const = 0;
45
24 // Starts the download for the given favicon. When finished, the driver 46 // Starts the download for the given favicon. When finished, the driver
25 // will call OnDidDownloadFavicon() with the results. 47 // will call OnDidDownloadFavicon() with the results.
26 // Returns the unique id of the download request. The id will be passed 48 // Returns the unique id of the download request. The id will be passed
27 // in OnDidDownloadFavicon(). 49 // in OnDidDownloadFavicon().
28 // Bitmaps with pixel sizes larger than |max_bitmap_size| are filtered out 50 // Bitmaps with pixel sizes larger than |max_bitmap_size| are filtered out
29 // from the bitmap results. If there are no bitmap results <= 51 // from the bitmap results. If there are no bitmap results <=
30 // |max_bitmap_size|, the smallest bitmap is resized to |max_bitmap_size| and 52 // |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. 53 // is the only result. A |max_bitmap_size| of 0 means unlimited.
32 virtual int StartDownload(const GURL& url, int max_bitmap_size) = 0; 54 virtual int StartDownload(const GURL& url, int max_bitmap_size) = 0;
33 55
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 virtual void SetActiveFaviconImage(const gfx::Image& image) = 0; 89 virtual void SetActiveFaviconImage(const gfx::Image& image) = 0;
68 90
69 // Notifies the driver a favicon image is available. |image| is not 91 // Notifies the driver a favicon image is available. |image| is not
70 // necessarily 16x16. |icon_url| is the url the image is from. If 92 // necessarily 16x16. |icon_url| is the url the image is from. If
71 // |is_active_favicon| is true the image corresponds to the favicon 93 // |is_active_favicon| is true the image corresponds to the favicon
72 // (possibly empty) of the page. 94 // (possibly empty) of the page.
73 virtual void OnFaviconAvailable(const gfx::Image& image, 95 virtual void OnFaviconAvailable(const gfx::Image& image,
74 const GURL& icon_url, 96 const GURL& icon_url,
75 bool is_active_favicon) = 0; 97 bool is_active_favicon) = 0;
76 98
77 // Sends notification that the current page favicon change. |icon_url_changed| 99 // Returns whether the driver is waiting for a download to complete or for
78 // is true if the URL of the favicon changed in addition to the favicon image. 100 // data from the FaviconService. Reserved for testing.
79 virtual void NotifyFaviconUpdated(bool icon_url_changed) = 0; 101 virtual bool HasPendingTasksForTest() = 0;
80 102
81 protected: 103 protected:
82 FaviconDriver() {} 104 FaviconDriver();
83 virtual ~FaviconDriver() {} 105 virtual ~FaviconDriver();
106
107 // Informs FaviconDriverObservers that favicon |image| has been retrieved from
108 // either website or cached storage.
109 void NotifyFaviconAvailable(const gfx::Image& image);
110
111 // Informs FaviconDriverObservers that favicon has changed for the current
112 // page. |icon_url_changed| is true if the favicon URL has also changed since
113 // the last call.
114 virtual void NotifyFaviconUpdated(bool icon_url_changed);
84 115
85 private: 116 private:
117 ObserverList<FaviconDriverObserver> observer_list_;
118
86 DISALLOW_COPY_AND_ASSIGN(FaviconDriver); 119 DISALLOW_COPY_AND_ASSIGN(FaviconDriver);
87 }; 120 };
88 121
89 } // namespace favicon 122 } // namespace favicon
90 123
91 #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_ 124 #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698