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

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

Issue 1407353012: Refactor FaviconDriver::OnFaviconAvailable() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@initial_simplify
Patch Set: Created 5 years, 1 month 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_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 #include "url/gurl.h"
sky 2015/11/20 00:44:26 You should be able to forward declare GURL.
9 10
10 namespace gfx { 11 namespace gfx {
11 class Image; 12 class Image;
12 } 13 }
13 14
14 namespace favicon { 15 namespace favicon {
15 16
16 class FaviconDriver; 17 class FaviconDriver;
17 18
18 // An observer implemented by classes which are interested in event from 19 // An observer implemented by classes which are interested in event from
19 // FaviconDriver. 20 // FaviconDriver.
20 class FaviconDriverObserver { 21 class FaviconDriverObserver {
21 public: 22 public:
23 // The type of the icon in the OnFaviconUpdated() notification.
24 enum NotificationIconType {
25 // Multi-resolution 16x16 (gfx::kFaviconSize) device independant pixel
26 // favicon of type favicon_base::FAVICON. If the page does not provide a
27 // 16x16 DIP icon, the icon is generated by resizing another icon.
28 NON_TOUCH_16_DIP,
sky 2015/11/20 00:44:26 I'm not a fan of NON_TOUCH_ here. I prefer DEFAULT
pkotwicz 2015/11/21 23:04:08 I think that the names that I have are more descri
29 // Largest icon specified by the page which is of type
30 // favicon_base::FAVICON.
31 NON_TOUCH_LARGEST,
32 // Largest icon specified by the page which is of type
33 // favicon_base::TOUCH_ICON or of type favicon_base::TOUCH_PRECOMPOSED_ICON.
34 TOUCH_LARGEST
35 };
36
22 FaviconDriverObserver() {} 37 FaviconDriverObserver() {}
23 virtual ~FaviconDriverObserver() {} 38 virtual ~FaviconDriverObserver() {}
24 39
25 // Called when favicon |image| is retrieved from either web site or cached 40 // Called when either:
26 // storage. 41 // 1) Chrome determines the best icon for the page for
27 virtual void OnFaviconAvailable(const gfx::Image& image) = 0; 42 // |notification_icon_type|.
28 43 // 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 44 // for the page is the default one provided by Chrome.
30 // true if the favicon URL has also changed. 45 // 2) The site changes its icon via Javascript.
46 // |icon_url_changed| is false if OnFaviconAvailable() was already called for
47 // |notification_icon_type| for the current page URL and |icon_url| is the
48 // same as for the previous notification for |notification_icon_type|.
49 // Example:
50 // Page: www.google.com
51 // Icon: www.google.com/favicon.ico
52 // Data for www.google.com/favicon.ico in the database has expired.
53 // i) OnFaviconUpdated() is called with |icon_url_changed| == true to notify
54 // that a favicon was found in the history database.
55 // ii) As the history data has expired, the icon at www.google.com/favicon.ico
56 // is redownloaded and stored into the database. OnFaviconUpdated() is
57 // called with |icon_url_changed| == false to notify that the icon in the
58 // history database MAY have changed visually.
31 virtual void OnFaviconUpdated(FaviconDriver* favicon_driver, 59 virtual void OnFaviconUpdated(FaviconDriver* favicon_driver,
32 bool icon_url_changed) = 0; 60 NotificationIconType notification_icon_type,
61 const GURL& icon_url,
62 bool icon_url_changed,
63 const gfx::Image& image) = 0;
33 64
34 private: 65 private:
35 DISALLOW_COPY_AND_ASSIGN(FaviconDriverObserver); 66 DISALLOW_COPY_AND_ASSIGN(FaviconDriverObserver);
36 }; 67 };
37 68
38 } // namespace favicon 69 } // namespace favicon
39 70
40 #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_OBSERVER_H_ 71 #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698