Commit 698fd44c authored by jif@chromium.org's avatar jif@chromium.org

Renamed FaviconHandlerDelegate to FaviconDriver.

Note:
Currently FaviconTabHelper implements both FaviconClient and FaviconDriver.
A follow up CL will create a ContentFaviconDriver class that implements
FaviconDriver. FaviconTabHelper will then own an instance of the
ContentFaviconDriver, instead of inheriting from FaviconDriver.

BUG=362074

Review URL: https://codereview.chromium.org/255843002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266551 0039d316-1c4b-4281-b951-d872f2087c98
parent 84b07fbe
...@@ -241,7 +241,7 @@ FaviconHandler::FaviconCandidate::FaviconCandidate( ...@@ -241,7 +241,7 @@ FaviconHandler::FaviconCandidate::FaviconCandidate(
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
FaviconHandler::FaviconHandler(FaviconClient* client, FaviconHandler::FaviconHandler(FaviconClient* client,
FaviconHandlerDelegate* delegate, FaviconDriver* driver,
Type icon_type, Type icon_type,
bool download_largest_icon) bool download_largest_icon)
: got_favicon_from_history_(false), : got_favicon_from_history_(false),
...@@ -252,8 +252,8 @@ FaviconHandler::FaviconHandler(FaviconClient* client, ...@@ -252,8 +252,8 @@ FaviconHandler::FaviconHandler(FaviconClient* client,
favicon_base::TOUCH_PRECOMPOSED_ICON), favicon_base::TOUCH_PRECOMPOSED_ICON),
download_largest_icon_(download_largest_icon), download_largest_icon_(download_largest_icon),
client_(client), client_(client),
delegate_(delegate) { driver_(driver) {
DCHECK(delegate_); DCHECK(driver_);
} }
FaviconHandler::~FaviconHandler() { FaviconHandler::~FaviconHandler() {
...@@ -495,7 +495,7 @@ void FaviconHandler::OnDidDownloadFavicon( ...@@ -495,7 +495,7 @@ void FaviconHandler::OnDidDownloadFavicon(
} }
NavigationEntry* FaviconHandler::GetEntry() { NavigationEntry* FaviconHandler::GetEntry() {
NavigationEntry* entry = delegate_->GetActiveEntry(); NavigationEntry* entry = driver_->GetActiveEntry();
if (entry && UrlMatches(entry->GetURL(), url_)) if (entry && UrlMatches(entry->GetURL(), url_))
return entry; return entry;
...@@ -510,7 +510,7 @@ int FaviconHandler::DownloadFavicon(const GURL& image_url, ...@@ -510,7 +510,7 @@ int FaviconHandler::DownloadFavicon(const GURL& image_url,
NOTREACHED(); NOTREACHED();
return 0; return 0;
} }
return delegate_->StartDownload(image_url, max_bitmap_size); return driver_->StartDownload(image_url, max_bitmap_size);
} }
void FaviconHandler::UpdateFaviconMappingAndFetch( void FaviconHandler::UpdateFaviconMappingAndFetch(
...@@ -557,7 +557,7 @@ void FaviconHandler::SetHistoryFavicons(const GURL& page_url, ...@@ -557,7 +557,7 @@ void FaviconHandler::SetHistoryFavicons(const GURL& page_url,
} }
bool FaviconHandler::ShouldSaveFavicon(const GURL& url) { bool FaviconHandler::ShouldSaveFavicon(const GURL& url) {
if (!delegate_->IsOffTheRecord()) if (!driver_->IsOffTheRecord())
return true; return true;
// Otherwise store the favicon if the page is bookmarked. // Otherwise store the favicon if the page is bookmarked.
...@@ -565,7 +565,7 @@ bool FaviconHandler::ShouldSaveFavicon(const GURL& url) { ...@@ -565,7 +565,7 @@ bool FaviconHandler::ShouldSaveFavicon(const GURL& url) {
} }
void FaviconHandler::NotifyFaviconUpdated(bool icon_url_changed) { void FaviconHandler::NotifyFaviconUpdated(bool icon_url_changed) {
delegate_->NotifyFaviconUpdated(icon_url_changed); driver_->NotifyFaviconUpdated(icon_url_changed);
} }
void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService( void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService(
...@@ -633,7 +633,7 @@ void FaviconHandler::DownloadFaviconOrAskFaviconService( ...@@ -633,7 +633,7 @@ void FaviconHandler::DownloadFaviconOrAskFaviconService(
// We don't know the favicon, but we may have previously downloaded the // We don't know the favicon, but we may have previously downloaded the
// favicon for another page that shares the same favicon. Ask for the // favicon for another page that shares the same favicon. Ask for the
// favicon given the favicon URL. // favicon given the favicon URL.
if (delegate_->IsOffTheRecord()) { if (driver_->IsOffTheRecord()) {
GetFaviconFromFaviconService( GetFaviconFromFaviconService(
icon_url, icon_type, icon_url, icon_type,
base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)), base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)),
...@@ -689,7 +689,7 @@ int FaviconHandler::ScheduleDownload(const GURL& url, ...@@ -689,7 +689,7 @@ int FaviconHandler::ScheduleDownload(const GURL& url,
const GURL& image_url, const GURL& image_url,
favicon_base::IconType icon_type) { favicon_base::IconType icon_type) {
// A max bitmap size is specified to avoid receiving huge bitmaps in // A max bitmap size is specified to avoid receiving huge bitmaps in
// OnDidDownloadFavicon(). See FaviconHandlerDelegate::StartDownload() // OnDidDownloadFavicon(). See FaviconDriver::StartDownload()
// for more details about the max bitmap size. // for more details about the max bitmap size.
const int download_id = DownloadFavicon(image_url, const int download_id = DownloadFavicon(image_url,
GetMaximalIconSize(icon_type)); GetMaximalIconSize(icon_type));
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "url/gurl.h" #include "url/gurl.h"
class FaviconClient; class FaviconClient;
class FaviconHandlerDelegate; class FaviconDriver;
class SkBitmap; class SkBitmap;
namespace base { namespace base {
...@@ -87,7 +87,7 @@ class FaviconHandler { ...@@ -87,7 +87,7 @@ class FaviconHandler {
}; };
FaviconHandler(FaviconClient* client, FaviconHandler(FaviconClient* client,
FaviconHandlerDelegate* delegate, FaviconDriver* driver,
Type icon_type, Type icon_type,
bool download_largest_icon); bool download_largest_icon);
virtual ~FaviconHandler(); virtual ~FaviconHandler();
...@@ -159,7 +159,7 @@ class FaviconHandler { ...@@ -159,7 +159,7 @@ class FaviconHandler {
// Returns true if the favicon should be saved. // Returns true if the favicon should be saved.
virtual bool ShouldSaveFavicon(const GURL& url); virtual bool ShouldSaveFavicon(const GURL& url);
// Notifies the delegate that the favicon for the active entry was updated. // Notifies the driver that the favicon for the active entry was updated.
// |icon_url_changed| is true if a favicon with a different icon URL has been // |icon_url_changed| is true if a favicon with a different icon URL has been
// selected since the previous call to NotifyFaviconUpdated(). // selected since the previous call to NotifyFaviconUpdated().
virtual void NotifyFaviconUpdated(bool icon_url_changed); virtual void NotifyFaviconUpdated(bool icon_url_changed);
...@@ -295,8 +295,8 @@ class FaviconHandler { ...@@ -295,8 +295,8 @@ class FaviconHandler {
// The client which implements embedder-specific Favicon operations. // The client which implements embedder-specific Favicon operations.
FaviconClient* client_; // weak FaviconClient* client_; // weak
// This handler's delegate. // This handler's driver.
FaviconHandlerDelegate* delegate_; // weak FaviconDriver* driver_; // weak
// Best image we've seen so far. As images are downloaded from the page they // Best image we've seen so far. As images are downloaded from the page they
// are stored here. When there is an exact match, or no more images are // are stored here. When there is an exact match, or no more images are
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/callback.h" #include "base/callback.h"
#include "components/favicon/core/browser/favicon_client.h" #include "components/favicon/core/browser/favicon_client.h"
#include "components/favicon/core/favicon_handler_delegate.h" #include "components/favicon/core/favicon_driver.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h" #include "content/public/browser/web_contents_user_data.h"
#include "content/public/common/favicon_url.h" #include "content/public/common/favicon_url.h"
...@@ -32,7 +32,7 @@ class SkBitmap; ...@@ -32,7 +32,7 @@ class SkBitmap;
// //
class FaviconTabHelper : public content::WebContentsObserver, class FaviconTabHelper : public content::WebContentsObserver,
public FaviconClient, public FaviconClient,
public FaviconHandlerDelegate, public FaviconDriver,
public content::WebContentsUserData<FaviconTabHelper> { public content::WebContentsUserData<FaviconTabHelper> {
public: public:
virtual ~FaviconTabHelper(); virtual ~FaviconTabHelper();
...@@ -68,7 +68,7 @@ class FaviconTabHelper : public content::WebContentsObserver, ...@@ -68,7 +68,7 @@ class FaviconTabHelper : public content::WebContentsObserver,
// Saves the favicon for the current page. // Saves the favicon for the current page.
void SaveFavicon(); void SaveFavicon();
// FaviconHandlerDelegate methods. // FaviconDriver methods.
virtual content::NavigationEntry* GetActiveEntry() OVERRIDE; virtual content::NavigationEntry* GetActiveEntry() OVERRIDE;
virtual int StartDownload(const GURL& url, int max_bitmap_size) OVERRIDE; virtual int StartDownload(const GURL& url, int max_bitmap_size) OVERRIDE;
virtual void NotifyFaviconUpdated(bool icon_url_changed) OVERRIDE; virtual void NotifyFaviconUpdated(bool icon_url_changed) OVERRIDE;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
'type': 'none', 'type': 'none',
'sources': [ 'sources': [
'favicon/core/browser/favicon_client.h', 'favicon/core/browser/favicon_client.h',
'favicon/core/favicon_handler_delegate.h', 'favicon/core/favicon_driver.h',
], ],
}, },
], ],
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_DELEGATE_H_ #ifndef COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_
#define COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_DELEGATE_H_ #define COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_
class GURL; class GURL;
...@@ -12,16 +12,16 @@ namespace content { ...@@ -12,16 +12,16 @@ namespace content {
class NavigationEntry; class NavigationEntry;
} }
// This class provides a delegate interface for a FaviconHandler. It allows the // Interface that allows Favicon core code to interact with its driver (i.e.,
// FaviconHandler to ask its delegate for information or notify its delegate // obtain information from it and give information to it). A concrete
// about changes. // implementation must be provided by the driver.
class FaviconHandlerDelegate { class FaviconDriver {
public: public:
// Returns the current NavigationEntry. // Returns the current NavigationEntry.
// TODO(jif): Abstract the NavigationEntry (crbug.com/359598). // TODO(jif): Abstract the NavigationEntry (crbug.com/359598).
virtual content::NavigationEntry* GetActiveEntry() = 0; virtual content::NavigationEntry* GetActiveEntry() = 0;
// Starts the download for the given favicon. When finished, the delegate // Starts the download for the given favicon. When finished, the driver
// will call OnDidDownloadFavicon() with the results. // will call OnDidDownloadFavicon() with the results.
// Returns the unique id of the download request. The id will be passed // Returns the unique id of the download request. The id will be passed
// in OnDidDownloadFavicon(). // in OnDidDownloadFavicon().
...@@ -31,7 +31,7 @@ class FaviconHandlerDelegate { ...@@ -31,7 +31,7 @@ class FaviconHandlerDelegate {
// is the only result. A |max_bitmap_size| of 0 means unlimited. // is the only result. A |max_bitmap_size| of 0 means unlimited.
virtual int StartDownload(const GURL& url, int max_bitmap_size) = 0; virtual int StartDownload(const GURL& url, int max_bitmap_size) = 0;
// Notifies the delegate that the favicon for the active entry was updated. // Notifies the driver that the favicon for the active entry was updated.
// |icon_url_changed| is true if a favicon with a different icon URL has // |icon_url_changed| is true if a favicon with a different icon URL has
// been selected since the previous call to NotifyFaviconUpdated(). // been selected since the previous call to NotifyFaviconUpdated().
virtual void NotifyFaviconUpdated(bool icon_url_changed) = 0; virtual void NotifyFaviconUpdated(bool icon_url_changed) = 0;
...@@ -40,4 +40,4 @@ class FaviconHandlerDelegate { ...@@ -40,4 +40,4 @@ class FaviconHandlerDelegate {
virtual bool IsOffTheRecord() = 0; virtual bool IsOffTheRecord() = 0;
}; };
#endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_DELEGATE_H_ #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment