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_OBSERVER_H_ | 5 #ifndef COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_OBSERVER_H_ |
6 #define COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_OBSERVER_H_ | 6 #define COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_OBSERVER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 | 9 |
10 namespace gfx { | 10 namespace gfx { |
11 class Image; | 11 class Image; |
12 } | 12 } |
13 | 13 |
| 14 class GURL; |
| 15 |
14 namespace favicon { | 16 namespace favicon { |
15 | 17 |
16 class FaviconDriver; | 18 class FaviconDriver; |
17 | 19 |
18 // An observer implemented by classes which are interested in event from | 20 // An observer implemented by classes which are interested in event from |
19 // FaviconDriver. | 21 // FaviconDriver. |
20 class FaviconDriverObserver { | 22 class FaviconDriverObserver { |
21 public: | 23 public: |
| 24 // The type of the icon in the OnFaviconUpdated() notification. |
| 25 enum NotificationIconType { |
| 26 // Multi-resolution 16x16 (gfx::kFaviconSize) device independant pixel |
| 27 // favicon of type favicon_base::FAVICON. If the page does not provide a |
| 28 // 16x16 DIP icon, the icon is generated by resizing another icon. |
| 29 NON_TOUCH_16_DIP, |
| 30 // Largest icon specified by the page which is of type |
| 31 // favicon_base::FAVICON. |
| 32 NON_TOUCH_LARGEST, |
| 33 // Largest icon specified by the page which is of type |
| 34 // favicon_base::TOUCH_ICON or of type favicon_base::TOUCH_PRECOMPOSED_ICON. |
| 35 TOUCH_LARGEST |
| 36 }; |
| 37 |
22 FaviconDriverObserver() {} | 38 FaviconDriverObserver() {} |
23 virtual ~FaviconDriverObserver() {} | 39 virtual ~FaviconDriverObserver() {} |
24 | 40 |
25 // Called when favicon |image| is retrieved from either web site or cached | 41 // Called when either: |
26 // storage. | 42 // 1) Chrome determines the best icon for the page for |
27 virtual void OnFaviconAvailable(const gfx::Image& image) = 0; | 43 // |notification_icon_type|. |
28 | 44 // Not called if the site does not provide a custom icon and the best icon |
29 // Called when favicon has changed for the current page. |icon_url_changed| is | 45 // for the page is the default one provided by Chrome. |
30 // true if the favicon URL has also changed. | 46 // 2) The site changes its icon via Javascript. |
| 47 // |icon_url_changed| is false if OnFaviconAvailable() was already called for |
| 48 // |notification_icon_type| for the current page URL and |icon_url| is the |
| 49 // same as for the previous notification for |notification_icon_type|. |
| 50 // Example: |
| 51 // Page: www.google.com |
| 52 // Icon: www.google.com/favicon.ico |
| 53 // Data for www.google.com/favicon.ico in the database has expired. |
| 54 // i) OnFaviconUpdated() is called with |icon_url_changed| == true to notify |
| 55 // that a favicon was found in the history database. |
| 56 // ii) As the history data has expired, the icon at www.google.com/favicon.ico |
| 57 // is redownloaded and stored into the database. OnFaviconUpdated() is |
| 58 // called with |icon_url_changed| == false to notify that the icon in the |
| 59 // history database MAY have changed visually. |
31 virtual void OnFaviconUpdated(FaviconDriver* favicon_driver, | 60 virtual void OnFaviconUpdated(FaviconDriver* favicon_driver, |
32 bool icon_url_changed) = 0; | 61 NotificationIconType notification_icon_type, |
| 62 const GURL& icon_url, |
| 63 bool icon_url_changed, |
| 64 const gfx::Image& image) = 0; |
33 | 65 |
34 private: | 66 private: |
35 DISALLOW_COPY_AND_ASSIGN(FaviconDriverObserver); | 67 DISALLOW_COPY_AND_ASSIGN(FaviconDriverObserver); |
36 }; | 68 }; |
37 | 69 |
38 } // namespace favicon | 70 } // namespace favicon |
39 | 71 |
40 #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_OBSERVER_H_ | 72 #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_OBSERVER_H_ |
OLD | NEW |