Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / favicon / favicon_tab_helper.h
index e6a66ad..97ed230 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "base/basictypes.h"
 #include "base/callback.h"
+#include "base/observer_list.h"
 #include "components/favicon/core/browser/favicon_client.h"
 #include "components/favicon/core/favicon_driver.h"
 #include "content/public/browser/web_contents_observer.h"
@@ -25,6 +26,7 @@ struct FaviconStatus;
 
 class GURL;
 class FaviconHandler;
+class FaviconTabHelperObserver;
 class Profile;
 class SkBitmap;
 
@@ -38,7 +40,7 @@ class FaviconTabHelper : public content::WebContentsObserver,
                          public FaviconDriver,
                          public content::WebContentsUserData<FaviconTabHelper> {
  public:
-  virtual ~FaviconTabHelper();
+  ~FaviconTabHelper() override;
 
   // Initiates loading the favicon for the specified url.
   void FetchFavicon(const GURL& url);
@@ -64,23 +66,25 @@ class FaviconTabHelper : public content::WebContentsObserver,
 
   // content::WebContentsObserver override. Must be public, because also
   // called from PrerenderContents.
-  virtual void DidUpdateFaviconURL(
-      const std::vector<content::FaviconURL>& candidates) OVERRIDE;
+  void DidUpdateFaviconURL(
+      const std::vector<content::FaviconURL>& candidates) override;
 
   // Saves the favicon for the current page.
   void SaveFavicon();
 
+  void AddObserver(FaviconTabHelperObserver* observer);
+  void RemoveObserver(FaviconTabHelperObserver* observer);
+
   // FaviconDriver methods.
-  virtual int StartDownload(const GURL& url, int max_bitmap_size) OVERRIDE;
-  virtual void NotifyFaviconUpdated(bool icon_url_changed) OVERRIDE;
-  virtual bool IsOffTheRecord() OVERRIDE;
-  virtual const gfx::Image GetActiveFaviconImage() OVERRIDE;
-  virtual const GURL GetActiveFaviconURL() OVERRIDE;
-  virtual bool GetActiveFaviconValidity() OVERRIDE;
-  virtual const GURL GetActiveURL() OVERRIDE;
-  virtual void SetActiveFaviconImage(gfx::Image image) OVERRIDE;
-  virtual void SetActiveFaviconURL(GURL url) OVERRIDE;
-  virtual void SetActiveFaviconValidity(bool validity) OVERRIDE;
+  int StartDownload(const GURL& url, int max_bitmap_size) override;
+  bool IsOffTheRecord() override;
+  const gfx::Image GetActiveFaviconImage() override;
+  const GURL GetActiveFaviconURL() override;
+  bool GetActiveFaviconValidity() override;
+  const GURL GetActiveURL() override;
+  void OnFaviconAvailable(const gfx::Image& image,
+                          const GURL& url,
+                          bool is_active_favicon) override;
 
   // Favicon download callback.
   void DidDownloadFavicon(
@@ -95,19 +99,29 @@ class FaviconTabHelper : public content::WebContentsObserver,
   friend class content::WebContentsUserData<FaviconTabHelper>;
 
   // content::WebContentsObserver overrides.
-  virtual void DidStartNavigationToPendingEntry(
+  void DidStartNavigationToPendingEntry(
       const GURL& url,
-      content::NavigationController::ReloadType reload_type) OVERRIDE;
-  virtual void DidNavigateMainFrame(
+      content::NavigationController::ReloadType reload_type) override;
+  void DidNavigateMainFrame(
       const content::LoadCommittedDetails& details,
-      const content::FrameNavigateParams& params) OVERRIDE;
+      const content::FrameNavigateParams& params) override;
+
+  // Sets whether the page's favicon is valid (if false, the default favicon is
+  // being used). Requires GetActiveURL() to be valid.
+  void SetActiveFaviconValidity(bool validity);
+
+  // Sets the URL of the favicon's bitmap.
+  void SetActiveFaviconURL(GURL url);
+
+  // Sets the bitmap of the current page's favicon.
+  void SetActiveFaviconImage(gfx::Image image);
 
   // Helper method that returns the active navigation entry's favicon.
   content::FaviconStatus& GetFaviconStatus();
 
   Profile* profile_;
 
-  scoped_ptr<FaviconClient> client_;
+  FaviconClient* client_;
 
   std::vector<content::FaviconURL> favicon_urls_;
 
@@ -117,6 +131,8 @@ class FaviconTabHelper : public content::WebContentsObserver,
   // browser_defaults::kEnableTouchIcon is false.
   scoped_ptr<FaviconHandler> touch_icon_handler_;
 
+  ObserverList<FaviconTabHelperObserver> observer_list_;
+
   DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper);
 };