| 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" |
| 11 #include "components/favicon/core/favicon_driver_observer.h" |
| 11 | 12 |
| 12 class GURL; | 13 class GURL; |
| 13 | 14 |
| 14 namespace gfx { | 15 namespace gfx { |
| 15 class Image; | 16 class Image; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace favicon { | 19 namespace favicon { |
| 19 | 20 |
| 20 class FaviconDriverObserver; | |
| 21 | |
| 22 // Interface that allows favicon core code to obtain information about the | 21 // Interface that allows favicon core code to obtain information about the |
| 23 // current page. This is partially implemented by FaviconDriverImpl, and | 22 // current page. This is partially implemented by FaviconDriverImpl, and |
| 24 // concrete implementation should be based on that class instead of directly | 23 // concrete implementation should be based on that class instead of directly |
| 25 // subclassing FaviconDriver. | 24 // subclassing FaviconDriver. |
| 26 class FaviconDriver { | 25 class FaviconDriver { |
| 27 public: | 26 public: |
| 28 // Adds/Removes an observer. | 27 // Adds/Removes an observer. |
| 29 void AddObserver(FaviconDriverObserver* observer); | 28 void AddObserver(FaviconDriverObserver* observer); |
| 30 void RemoveObserver(FaviconDriverObserver* observer); | 29 void RemoveObserver(FaviconDriverObserver* observer); |
| 31 | 30 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 54 // Returns whether the user is operating in an off-the-record context. | 53 // Returns whether the user is operating in an off-the-record context. |
| 55 virtual bool IsOffTheRecord() = 0; | 54 virtual bool IsOffTheRecord() = 0; |
| 56 | 55 |
| 57 // Returns whether |url| is bookmarked. | 56 // Returns whether |url| is bookmarked. |
| 58 virtual bool IsBookmarked(const GURL& url) = 0; | 57 virtual bool IsBookmarked(const GURL& url) = 0; |
| 59 | 58 |
| 60 // Returns the URL of the current page, if any. Returns an invalid URL | 59 // Returns the URL of the current page, if any. Returns an invalid URL |
| 61 // otherwise. | 60 // otherwise. |
| 62 virtual GURL GetActiveURL() = 0; | 61 virtual GURL GetActiveURL() = 0; |
| 63 | 62 |
| 64 // Sets whether the page's favicon is valid (if false, the default favicon is | 63 // Notifies the driver that the favicon image has been updated. |
| 65 // being used). | 64 // See comment for FaviconDriverObserver::OnFaviconUpdated() for more details. |
| 66 virtual void SetActiveFaviconValidity(bool valid) = 0; | 65 virtual void OnFaviconUpdated( |
| 67 | 66 const GURL& page_url, |
| 68 // Returns the URL of the current page's favicon. | 67 FaviconDriverObserver::NotificationIconType notification_icon_type, |
| 69 virtual GURL GetActiveFaviconURL() = 0; | 68 const GURL& icon_url, |
| 70 | 69 bool icon_url_changed, |
| 71 // Sets the URL of the favicon's bitmap. | 70 const gfx::Image& image) = 0; |
| 72 virtual void SetActiveFaviconURL(const GURL& url) = 0; | |
| 73 | |
| 74 // Sets the bitmap of the current page's favicon. | |
| 75 virtual void SetActiveFaviconImage(const gfx::Image& image) = 0; | |
| 76 | |
| 77 // Notifies the driver a favicon image is available. |image| is not | |
| 78 // necessarily 16x16. |icon_url| is the url the image is from. If | |
| 79 // |is_active_favicon| is true the image corresponds to the favicon | |
| 80 // (possibly empty) of the page. | |
| 81 virtual void OnFaviconAvailable(const GURL& page_url, | |
| 82 const GURL& icon_url, | |
| 83 const gfx::Image& image, | |
| 84 bool is_active_favicon) = 0; | |
| 85 | 71 |
| 86 // Returns whether the driver is waiting for a download to complete or for | 72 // Returns whether the driver is waiting for a download to complete or for |
| 87 // data from the FaviconService. Reserved for testing. | 73 // data from the FaviconService. Reserved for testing. |
| 88 virtual bool HasPendingTasksForTest() = 0; | 74 virtual bool HasPendingTasksForTest() = 0; |
| 89 | 75 |
| 90 protected: | 76 protected: |
| 91 FaviconDriver(); | 77 FaviconDriver(); |
| 92 virtual ~FaviconDriver(); | 78 virtual ~FaviconDriver(); |
| 93 | 79 |
| 94 // Informs FaviconDriverObservers that favicon |image| has been retrieved from | 80 // Notifies FaviconDriverObservers that the favicon image has been updated. |
| 95 // either website or cached storage. | 81 void NotifyFaviconUpdatedObservers( |
| 96 void NotifyFaviconAvailable(const gfx::Image& image); | 82 FaviconDriverObserver::NotificationIconType notification_icon_type, |
| 83 const GURL& icon_url, |
| 84 bool icon_url_changed, |
| 85 const gfx::Image& image); |
| 97 | 86 |
| 98 // Informs FaviconDriverObservers that favicon has changed for the current | |
| 99 // page. |icon_url_changed| is true if the favicon URL has also changed since | |
| 100 // the last call. | |
| 101 virtual void NotifyFaviconUpdated(bool icon_url_changed); | |
| 102 | 87 |
| 103 private: | 88 private: |
| 104 base::ObserverList<FaviconDriverObserver> observer_list_; | 89 base::ObserverList<FaviconDriverObserver> observer_list_; |
| 105 | 90 |
| 106 DISALLOW_COPY_AND_ASSIGN(FaviconDriver); | 91 DISALLOW_COPY_AND_ASSIGN(FaviconDriver); |
| 107 }; | 92 }; |
| 108 | 93 |
| 109 } // namespace favicon | 94 } // namespace favicon |
| 110 | 95 |
| 111 #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_ | 96 #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_ |
| OLD | NEW |