diff options
author | sdefresne <sdefresne@chromium.org> | 2015-04-10 08:25:15 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-10 15:25:40 +0000 |
commit | 45582697f9846db420f07615886651e9688e70d3 (patch) | |
tree | e513186de8fcad58e36cb0f33dc462ec210a3ac3 | |
parent | 375ce9a7839b5610d09e6e18f9d0358bf3571a83 (diff) | |
download | chromium_src-45582697f9846db420f07615886651e9688e70d3.zip chromium_src-45582697f9846db420f07615886651e9688e70d3.tar.gz chromium_src-45582697f9846db420f07615886651e9688e70d3.tar.bz2 |
Remove FaviconTabHelper
Convert CreateForWebContents() and ShouldDisplayFavicon() from static
method into free functions and move them into the favicon namespace.
Port client code to use favicon::ContentFaviconDriver::FromWebContents()
to access the favicon::FaviconDriver and prefer to use the public base
class instead of favicon::ContentFaviconDriver.
Rename FaviconTabHelperTest to ContentFaviconDriverTest.
BUG=359569
TBR=jochen
Review URL: https://codereview.chromium.org/1075443003
Cr-Commit-Position: refs/heads/master@{#324639}
43 files changed, 249 insertions, 258 deletions
diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc index 57976d2..afbe27f 100644 --- a/chrome/browser/android/tab_android.cc +++ b/chrome/browser/android/tab_android.cc @@ -19,7 +19,6 @@ #include "chrome/browser/browser_about_handler.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/prerender/prerender_contents.h" #include "chrome/browser/prerender/prerender_manager.h" @@ -53,6 +52,7 @@ #include "components/bookmarks/browser/bookmark_node.h" #include "components/bookmarks/browser/bookmark_utils.h" #include "components/dom_distiller/core/url_utils.h" +#include "components/favicon/content/content_favicon_driver.h" #include "components/infobars/core/infobar_container.h" #include "components/navigation_interception/intercept_navigation_delegate.h" #include "components/navigation_interception/navigation_params.h" @@ -446,11 +446,11 @@ void TabAndroid::InitWebContents(JNIEnv* env, content::Source<content::NavigationController>( &web_contents()->GetController())); - FaviconTabHelper* favicon_tab_helper = - FaviconTabHelper::FromWebContents(web_contents_.get()); + favicon::FaviconDriver* favicon_driver = + favicon::ContentFaviconDriver::FromWebContents(web_contents_.get()); - if (favicon_tab_helper) - favicon_tab_helper->AddObserver(this); + if (favicon_driver) + favicon_driver->AddObserver(this); synced_tab_delegate_->SetWebContents(web_contents()); @@ -485,11 +485,11 @@ void TabAndroid::DestroyWebContents(JNIEnv* env, content::Source<content::NavigationController>( &web_contents()->GetController())); - FaviconTabHelper* favicon_tab_helper = - FaviconTabHelper::FromWebContents(web_contents_.get()); + favicon::FaviconDriver* favicon_driver = + favicon::ContentFaviconDriver::FromWebContents(web_contents_.get()); - if (favicon_tab_helper) - favicon_tab_helper->RemoveObserver(this); + if (favicon_driver) + favicon_driver->RemoveObserver(this); InstantService* instant_service = InstantServiceFactory::GetForProfile(GetProfile()); @@ -672,14 +672,14 @@ ScopedJavaLocalRef<jobject> TabAndroid::GetFavicon(JNIEnv* env, jobject obj) { ScopedJavaLocalRef<jobject> bitmap; - FaviconTabHelper* favicon_tab_helper = - FaviconTabHelper::FromWebContents(web_contents_.get()); + favicon::FaviconDriver* favicon_driver = + favicon::ContentFaviconDriver::FromWebContents(web_contents_.get()); - if (!favicon_tab_helper) + if (!favicon_driver) return bitmap; // Always return the default favicon in Android. - SkBitmap favicon = favicon_tab_helper->GetFavicon().AsBitmap(); + SkBitmap favicon = favicon_driver->GetFavicon().AsBitmap(); if (!favicon.empty()) { gfx::DeviceDisplayInfo device_info; const float device_scale_factor = device_info.GetDIPScale(); diff --git a/chrome/browser/extensions/api/tabs/ash_panel_contents.cc b/chrome/browser/extensions/api/tabs/ash_panel_contents.cc index 7943327..8502c00 100644 --- a/chrome/browser/extensions/api/tabs/ash_panel_contents.cc +++ b/chrome/browser/extensions/api/tabs/ash_panel_contents.cc @@ -176,15 +176,15 @@ void AshPanelContents::Initialize(content::BrowserContext* context, context, content::SiteInstance::CreateForURL(context, url_)))); // Needed to give the web contents a Window ID. Extension APIs expect web - // contents to have a Window ID. Also required for FaviconTabHelper to - // correctly set the window icon and title. + // contents to have a Window ID. Also required for FaviconDriver to correctly + // set the window icon and title. SessionTabHelper::CreateForWebContents(web_contents_.get()); SessionTabHelper::FromWebContents(web_contents_.get())->SetWindowID( host_->session_id()); // Responsible for loading favicons for the Launcher, which uses different - // logic than the FaviconTabHelper associated with web_contents_ - // (instantiated in AppWindow::Init()) + // logic than the FaviconDriver associated with web_contents_ (instantiated in + // AppWindow::Init()) launcher_favicon_loader_.reset( new LauncherFaviconLoader(this, web_contents_.get())); diff --git a/chrome/browser/extensions/api/tabs/tabs_event_router.cc b/chrome/browser/extensions/api/tabs/tabs_event_router.cc index 8cbd534..bcee3c6 100644 --- a/chrome/browser/extensions/api/tabs/tabs_event_router.cc +++ b/chrome/browser/extensions/api/tabs/tabs_event_router.cc @@ -11,13 +11,13 @@ #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" #include "chrome/browser/extensions/api/tabs/windows_event_router.h" #include "chrome/browser/extensions/extension_tab_util.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_iterator.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/extensions/extension_constants.h" +#include "components/favicon/content/content_favicon_driver.h" #include "content/public/browser/favicon_status.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" @@ -150,7 +150,8 @@ void TabsEventRouter::RegisterForTabNotifications(WebContents* contents) { registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::Source<WebContents>(contents)); - favicon_scoped_observer_.Add(FaviconTabHelper::FromWebContents(contents)); + favicon_scoped_observer_.Add( + favicon::ContentFaviconDriver::FromWebContents(contents)); ZoomController::FromWebContents(contents)->AddObserver(this); } @@ -160,7 +161,8 @@ void TabsEventRouter::UnregisterForTabNotifications(WebContents* contents) { content::Source<NavigationController>(&contents->GetController())); registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::Source<WebContents>(contents)); - favicon_scoped_observer_.Remove(FaviconTabHelper::FromWebContents(contents)); + favicon_scoped_observer_.Remove( + favicon::ContentFaviconDriver::FromWebContents(contents)); ZoomController::FromWebContents(contents)->RemoveObserver(this); } @@ -502,7 +504,7 @@ void TabsEventRouter::Observe(int type, registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::Source<WebContents>(contents)); favicon_scoped_observer_.Remove( - FaviconTabHelper::FromWebContents(contents)); + favicon::ContentFaviconDriver::FromWebContents(contents)); } else { NOTREACHED(); } @@ -587,9 +589,9 @@ void TabsEventRouter::OnFaviconAvailable(const gfx::Image& image) { void TabsEventRouter::OnFaviconUpdated(favicon::FaviconDriver* favicon_driver, bool icon_url_changed) { if (icon_url_changed) { - FaviconTabHelper* favicon_tab_helper = - static_cast<FaviconTabHelper*>(favicon_driver); - FaviconUrlUpdated(favicon_tab_helper->web_contents()); + favicon::ContentFaviconDriver* content_favicon_driver = + static_cast<favicon::ContentFaviconDriver*>(favicon_driver); + FaviconUrlUpdated(content_favicon_driver->web_contents()); } } diff --git a/chrome/browser/extensions/api/tabs/tabs_event_router.h b/chrome/browser/extensions/api/tabs/tabs_event_router.h index 501c5fd..45a63c3 100644 --- a/chrome/browser/extensions/api/tabs/tabs_event_router.h +++ b/chrome/browser/extensions/api/tabs/tabs_event_router.h @@ -19,12 +19,14 @@ #include "content/public/browser/notification_registrar.h" #include "extensions/browser/event_router.h" -class FaviconTabHelper; - namespace content { class WebContents; } +namespace favicon { +class FaviconDriver; +} + namespace extensions { // The TabsEventRouter listens to tab events and routes them to listeners inside @@ -179,7 +181,8 @@ class TabsEventRouter : public TabStripModelObserver, // The main profile that owns this event router. Profile* profile_; - ScopedObserver<FaviconTabHelper, TabsEventRouter> favicon_scoped_observer_; + ScopedObserver<favicon::FaviconDriver, TabsEventRouter> + favicon_scoped_observer_; DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); }; diff --git a/chrome/browser/extensions/favicon_downloader.cc b/chrome/browser/extensions/favicon_downloader.cc index 043a509..f7fff1d 100644 --- a/chrome/browser/extensions/favicon_downloader.cc +++ b/chrome/browser/extensions/favicon_downloader.cc @@ -5,7 +5,7 @@ #include "chrome/browser/extensions/favicon_downloader.h" #include "base/bind.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" +#include "components/favicon/content/content_favicon_driver.h" #include "content/public/browser/web_contents.h" #include "content/public/common/favicon_url.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -49,12 +49,14 @@ int FaviconDownloader::DownloadImage(const GURL& url) { std::vector<content::FaviconURL> FaviconDownloader::GetFaviconURLsFromWebContents() { - FaviconTabHelper* favicon_tab_helper = - web_contents() ? FaviconTabHelper::FromWebContents(web_contents()) : NULL; + favicon::ContentFaviconDriver* content_favicon_driver = + web_contents() + ? favicon::ContentFaviconDriver::FromWebContents(web_contents()) + : nullptr; // If favicon_urls() is empty, we are guaranteed that DidUpdateFaviconURLs has // not yet been called for the current page's navigation. - return favicon_tab_helper ? favicon_tab_helper->favicon_urls() - : std::vector<content::FaviconURL>(); + return content_favicon_driver ? content_favicon_driver->favicon_urls() + : std::vector<content::FaviconURL>(); } void FaviconDownloader::FetchIcons( diff --git a/chrome/browser/extensions/favicon_downloader.h b/chrome/browser/extensions/favicon_downloader.h index e3b73a8..4f4ca01 100644 --- a/chrome/browser/extensions/favicon_downloader.h +++ b/chrome/browser/extensions/favicon_downloader.h @@ -48,7 +48,7 @@ class FaviconDownloader : public content::WebContentsObserver { // This is overridden in testing. virtual int DownloadImage(const GURL& url); - // Queries FaviconTabHelper for the page's current favicon URLs. + // Queries FaviconDriver for the page's current favicon URLs. // This is overridden in testing. virtual std::vector<content::FaviconURL> GetFaviconURLsFromWebContents(); diff --git a/chrome/browser/favicon/favicon_tab_helper_browsertest.cc b/chrome/browser/favicon/content_favicon_driver_browsertest.cc index 567d825..dbf2a8d 100644 --- a/chrome/browser/favicon/favicon_tab_helper_browsertest.cc +++ b/chrome/browser/favicon/content_favicon_driver_browsertest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/favicon/favicon_tab_helper.h" +#include "components/favicon/content/content_favicon_driver.h" #include "base/memory/weak_ptr.h" #include "base/run_loop.h" @@ -88,11 +88,11 @@ class TestResourceDispatcherHostDelegate DISALLOW_COPY_AND_ASSIGN(TestResourceDispatcherHostDelegate); }; -// Checks whether the FaviconTabHelper is waiting for a download to complete or +// Checks whether the FaviconDriver is waiting for a download to complete or // for data from the FaviconService. -class FaviconTabHelperPendingTaskChecker { +class FaviconDriverPendingTaskChecker { public: - virtual ~FaviconTabHelperPendingTaskChecker() {} + virtual ~FaviconDriverPendingTaskChecker() {} virtual bool HasPendingTasks() = 0; }; @@ -105,7 +105,7 @@ class PendingTaskWaiter : public content::NotificationObserver, public favicon::FaviconDriverObserver { public: PendingTaskWaiter(content::WebContents* web_contents, - FaviconTabHelperPendingTaskChecker* checker) + FaviconDriverPendingTaskChecker* checker) : checker_(checker), load_stopped_(false), scoped_observer_(this), @@ -113,7 +113,8 @@ class PendingTaskWaiter : public content::NotificationObserver, registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, content::Source<content::NavigationController>( &web_contents->GetController())); - scoped_observer_.Add(FaviconTabHelper::FromWebContents(web_contents)); + scoped_observer_.Add( + favicon::ContentFaviconDriver::FromWebContents(web_contents)); } ~PendingTaskWaiter() override {} @@ -163,11 +164,11 @@ class PendingTaskWaiter : public content::NotificationObserver, } } - FaviconTabHelperPendingTaskChecker* checker_; // Not owned. + FaviconDriverPendingTaskChecker* checker_; // Not owned. bool load_stopped_; base::Closure quit_closure_; content::NotificationRegistrar registrar_; - ScopedObserver<FaviconTabHelper, PendingTaskWaiter> scoped_observer_; + ScopedObserver<favicon::FaviconDriver, PendingTaskWaiter> scoped_observer_; base::WeakPtrFactory<PendingTaskWaiter> weak_factory_; DISALLOW_COPY_AND_ASSIGN(PendingTaskWaiter); @@ -175,30 +176,30 @@ class PendingTaskWaiter : public content::NotificationObserver, } // namespace -class FaviconTabHelperTest : public InProcessBrowserTest, - public FaviconTabHelperPendingTaskChecker { +class ContentFaviconDriverTest : public InProcessBrowserTest, + public FaviconDriverPendingTaskChecker { public: - FaviconTabHelperTest() {} - ~FaviconTabHelperTest() override {} + ContentFaviconDriverTest() {} + ~ContentFaviconDriverTest() override {} content::WebContents* web_contents() { return browser()->tab_strip_model()->GetActiveWebContents(); } - // FaviconTabHelperPendingTaskChecker: + // FaviconDriverPendingTaskChecker: bool HasPendingTasks() override { - return FaviconTabHelper::FromWebContents(web_contents()) + return favicon::ContentFaviconDriver::FromWebContents(web_contents()) ->HasPendingTasksForTest(); } private: - DISALLOW_COPY_AND_ASSIGN(FaviconTabHelperTest); + DISALLOW_COPY_AND_ASSIGN(ContentFaviconDriverTest); }; // Test that when a user reloads a page ignoring the cache that the favicon is // is redownloaded and (not returned from either the favicon cache or the HTTP // cache). -IN_PROC_BROWSER_TEST_F(FaviconTabHelperTest, ReloadIgnoringCache) { +IN_PROC_BROWSER_TEST_F(ContentFaviconDriverTest, ReloadIgnoringCache) { ASSERT_TRUE(test_server()->Start()); GURL url = test_server()->GetURL("files/favicon/page_with_favicon.html"); GURL icon_url = test_server()->GetURL("files/favicon/icon.ico"); diff --git a/chrome/browser/favicon/favicon_helper.cc b/chrome/browser/favicon/favicon_helper.cc new file mode 100644 index 0000000..214c28b --- /dev/null +++ b/chrome/browser/favicon/favicon_helper.cc @@ -0,0 +1,54 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/favicon/favicon_helper.h" + +#include "chrome/browser/bookmarks/bookmark_model_factory.h" +#include "chrome/browser/favicon/favicon_service_factory.h" +#include "chrome/browser/history/history_service_factory.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/search/search.h" +#include "chrome/common/url_constants.h" +#include "content/public/common/favicon_url.h" + +namespace favicon { + +void CreateContentFaviconDriverForWebContents( + content::WebContents* web_contents) { + DCHECK(web_contents); + if (ContentFaviconDriver::FromWebContents(web_contents)) + return; + + Profile* original_profile = + Profile::FromBrowserContext(web_contents->GetBrowserContext()) + ->GetOriginalProfile(); + return ContentFaviconDriver::CreateForWebContents( + web_contents, FaviconServiceFactory::GetForProfile( + original_profile, ServiceAccessType::IMPLICIT_ACCESS), + HistoryServiceFactory::GetForProfile(original_profile, + ServiceAccessType::IMPLICIT_ACCESS), + BookmarkModelFactory::GetForProfileIfExists(original_profile)); +} + +bool ShouldDisplayFavicon(content::WebContents* web_contents) { + // Always display a throbber during pending loads. + const content::NavigationController& controller = + web_contents->GetController(); + if (controller.GetLastCommittedEntry() && controller.GetPendingEntry()) + return true; + + GURL url = web_contents->GetURL(); + if (url.SchemeIs(content::kChromeUIScheme) && + url.host() == chrome::kChromeUINewTabHost) { + return false; + } + + // No favicon on Instant New Tab Pages. + if (chrome::IsInstantNTP(web_contents)) + return false; + + return true; +} + +} // namespace favicon diff --git a/chrome/browser/favicon/favicon_helper.h b/chrome/browser/favicon/favicon_helper.h new file mode 100644 index 0000000..9b9af36 --- /dev/null +++ b/chrome/browser/favicon/favicon_helper.h @@ -0,0 +1,26 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_FAVICON_FAVICON_HELPER_H_ +#define CHROME_BROWSER_FAVICON_FAVICON_HELPER_H_ + +#include "components/favicon/content/content_favicon_driver.h" + +namespace favicon { + +// Creates a ContentFaviconDriver and associates it with |web_contents| if none +// exists yet. +// +// This is a helper method for ContentFaviconDriver::CreateForWebContents() that +// gets KeyedService factories from the Profile linked to web_contents. +void CreateContentFaviconDriverForWebContents( + content::WebContents* web_contents); + +// Returns whether the favicon should be displayed. If this returns false, no +// space is provided for the favicon, and the favicon is never displayed. +bool ShouldDisplayFavicon(content::WebContents* web_contents); + +} // namespace favicon + +#endif // CHROME_BROWSER_FAVICON_FAVICON_HELPER_H_ diff --git a/chrome/browser/favicon/favicon_tab_helper.cc b/chrome/browser/favicon/favicon_tab_helper.cc deleted file mode 100644 index 177e7ba..0000000 --- a/chrome/browser/favicon/favicon_tab_helper.cc +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/favicon/favicon_tab_helper.h" - -#include "chrome/browser/bookmarks/bookmark_model_factory.h" -#include "chrome/browser/favicon/favicon_service_factory.h" -#include "chrome/browser/history/history_service_factory.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/search/search.h" -#include "chrome/common/url_constants.h" -#include "content/public/common/favicon_url.h" - -// static -void FaviconTabHelper::CreateForWebContents( - content::WebContents* web_contents) { - DCHECK(web_contents); - if (FromWebContents(web_contents)) - return; - - Profile* original_profile = - Profile::FromBrowserContext(web_contents->GetBrowserContext()) - ->GetOriginalProfile(); - web_contents->SetUserData( - UserDataKey(), - new FaviconTabHelper( - web_contents, - FaviconServiceFactory::GetForProfile( - original_profile, ServiceAccessType::IMPLICIT_ACCESS), - HistoryServiceFactory::GetForProfile( - original_profile, ServiceAccessType::IMPLICIT_ACCESS), - BookmarkModelFactory::GetForProfileIfExists(original_profile))); -} - -// static -FaviconTabHelper* FaviconTabHelper::FromWebContents( - content::WebContents* web_contents) { - return static_cast<FaviconTabHelper*>( - favicon::ContentFaviconDriver::FromWebContents(web_contents)); -} - -// static -bool FaviconTabHelper::ShouldDisplayFavicon( - content::WebContents* web_contents) { - // Always display a throbber during pending loads. - const content::NavigationController& controller = - web_contents->GetController(); - if (controller.GetLastCommittedEntry() && controller.GetPendingEntry()) - return true; - - GURL url = web_contents->GetURL(); - if (url.SchemeIs(content::kChromeUIScheme) && - url.host() == chrome::kChromeUINewTabHost) { - return false; - } - - // No favicon on Instant New Tab Pages. - if (chrome::IsInstantNTP(web_contents)) - return false; - - return true; -} - -FaviconTabHelper::FaviconTabHelper(content::WebContents* web_contents, - favicon::FaviconService* favicon_service, - history::HistoryService* history_service, - bookmarks::BookmarkModel* bookmark_model) - : favicon::ContentFaviconDriver(web_contents, - favicon_service, - history_service, - bookmark_model) { -} diff --git a/chrome/browser/favicon/favicon_tab_helper.h b/chrome/browser/favicon/favicon_tab_helper.h deleted file mode 100644 index e907090..0000000 --- a/chrome/browser/favicon/favicon_tab_helper.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ -#define CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ - -#include "base/macros.h" -#include "components/favicon/content/content_favicon_driver.h" - -// FaviconTabHelper provides helper factory for ContentFaviconDriver. -class FaviconTabHelper : public favicon::ContentFaviconDriver { - public: - static void CreateForWebContents(content::WebContents* web_contents); - - // TODO(sdefresne): remove this method once all clients have been ported to - // use ContentFaviconDriver::FromWebContents() instead. - static FaviconTabHelper* FromWebContents(content::WebContents* web_contents); - - // Returns whether the favicon should be displayed. If this returns false, no - // space is provided for the favicon, and the favicon is never displayed. - static bool ShouldDisplayFavicon(content::WebContents* web_contents); - - private: - friend class FaviconTabHelperTest; - - // Creates a new FaviconTabHelper bound to |web_contents|. Initialize - // |favicon_service_|, |bookmark_model_| and |history_service_| from the - // corresponding parameter. - FaviconTabHelper(content::WebContents* web_contents, - favicon::FaviconService* favicon_service, - history::HistoryService* history_service, - bookmarks::BookmarkModel* bookmark_model); - - DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); -}; - -#endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ diff --git a/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc b/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc index aa94ea7..969df5f 100644 --- a/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc +++ b/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc @@ -6,7 +6,7 @@ #include "chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h" #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" +#include "chrome/browser/favicon/favicon_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" #include "chrome/browser/ui/pdf/chrome_pdf_web_contents_helper_client.h" @@ -87,7 +87,7 @@ bool ChromeWebViewGuestDelegate::HandleContextMenu( // extension module in the future. void ChromeWebViewGuestDelegate::OnAttachWebViewHelpers( content::WebContents* contents) { - FaviconTabHelper::CreateForWebContents(contents); + favicon::CreateContentFaviconDriverForWebContents(contents); ChromeExtensionWebContentsObserver::CreateForWebContents(contents); #if defined(ENABLE_PRINTING) #if defined(ENABLE_PRINT_PREVIEW) diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc index f2e31de..dd7b852 100644 --- a/chrome/browser/prerender/prerender_browsertest.cc +++ b/chrome/browser/prerender/prerender_browsertest.cc @@ -30,7 +30,6 @@ #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/external_protocol/external_protocol_handler.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/net/prediction_options.h" #include "chrome/browser/predictors/autocomplete_action_predictor.h" #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" @@ -68,6 +67,7 @@ #include "chrome/test/base/test_switches.h" #include "chrome/test/base/ui_test_utils.h" #include "components/content_settings/core/browser/host_content_settings_map.h" +#include "components/favicon/content/content_favicon_driver.h" #include "components/favicon/core/favicon_driver_observer.h" #include "components/variations/entropy_provider.h" #include "components/variations/variations_associated_data.h" @@ -138,7 +138,8 @@ class FaviconUpdateWatcher : public favicon::FaviconDriverObserver { public: explicit FaviconUpdateWatcher(content::WebContents* web_contents) : seen_(false), running_(false), scoped_observer_(this) { - scoped_observer_.Add(FaviconTabHelper::FromWebContents(web_contents)); + scoped_observer_.Add( + favicon::ContentFaviconDriver::FromWebContents(web_contents)); } void Wait() { @@ -164,7 +165,7 @@ class FaviconUpdateWatcher : public favicon::FaviconDriverObserver { bool seen_; bool running_; - ScopedObserver<FaviconTabHelper, FaviconUpdateWatcher> scoped_observer_; + ScopedObserver<favicon::FaviconDriver, FaviconUpdateWatcher> scoped_observer_; scoped_refptr<content::MessageLoopRunner> message_loop_runner_; DISALLOW_COPY_AND_ASSIGN(FaviconUpdateWatcher); @@ -3182,14 +3183,14 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderFavicon) { 1); NavigateToDestURL(); - if (!FaviconTabHelper::FromWebContents( - GetActiveWebContents())->FaviconIsValid()) { + favicon::FaviconDriver* favicon_driver = + favicon::ContentFaviconDriver::FromWebContents(GetActiveWebContents()); + if (!favicon_driver->FaviconIsValid()) { // If the favicon has not been set yet, wait for it to be. FaviconUpdateWatcher favicon_update_watcher(GetActiveWebContents()); favicon_update_watcher.Wait(); } - EXPECT_TRUE(FaviconTabHelper::FromWebContents( - GetActiveWebContents())->FaviconIsValid()); + EXPECT_TRUE(favicon_driver->FaviconIsValid()); } // Checks that when a prerendered page is swapped in to a referring page, the diff --git a/chrome/browser/task_manager/guest_information.cc b/chrome/browser/task_manager/guest_information.cc index 0c7f7e1..fdfa035 100644 --- a/chrome/browser/task_manager/guest_information.cc +++ b/chrome/browser/task_manager/guest_information.cc @@ -6,13 +6,13 @@ #include "base/strings/string16.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/task_manager/renderer_resource.h" #include "chrome/browser/task_manager/resource_provider.h" #include "chrome/browser/task_manager/task_manager.h" #include "chrome/browser/task_manager/task_manager_util.h" #include "chrome/grit/generated_resources.h" +#include "components/favicon/content/content_favicon_driver.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" @@ -77,9 +77,11 @@ base::string16 GuestResource::GetTitle() const { gfx::ImageSkia GuestResource::GetIcon() const { WebContents* web_contents = GetWebContents(); - if (web_contents && FaviconTabHelper::FromWebContents(web_contents)) { - return FaviconTabHelper::FromWebContents(web_contents)-> - GetFavicon().AsImageSkia(); + if (web_contents) { + favicon::FaviconDriver* favicon_driver = + favicon::ContentFaviconDriver::FromWebContents(web_contents); + if (favicon_driver) + return favicon_driver->GetFavicon().AsImageSkia(); } return gfx::ImageSkia(); } diff --git a/chrome/browser/task_manager/printing_information.cc b/chrome/browser/task_manager/printing_information.cc index b623d18..4f9d6f1 100644 --- a/chrome/browser/task_manager/printing_information.cc +++ b/chrome/browser/task_manager/printing_information.cc @@ -7,7 +7,7 @@ #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" +#include "chrome/browser/favicon/favicon_helper.h" #include "chrome/browser/printing/background_printing_manager.h" #include "chrome/browser/printing/print_preview_dialog_controller.h" #include "chrome/browser/profiles/profile.h" @@ -16,6 +16,7 @@ #include "chrome/browser/task_manager/task_manager.h" #include "chrome/browser/task_manager/task_manager_util.h" #include "chrome/grit/generated_resources.h" +#include "components/favicon/content/content_favicon_driver.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" @@ -60,9 +61,10 @@ base::string16 PrintingResource::GetTitle() const { } gfx::ImageSkia PrintingResource::GetIcon() const { - FaviconTabHelper::CreateForWebContents(web_contents_); - return FaviconTabHelper::FromWebContents(web_contents_)-> - GetFavicon().AsImageSkia(); + favicon::CreateContentFaviconDriverForWebContents(web_contents_); + return favicon::ContentFaviconDriver::FromWebContents(web_contents_) + ->GetFavicon() + .AsImageSkia(); } WebContents* PrintingResource::GetWebContents() const { return web_contents_; } diff --git a/chrome/browser/task_manager/tab_contents_information.cc b/chrome/browser/task_manager/tab_contents_information.cc index 6087631..c810e91 100644 --- a/chrome/browser/task_manager/tab_contents_information.cc +++ b/chrome/browser/task_manager/tab_contents_information.cc @@ -8,7 +8,7 @@ #include "base/strings/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/devtools/devtools_window.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" +#include "chrome/browser/favicon/favicon_helper.h" #include "chrome/browser/prerender/prerender_manager.h" #include "chrome/browser/prerender/prerender_manager_factory.h" #include "chrome/browser/profiles/profile.h" @@ -19,6 +19,7 @@ #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_iterator.h" #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" +#include "components/favicon/content/content_favicon_driver.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents.h" #include "extensions/browser/extension_registry.h" @@ -123,9 +124,10 @@ base::string16 TabContentsResource::GetTitle() const { gfx::ImageSkia TabContentsResource::GetIcon() const { if (IsContentsPrerendering(web_contents_)) return *prerender_icon_; - FaviconTabHelper::CreateForWebContents(web_contents_); - return FaviconTabHelper::FromWebContents(web_contents_)-> - GetFavicon().AsImageSkia(); + favicon::CreateContentFaviconDriverForWebContents(web_contents_); + return favicon::ContentFaviconDriver::FromWebContents(web_contents_) + ->GetFavicon() + .AsImageSkia(); } WebContents* TabContentsResource::GetWebContents() const { diff --git a/chrome/browser/ui/apps/chrome_app_delegate.cc b/chrome/browser/ui/apps/chrome_app_delegate.cc index 7421867..1103dd0 100644 --- a/chrome/browser/ui/apps/chrome_app_delegate.cc +++ b/chrome/browser/ui/apps/chrome_app_delegate.cc @@ -10,7 +10,7 @@ #include "chrome/browser/apps/scoped_keep_alive.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" +#include "chrome/browser/favicon/favicon_helper.h" #include "chrome/browser/file_select_helper.h" #include "chrome/browser/media/media_capture_devices_dispatcher.h" #include "chrome/browser/platform_util.h" @@ -185,7 +185,7 @@ void ChromeAppDelegate::DisableExternalOpenForTesting() { } void ChromeAppDelegate::InitWebContents(content::WebContents* web_contents) { - FaviconTabHelper::CreateForWebContents(web_contents); + favicon::CreateContentFaviconDriverForWebContents(web_contents); #if defined(ENABLE_PRINTING) #if defined(ENABLE_PRINT_PREVIEW) diff --git a/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc index d4e9a54..0f7c3cb 100644 --- a/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc +++ b/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc @@ -8,13 +8,13 @@ #include "ash/wm/window_state.h" #include "ash/wm/window_util.h" #include "chrome/browser/extensions/webstore_install_with_prompt.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" +#include "components/favicon/content/content_favicon_driver.h" #include "content/public/browser/web_contents.h" #include "extensions/browser/app_window/app_window.h" #include "extensions/browser/app_window/native_app_window.h" @@ -204,9 +204,10 @@ ChromeLauncherAppMenuItems AppWindowLauncherItemController::GetApplicationList( // If the app's web contents provides a favicon, use it. Otherwise, use a // scaled down app icon. - FaviconTabHelper* favicon_tab_helper = - FaviconTabHelper::FromWebContents(app_window->web_contents()); - gfx::Image result = favicon_tab_helper->GetFavicon(); + favicon::FaviconDriver* favicon_driver = + favicon::ContentFaviconDriver::FromWebContents( + app_window->web_contents()); + gfx::Image result = favicon_driver->GetFavicon(); if (result.IsEmpty()) result = GetAppListIcon(app_window); diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc index b036635..8669b59 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc @@ -30,7 +30,6 @@ #include "chrome/browser/extensions/app_icon_loader_impl.h" #include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/extensions/launch_util.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/prefs/incognito_mode_prefs.h" #include "chrome/browser/prefs/pref_service_syncable.h" #include "chrome/browser/profiles/profile.h" @@ -67,6 +66,7 @@ #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "chrome/grit/generated_resources.h" +#include "components/favicon/content/content_favicon_driver.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_service.h" @@ -1364,9 +1364,9 @@ gfx::Image ChromeLauncherController::GetAppListIcon( ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); if (IsIncognito(web_contents)) return rb.GetImageNamed(IDR_ASH_SHELF_LIST_INCOGNITO_BROWSER); - FaviconTabHelper* favicon_tab_helper = - FaviconTabHelper::FromWebContents(web_contents); - gfx::Image result = favicon_tab_helper->GetFavicon(); + favicon::FaviconDriver* favicon_driver = + favicon::ContentFaviconDriver::FromWebContents(web_contents); + gfx::Image result = favicon_driver->GetFavicon(); if (result.IsEmpty()) return rb.GetImageNamed(IDR_DEFAULT_FAVICON); return result; diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 756aa02..8ba7764 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -58,7 +58,6 @@ #include "chrome/browser/extensions/extension_ui_util.h" #include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/extensions/tab_helper.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/file_select_helper.h" #include "chrome/browser/first_run/first_run.h" #include "chrome/browser/history/top_sites_factory.h" @@ -155,6 +154,7 @@ #include "components/bookmarks/browser/bookmark_model.h" #include "components/bookmarks/browser/bookmark_utils.h" #include "components/content_settings/core/browser/host_content_settings_map.h" +#include "components/favicon/content/content_favicon_driver.h" #include "components/history/core/browser/top_sites.h" #include "components/infobars/core/simple_alert_infobar_delegate.h" #include "components/search/search.h" @@ -584,9 +584,11 @@ gfx::Image Browser::GetCurrentPageIcon() const { WebContents* web_contents = tab_strip_model_->GetActiveWebContents(); // |web_contents| can be NULL since GetCurrentPageIcon() is called by the // window during the window's creation (before tabs have been added). - FaviconTabHelper* favicon_tab_helper = - web_contents ? FaviconTabHelper::FromWebContents(web_contents) : NULL; - return favicon_tab_helper ? favicon_tab_helper->GetFavicon() : gfx::Image(); + favicon::FaviconDriver* favicon_driver = + web_contents + ? favicon::ContentFaviconDriver::FromWebContents(web_contents) + : nullptr; + return favicon_driver ? favicon_driver->GetFavicon() : gfx::Image(); } base::string16 Browser::GetWindowTitleForCurrentTab() const { diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc index 1d80b76..cd20a11 100644 --- a/chrome/browser/ui/browser_commands.cc +++ b/chrome/browser/ui/browser_commands.cc @@ -16,7 +16,6 @@ #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/devtools/devtools_window.h" #include "chrome/browser/dom_distiller/tab_utils.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/prefs/incognito_mode_prefs.h" @@ -58,6 +57,7 @@ #include "chrome/common/pref_names.h" #include "components/bookmarks/browser/bookmark_model.h" #include "components/bookmarks/browser/bookmark_utils.h" +#include "components/favicon/content/content_favicon_driver.h" #include "components/google/core/browser/google_util.h" #include "components/translate/core/browser/language_state.h" #include "components/ui/zoom/page_zoom.h" @@ -732,7 +732,7 @@ void BookmarkCurrentPageIgnoringExtensionOverrides(Browser* browser) { web_contents->GetBrowserContext()->IsOffTheRecord()) { // If we're incognito the favicon may not have been saved. Save it now // so that bookmarks have an icon for the page. - FaviconTabHelper::FromWebContents(web_contents)->SaveFavicon(); + favicon::ContentFaviconDriver::FromWebContents(web_contents)->SaveFavicon(); } bool was_bookmarked_by_user = bookmarks::IsBookmarkedByUser(model, url); bookmarks::AddIfNotBookmarked(model, url, title); diff --git a/chrome/browser/ui/cocoa/hung_renderer_controller.mm b/chrome/browser/ui/cocoa/hung_renderer_controller.mm index a72eeca..a3c5b90 100644 --- a/chrome/browser/ui/cocoa/hung_renderer_controller.mm +++ b/chrome/browser/ui/cocoa/hung_renderer_controller.mm @@ -9,7 +9,6 @@ #include "base/mac/bundle_locations.h" #include "base/process/process.h" #include "base/strings/sys_string_conversions.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #import "chrome/browser/ui/cocoa/multi_key_equivalent_button.h" #import "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h" #include "chrome/browser/ui/tab_contents/core_tab_helper.h" diff --git a/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm b/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm index 5a6f0f1..6678f33 100644 --- a/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm +++ b/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm @@ -5,7 +5,6 @@ #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" #include "base/strings/sys_string_conversions.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/search/search.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" @@ -14,6 +13,7 @@ #import "chrome/browser/ui/cocoa/drag_util.h" #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" #include "chrome/grit/generated_resources.h" +#include "components/favicon/content/content_favicon_driver.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/web_contents.h" @@ -69,7 +69,9 @@ NSPasteboard* LocationIconDecoration::GetDragPasteboard() { NSImage* LocationIconDecoration::GetDragImage() { content::WebContents* web_contents = owner_->GetWebContents(); NSImage* favicon = - FaviconTabHelper::FromWebContents(web_contents)->GetFavicon().AsNSImage(); + favicon::ContentFaviconDriver::FromWebContents(web_contents) + ->GetFavicon() + .AsNSImage(); NSImage* iconImage = favicon ? favicon : GetImage(); NSImage* image = diff --git a/chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm b/chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm index b4fe508..d713b62 100644 --- a/chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm +++ b/chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm @@ -4,18 +4,18 @@ #include "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" +#include "components/favicon/content/content_favicon_driver.h" #include "ui/base/resource/resource_bundle.h" #include "ui/resources/grit/ui_resources.h" namespace mac { NSImage* FaviconForWebContents(content::WebContents* contents) { - FaviconTabHelper* favicon_tab_helper = - contents ? FaviconTabHelper::FromWebContents(contents) - : NULL; - if (favicon_tab_helper && favicon_tab_helper->FaviconIsValid()) { - NSImage* image = favicon_tab_helper->GetFavicon().AsNSImage(); + favicon::FaviconDriver* favicon_driver = + contents ? favicon::ContentFaviconDriver::FromWebContents(contents) + : nullptr; + if (favicon_driver && favicon_driver->FaviconIsValid()) { + NSImage* image = favicon_driver->GetFavicon().AsNSImage(); // The |image| could be nil if the bitmap is null. In that case, fallback // to the default image. if (image) { diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm index 8dde6a25..b4a33f5 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm @@ -20,7 +20,7 @@ #include "chrome/browser/autocomplete/autocomplete_classifier.h" #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" #include "chrome/browser/extensions/tab_helper.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" +#include "chrome/browser/favicon/favicon_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/themes/theme_service.h" @@ -1555,7 +1555,8 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay, CGFloat alpha) { TabController* tabController = [tabArray_ objectAtIndex:index]; bool oldHasIcon = [tabController iconView] != nil; - bool newHasIcon = FaviconTabHelper::ShouldDisplayFavicon(contents) || + bool newHasIcon = + favicon::ShouldDisplayFavicon(contents) || tabStripModel_->IsMiniTab(modelIndex); // Always show icon if mini. TabLoadingState oldState = [tabController loadingState]; diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc index 8b37d7d..eead7fa 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc @@ -13,7 +13,6 @@ #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/media/media_capture_devices_dispatcher.h" #include "chrome/browser/plugins/chrome_plugin_service_filter.h" diff --git a/chrome/browser/ui/metro_pin_tab_helper_win.cc b/chrome/browser/ui/metro_pin_tab_helper_win.cc index 202c39b..6564571 100644 --- a/chrome/browser/ui/metro_pin_tab_helper_win.cc +++ b/chrome/browser/ui/metro_pin_tab_helper_win.cc @@ -18,8 +18,8 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "base/win/metro.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/common/chrome_paths.h" +#include "components/favicon/content/content_favicon_driver.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" #include "crypto/sha2.h" @@ -375,12 +375,14 @@ void MetroPinTabHelper::TogglePinnedToStartScreen() { base::string16 title = web_contents()->GetTitle(); // TODO(oshima): Use scoped_ptr::Pass to pass it to other thread. SkBitmap favicon; - FaviconTabHelper* favicon_tab_helper = FaviconTabHelper::FromWebContents( - web_contents()); - if (favicon_tab_helper->FaviconIsValid()) { + favicon::FaviconDriver* favicon_driver = + favicon::ContentFaviconDriver::FromWebContents(web_contents()); + if (favicon_driver->FaviconIsValid()) { // Only the 1x bitmap data is needed. - favicon = favicon_tab_helper->GetFavicon().AsImageSkia().GetRepresentation( - 1.0f).sk_bitmap(); + favicon = favicon_driver->GetFavicon() + .AsImageSkia() + .GetRepresentation(1.0f) + .sk_bitmap(); } favicon_chooser_.reset(new FaviconChooser(this, title, url_str, favicon)); diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc index ecaf694..dcbdd8a 100644 --- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc +++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc @@ -26,7 +26,6 @@ #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/command_updater.h" #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/net/predictor.h" #include "chrome/browser/omnibox/omnibox_log.h" #include "chrome/browser/predictors/autocomplete_action_predictor.h" @@ -53,6 +52,7 @@ #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "components/bookmarks/browser/bookmark_model.h" +#include "components/favicon/content/content_favicon_driver.h" #include "components/metrics/proto/omnibox_event.pb.h" #include "components/omnibox/autocomplete_provider.h" #include "components/omnibox/keyword_provider.h" @@ -428,7 +428,8 @@ void OmniboxEditModel::GetDataForURLExport(GURL* url, if (*url == delegate_->GetURL()) { content::WebContents* web_contents = controller_->GetWebContents(); *title = web_contents->GetTitle(); - *favicon = FaviconTabHelper::FromWebContents(web_contents)->GetFavicon(); + *favicon = favicon::ContentFaviconDriver::FromWebContents(web_contents) + ->GetFavicon(); } } diff --git a/chrome/browser/ui/panels/panel_host.cc b/chrome/browser/ui/panels/panel_host.cc index 0f88321..8c70a68 100644 --- a/chrome/browser/ui/panels/panel_host.cc +++ b/chrome/browser/ui/panels/panel_host.cc @@ -10,12 +10,13 @@ #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" #include "chrome/browser/extensions/window_controller.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" +#include "chrome/browser/favicon/favicon_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/panels/panel.h" #include "chrome/browser/ui/prefs/prefs_tab_helper.h" +#include "components/favicon/content/content_favicon_driver.h" #include "components/ui/zoom/page_zoom.h" #include "components/ui/zoom/zoom_controller.h" #include "content/public/browser/invalidate_type.h" @@ -66,7 +67,7 @@ void PanelHost::Init(const GURL& url) { SessionTabHelper::FromWebContents(web_contents_.get())->SetWindowID( panel_->session_id()); - FaviconTabHelper::CreateForWebContents(web_contents_.get()); + favicon::CreateContentFaviconDriverForWebContents(web_contents_.get()); PrefsTabHelper::CreateForWebContents(web_contents_.get()); extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( web_contents_.get()); @@ -88,10 +89,10 @@ gfx::Image PanelHost::GetPageIcon() const { if (!web_contents_.get()) return gfx::Image(); - FaviconTabHelper* favicon_tab_helper = - FaviconTabHelper::FromWebContents(web_contents_.get()); - CHECK(favicon_tab_helper); - return favicon_tab_helper->GetFavicon(); + favicon::FaviconDriver* favicon_driver = + favicon::ContentFaviconDriver::FromWebContents(web_contents_.get()); + CHECK(favicon_driver); + return favicon_driver->GetFavicon(); } content::WebContents* PanelHost::OpenURLFromTab( diff --git a/chrome/browser/ui/panels/panel_host.h b/chrome/browser/ui/panels/panel_host.h index 7fc115a..91634b8 100644 --- a/chrome/browser/ui/panels/panel_host.h +++ b/chrome/browser/ui/panels/panel_host.h @@ -12,7 +12,6 @@ #include "content/public/common/page_zoom.h" #include "extensions/browser/extension_function_dispatcher.h" -class FaviconTabHelper; class GURL; class Panel; class PrefsTabHelper; diff --git a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc index 7169a81..716c1b3 100644 --- a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc +++ b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc @@ -20,7 +20,6 @@ #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search/instant_service.h" diff --git a/chrome/browser/ui/tab_helpers.cc b/chrome/browser/ui/tab_helpers.cc index 5f7eb24..df974a9 100644 --- a/chrome/browser/ui/tab_helpers.cc +++ b/chrome/browser/ui/tab_helpers.cc @@ -8,7 +8,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/content_settings/chrome_content_settings_client.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" +#include "chrome/browser/favicon/favicon_helper.h" #include "chrome/browser/history/history_tab_helper.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/net/net_error_tab_helper.h" @@ -141,7 +141,7 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) { autofill::ChromeAutofillClient::FromWebContents(web_contents)); ChromeTranslateClient::CreateForWebContents(web_contents); CoreTabHelper::CreateForWebContents(web_contents); - FaviconTabHelper::CreateForWebContents(web_contents); + favicon::CreateContentFaviconDriverForWebContents(web_contents); FindTabHelper::CreateForWebContents(web_contents); HistoryTabHelper::CreateForWebContents(web_contents); InfoBarService::CreateForWebContents(web_contents); diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc index f372315..e242729 100644 --- a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc +++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc @@ -7,11 +7,11 @@ #include "apps/ui/views/app_window_frame_view.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/app_mode/app_mode_utils.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/views/apps/desktop_keyboard_capture.h" #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views.h" #include "chrome/browser/ui/views/frame/taskbar_decorator.h" +#include "components/favicon/content/content_favicon_driver.h" #include "components/ui/zoom/page_zoom.h" #include "components/ui/zoom/zoom_controller.h" #include "ui/views/controls/webview/webview.h" @@ -263,9 +263,9 @@ gfx::ImageSkia ChromeNativeAppWindowViews::GetWindowAppIcon() { gfx::ImageSkia ChromeNativeAppWindowViews::GetWindowIcon() { content::WebContents* web_contents = app_window()->web_contents(); if (web_contents) { - FaviconTabHelper* favicon_tab_helper = - FaviconTabHelper::FromWebContents(web_contents); - gfx::Image app_icon = favicon_tab_helper->GetFavicon(); + favicon::FaviconDriver* favicon_driver = + favicon::ContentFaviconDriver::FromWebContents(web_contents); + gfx::Image app_icon = favicon_driver->GetFavicon(); if (!app_icon.IsEmpty()) return *app_icon.ToImageSkia(); } diff --git a/chrome/browser/ui/views/hung_renderer_view.cc b/chrome/browser/ui/views/hung_renderer_view.cc index 6645a24..d91aa29 100644 --- a/chrome/browser/ui/views/hung_renderer_view.cc +++ b/chrome/browser/ui/views/hung_renderer_view.cc @@ -7,7 +7,6 @@ #include "base/i18n/rtl.h" #include "base/memory/scoped_vector.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h" @@ -17,6 +16,7 @@ #include "chrome/common/logging_chrome.h" #include "chrome/grit/generated_resources.h" #include "components/constrained_window/constrained_window_views.h" +#include "components/favicon/content/content_favicon_driver.h" #include "components/web_modal/web_contents_modal_dialog_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" @@ -111,8 +111,10 @@ base::string16 HungPagesTableModel::GetText(int row, int column_id) { gfx::ImageSkia HungPagesTableModel::GetIcon(int row) { DCHECK(row >= 0 && row < RowCount()); - return FaviconTabHelper::FromWebContents( - tab_observers_[row]->web_contents())->GetFavicon().AsImageSkia(); + return favicon::ContentFaviconDriver::FromWebContents( + tab_observers_[row]->web_contents()) + ->GetFavicon() + .AsImageSkia(); } void HungPagesTableModel::SetObserver(ui::TableModelObserver* observer) { diff --git a/chrome/browser/ui/views/hung_renderer_view.h b/chrome/browser/ui/views/hung_renderer_view.h index 162f669..d178aaf 100644 --- a/chrome/browser/ui/views/hung_renderer_view.h +++ b/chrome/browser/ui/views/hung_renderer_view.h @@ -6,7 +6,7 @@ #define CHROME_BROWSER_UI_VIEWS_HUNG_RENDERER_VIEW_H_ #include "base/memory/scoped_vector.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" +#include "components/favicon/content/content_favicon_driver.h" #include "content/public/browser/web_contents_observer.h" #include "ui/base/models/table_model.h" #include "ui/views/controls/button/button.h" @@ -64,8 +64,8 @@ class HungPagesTableModel : public ui::TableModel, public views::TableGrouper { WebContentsObserverImpl(HungPagesTableModel* model, content::WebContents* tab); - FaviconTabHelper* favicon_tab_helper() { - return FaviconTabHelper::FromWebContents(web_contents()); + favicon::FaviconDriver* favicon_driver() { + return favicon::ContentFaviconDriver::FromWebContents(web_contents()); } // WebContentsObserver overrides: diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index 52f7afb..9a8e18a 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -20,7 +20,6 @@ #include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/extensions/location_bar_controller.h" #include "chrome/browser/extensions/tab_helper.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search/instant_service.h" #include "chrome/browser/search/instant_service_factory.h" @@ -58,6 +57,7 @@ #include "chrome/browser/ui/views/translate/translate_bubble_view.h" #include "chrome/common/pref_names.h" #include "chrome/grit/generated_resources.h" +#include "components/favicon/content/content_favicon_driver.h" #include "components/search_engines/template_url.h" #include "components/search_engines/template_url_service.h" #include "components/translate/core/browser/language_state.h" @@ -1275,9 +1275,9 @@ void LocationBarView::WriteDragDataForView(views::View* sender, ui::DragDropTypes::DRAG_NONE); WebContents* web_contents = GetWebContents(); - FaviconTabHelper* favicon_tab_helper = - FaviconTabHelper::FromWebContents(web_contents); - gfx::ImageSkia favicon = favicon_tab_helper->GetFavicon().AsImageSkia(); + favicon::FaviconDriver* favicon_driver = + favicon::ContentFaviconDriver::FromWebContents(web_contents); + gfx::ImageSkia favicon = favicon_driver->GetFavicon().AsImageSkia(); button_drag_utils::SetURLAndDragImage(web_contents->GetURL(), web_contents->GetTitle(), favicon, diff --git a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc index 23a17e9..61797eb 100644 --- a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc +++ b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc @@ -13,7 +13,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/tab_helper.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" +#include "chrome/browser/favicon/favicon_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search/search.h" #include "chrome/browser/ui/browser.h" @@ -28,6 +28,7 @@ #include "chrome/browser/ui/views/tabs/tab_strip.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" +#include "components/favicon/content/content_favicon_driver.h" #include "components/metrics/proto/omnibox_event.pb.h" #include "components/omnibox/autocomplete_match.h" #include "content/public/browser/browser_thread.h" @@ -498,10 +499,10 @@ void BrowserTabStripController::SetTabRendererDataFromModel( int model_index, TabRendererData* data, TabStatus tab_status) { - FaviconTabHelper* favicon_tab_helper = - FaviconTabHelper::FromWebContents(contents); + favicon::FaviconDriver* favicon_driver = + favicon::ContentFaviconDriver::FromWebContents(contents); - data->favicon = favicon_tab_helper->GetFavicon().AsImageSkia(); + data->favicon = favicon_driver->GetFavicon().AsImageSkia(); data->network_state = TabContentsNetworkState(contents); data->title = contents->GetTitle(); data->url = contents->GetURL(); @@ -509,8 +510,7 @@ void BrowserTabStripController::SetTabRendererDataFromModel( data->crashed_status = contents->GetCrashedStatus(); data->incognito = contents->GetBrowserContext()->IsOffTheRecord(); data->mini = model_->IsMiniTab(model_index); - data->show_icon = - data->mini || FaviconTabHelper::ShouldDisplayFavicon(contents); + data->show_icon = data->mini || favicon::ShouldDisplayFavicon(contents); data->blocked = model_->IsTabBlocked(model_index); data->app = extensions::TabHelper::FromWebContents(contents)->is_app(); data->media_state = chrome::GetTabMediaStateForContents(contents); diff --git a/chrome/browser/web_applications/update_shortcut_worker_win.cc b/chrome/browser/web_applications/update_shortcut_worker_win.cc index 528b60b..f6590b9 100644 --- a/chrome/browser/web_applications/update_shortcut_worker_win.cc +++ b/chrome/browser/web_applications/update_shortcut_worker_win.cc @@ -15,7 +15,6 @@ #include "base/win/windows_version.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/tab_helper.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/web_applications/web_app.h" #include "chrome/browser/web_applications/web_app_win.h" diff --git a/chrome/browser/web_applications/update_shortcut_worker_win.h b/chrome/browser/web_applications/update_shortcut_worker_win.h index 62fc6b7..825a3ea 100644 --- a/chrome/browser/web_applications/update_shortcut_worker_win.h +++ b/chrome/browser/web_applications/update_shortcut_worker_win.h @@ -35,7 +35,7 @@ class UpdateShortcutWorker : public content::NotificationObserver { const content::NotificationSource& source, const content::NotificationDetails& details); - // Downloads icon via the FaviconTabHelper. + // Downloads icon via the FaviconDriver. void DownloadIcon(); // Favicon download callback. diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc index 7522fa24..627d78f 100644 --- a/chrome/browser/web_applications/web_app.cc +++ b/chrome/browser/web_applications/web_app.cc @@ -44,7 +44,7 @@ #if defined(TOOLKIT_VIEWS) #include "chrome/browser/extensions/tab_helper.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" +#include "components/favicon/content/content_favicon_driver.h" #endif using content::BrowserThread; @@ -180,8 +180,8 @@ ShortcutLocations::ShortcutLocations() #if defined(TOOLKIT_VIEWS) scoped_ptr<ShortcutInfo> GetShortcutInfoForTab( content::WebContents* web_contents) { - const FaviconTabHelper* favicon_tab_helper = - FaviconTabHelper::FromWebContents(web_contents); + const favicon::FaviconDriver* favicon_driver = + favicon::ContentFaviconDriver::FromWebContents(web_contents); const extensions::TabHelper* extensions_tab_helper = extensions::TabHelper::FromWebContents(web_contents); const WebApplicationInfo& app_info = extensions_tab_helper->web_app_info(); @@ -194,7 +194,7 @@ scoped_ptr<ShortcutInfo> GetShortcutInfoForTab( web_contents->GetTitle()) : app_info.title; info->description = app_info.description; - info->favicon.Add(favicon_tab_helper->GetFavicon()); + info->favicon.Add(favicon_driver->GetFavicon()); Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); diff --git a/chrome/browser/web_applications/web_app_unittest.cc b/chrome/browser/web_applications/web_app_unittest.cc index f9cac1e..76276b6 100644 --- a/chrome/browser/web_applications/web_app_unittest.cc +++ b/chrome/browser/web_applications/web_app_unittest.cc @@ -16,7 +16,7 @@ #if defined(TOOLKIT_VIEWS) #include "chrome/browser/extensions/tab_helper.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" +#include "chrome/browser/favicon/favicon_helper.h" #endif using content::RenderViewHostTester; @@ -27,7 +27,7 @@ class WebApplicationTest : public ChromeRenderViewHostTestHarness { ChromeRenderViewHostTestHarness::SetUp(); #if defined(TOOLKIT_VIEWS) extensions::TabHelper::CreateForWebContents(web_contents()); - FaviconTabHelper::CreateForWebContents(web_contents()); + favicon::CreateContentFaviconDriverForWebContents(web_contents()); #endif } }; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index d88e182..bcd49c9 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1551,10 +1551,10 @@ 'browser/favicon/chrome_favicon_client_factory.h', 'browser/favicon/fallback_icon_service_factory.cc', 'browser/favicon/fallback_icon_service_factory.h', + 'browser/favicon/favicon_helper.cc', + 'browser/favicon/favicon_helper.h', 'browser/favicon/favicon_service_factory.cc', 'browser/favicon/favicon_service_factory.h', - 'browser/favicon/favicon_tab_helper.cc', - 'browser/favicon/favicon_tab_helper.h', ], 'chrome_browser_gnome_keyring_sources': [ 'browser/password_manager/native_backend_gnome_x.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 4a32316..1c6df5e 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -287,7 +287,7 @@ 'browser/extensions/window_open_apitest.cc', 'browser/external_extension_browsertest.cc', 'browser/fast_shutdown_browsertest.cc', - 'browser/favicon/favicon_tab_helper_browsertest.cc', + 'browser/favicon/content_favicon_driver_browsertest.cc', 'browser/first_run/first_run_browsertest.cc', 'browser/first_run/try_chrome_dialog_view_browsertest.cc', 'browser/geolocation/access_token_store_browsertest.cc', |