OLD | NEW |
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/observer_list.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 // Returns the favicon for this tab, or IDR_DEFAULT_FAVICON if the tab does | 34 // Returns the favicon for this tab, or IDR_DEFAULT_FAVICON if the tab does |
35 // not have a favicon. The default implementation uses the current navigation | 35 // not have a favicon. The default implementation uses the current navigation |
36 // entry. Returns an empty bitmap if there are no navigation entries, which | 36 // entry. Returns an empty bitmap if there are no navigation entries, which |
37 // should rarely happen. | 37 // should rarely happen. |
38 virtual gfx::Image GetFavicon() const = 0; | 38 virtual gfx::Image GetFavicon() const = 0; |
39 | 39 |
40 // Returns true if we have the favicon for the page. | 40 // Returns true if we have the favicon for the page. |
41 virtual bool FaviconIsValid() const = 0; | 41 virtual bool FaviconIsValid() const = 0; |
42 | 42 |
43 // Starts the download for the given favicon. When finished, the driver | |
44 // will call OnDidDownloadFavicon() with the results. | |
45 // Returns the unique id of the download request. The id will be passed | |
46 // in OnDidDownloadFavicon(). | |
47 // Bitmaps with pixel sizes larger than |max_bitmap_size| are filtered out | |
48 // from the bitmap results. If there are no bitmap results <= | |
49 // |max_bitmap_size|, the smallest bitmap is resized to |max_bitmap_size| and | |
50 // is the only result. A |max_bitmap_size| of 0 means unlimited. | |
51 virtual int StartDownload(const GURL& url, int max_bitmap_size) = 0; | |
52 | |
53 // Returns whether the user is operating in an off-the-record context. | |
54 virtual bool IsOffTheRecord() = 0; | |
55 | |
56 // Returns whether |url| is bookmarked. | |
57 virtual bool IsBookmarked(const GURL& url) = 0; | |
58 | |
59 // Returns the URL of the current page, if any. Returns an invalid URL | 43 // Returns the URL of the current page, if any. Returns an invalid URL |
60 // otherwise. | 44 // otherwise. |
61 virtual GURL GetActiveURL() = 0; | 45 virtual GURL GetActiveURL() = 0; |
62 | 46 |
63 // Notifies the driver that the favicon image has been updated. | |
64 // See comment for FaviconDriverObserver::OnFaviconUpdated() for more details. | |
65 virtual void OnFaviconUpdated( | |
66 const GURL& page_url, | |
67 FaviconDriverObserver::NotificationIconType notification_icon_type, | |
68 const GURL& icon_url, | |
69 bool icon_url_changed, | |
70 const gfx::Image& image) = 0; | |
71 | |
72 // Returns whether the driver is waiting for a download to complete or for | |
73 // data from the FaviconService. Reserved for testing. | |
74 virtual bool HasPendingTasksForTest() = 0; | |
75 | |
76 protected: | 47 protected: |
77 FaviconDriver(); | 48 FaviconDriver(); |
78 virtual ~FaviconDriver(); | 49 virtual ~FaviconDriver(); |
79 | 50 |
80 // Notifies FaviconDriverObservers that the favicon image has been updated. | 51 // Notifies FaviconDriverObservers that the favicon image has been updated. |
81 void NotifyFaviconUpdatedObservers( | 52 void NotifyFaviconUpdatedObservers( |
82 FaviconDriverObserver::NotificationIconType notification_icon_type, | 53 FaviconDriverObserver::NotificationIconType notification_icon_type, |
83 const GURL& icon_url, | 54 const GURL& icon_url, |
84 bool icon_url_changed, | 55 bool icon_url_changed, |
85 const gfx::Image& image); | 56 const gfx::Image& image); |
86 | 57 |
87 | |
88 private: | 58 private: |
89 base::ObserverList<FaviconDriverObserver> observer_list_; | 59 base::ObserverList<FaviconDriverObserver> observer_list_; |
90 | 60 |
91 DISALLOW_COPY_AND_ASSIGN(FaviconDriver); | 61 DISALLOW_COPY_AND_ASSIGN(FaviconDriver); |
92 }; | 62 }; |
93 | 63 |
94 } // namespace favicon | 64 } // namespace favicon |
95 | 65 |
96 #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_ | 66 #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_ |
OLD | NEW |