diff options
author | michaelbai@chromium.org <michaelbai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-05 07:11:58 +0000 |
---|---|---|
committer | michaelbai@chromium.org <michaelbai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-05 07:11:58 +0000 |
commit | f718290eb845a2c28943d682fa4a7b1a4b914941 (patch) | |
tree | 5dcb6097992652bbee1877bb116de2eda59b586e | |
parent | 9c85473aa0ac8d8017b2b8280240a14239915744 (diff) | |
download | chromium_src-f718290eb845a2c28943d682fa4a7b1a4b914941.zip chromium_src-f718290eb845a2c28943d682fa4a7b1a4b914941.tar.gz chromium_src-f718290eb845a2c28943d682fa4a7b1a4b914941.tar.bz2 |
Make FaviconService() use Profile as parameter
BUG=308153
Review URL: https://codereview.chromium.org/56143002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232939 0039d316-1c4b-4281-b951-d872f2087c98
23 files changed, 39 insertions, 45 deletions
diff --git a/chrome/browser/android/favicon_helper.cc b/chrome/browser/android/favicon_helper.cc index 3694b36..17a4660 100644 --- a/chrome/browser/android/favicon_helper.cc +++ b/chrome/browser/android/favicon_helper.cc @@ -90,7 +90,6 @@ jboolean FaviconHelper::GetLocalFaviconImageForURL( return false; FaviconService::FaviconForURLParams params( - profile, GURL(ConvertJavaStringToUTF16(env, j_page_url)), static_cast<int>(j_icon_types), static_cast<int>(j_desired_size_in_dip)); diff --git a/chrome/browser/android/provider/chrome_browser_provider.cc b/chrome/browser/android/provider/chrome_browser_provider.cc index 2f82c13..800effc 100644 --- a/chrome/browser/android/provider/chrome_browser_provider.cc +++ b/chrome/browser/android/provider/chrome_browser_provider.cc @@ -673,7 +673,6 @@ class BookmarkIconFetchTask : public FaviconServiceTask { base::Bind(&FaviconService::GetRawFaviconForURL, base::Unretained(service()), FaviconService::FaviconForURLParams( - profile(), url, chrome::FAVICON | chrome::TOUCH_ICON, gfx::kFaviconSize), diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc index 3565ef8..3096166 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer.cc @@ -463,7 +463,7 @@ bool BookmarkFaviconFetcher::FetchNextFavicon() { profile_, Profile::EXPLICIT_ACCESS); favicon_service->GetRawFaviconForURL( FaviconService::FaviconForURLParams( - profile_, GURL(url), chrome::FAVICON, gfx::kFaviconSize), + GURL(url), chrome::FAVICON, gfx::kFaviconSize), ui::SCALE_FACTOR_100P, base::Bind(&BookmarkFaviconFetcher::OnFaviconDataAvailable, base::Unretained(this)), diff --git a/chrome/browser/bookmarks/bookmark_model.cc b/chrome/browser/bookmarks/bookmark_model.cc index 9e4156e..c4c6b81 100644 --- a/chrome/browser/bookmarks/bookmark_model.cc +++ b/chrome/browser/bookmarks/bookmark_model.cc @@ -996,8 +996,7 @@ void BookmarkModel::LoadFavicon(BookmarkNode* node) { if (!favicon_service) return; FaviconService::Handle handle = favicon_service->GetFaviconImageForURL( - FaviconService::FaviconForURLParams(profile_, - node->url(), + FaviconService::FaviconForURLParams(node->url(), chrome::FAVICON, gfx::kFaviconSize), base::Bind(&BookmarkModel::OnFaviconDataAvailable, diff --git a/chrome/browser/favicon/favicon_handler.cc b/chrome/browser/favicon/favicon_handler.cc index 57575cf..3e817c6 100644 --- a/chrome/browser/favicon/favicon_handler.cc +++ b/chrome/browser/favicon/favicon_handler.cc @@ -473,8 +473,8 @@ void FaviconHandler::GetFaviconForURL( const FaviconService::FaviconResultsCallback& callback, CancelableTaskTracker* tracker) { GetFaviconService()->GetFaviconForURL( - FaviconService::FaviconForURLParams( - profile_, page_url, icon_types, preferred_icon_size()), + FaviconService::FaviconForURLParams(page_url, icon_types, + preferred_icon_size()), callback, tracker); } diff --git a/chrome/browser/favicon/favicon_handler_unittest.cc b/chrome/browser/favicon/favicon_handler_unittest.cc index 40d0255..08cc59a 100644 --- a/chrome/browser/favicon/favicon_handler_unittest.cc +++ b/chrome/browser/favicon/favicon_handler_unittest.cc @@ -5,6 +5,7 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/favicon/favicon_handler.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/test/base/chrome_render_view_host_test_harness.h" #include "content/public/browser/favicon_status.h" @@ -1069,7 +1070,12 @@ TEST_F(FaviconHandlerTest, MultipleFavicons) { static BrowserContextKeyedService* BuildFaviconService( content::BrowserContext* profile) { - return new FaviconService(NULL); + return new FaviconService(static_cast<Profile*>(profile)); +} + +static BrowserContextKeyedService* BuildHistoryService( + content::BrowserContext* profile) { + return NULL; } // Test that Favicon is not requested repeatedly during the same session if @@ -1083,6 +1089,10 @@ TEST_F(FaviconHandlerTest, UnableToDownloadFavicon) { FaviconServiceFactory::GetInstance()->SetTestingFactory( profile, BuildFaviconService); + + HistoryServiceFactory::GetInstance()->SetTestingFactory( + profile, BuildHistoryService); + FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( profile, Profile::IMPLICIT_ACCESS); diff --git a/chrome/browser/favicon/favicon_service.cc b/chrome/browser/favicon/favicon_service.cc index 9f0ff332..6b1d9f8 100644 --- a/chrome/browser/favicon/favicon_service.cc +++ b/chrome/browser/favicon/favicon_service.cc @@ -63,8 +63,10 @@ CancelableTaskTracker::TaskId GetFaviconForChromeURL( } // namespace -FaviconService::FaviconService(HistoryService* history_service) - : history_service_(history_service) { +FaviconService::FaviconService(Profile* profile) + : history_service_(HistoryServiceFactory::GetForProfile( + profile, Profile::EXPLICIT_ACCESS)), + profile_(profile) { } // static @@ -323,7 +325,7 @@ CancelableTaskTracker::TaskId FaviconService::GetFaviconForURLImpl( CancelableTaskTracker* tracker) { if (params.page_url.SchemeIs(chrome::kChromeUIScheme) || params.page_url.SchemeIs(extensions::kExtensionScheme)) { - return GetFaviconForChromeURL(params.profile, params.page_url, + return GetFaviconForChromeURL(profile_, params.page_url, desired_scale_factors, callback, tracker); } else if (history_service_) { return history_service_->GetFaviconsForURL(params.page_url, diff --git a/chrome/browser/favicon/favicon_service.h b/chrome/browser/favicon/favicon_service.h index ed1bc3d..8ec0846 100644 --- a/chrome/browser/favicon/favicon_service.h +++ b/chrome/browser/favicon/favicon_service.h @@ -34,22 +34,19 @@ struct FaviconImageResult; class FaviconService : public CancelableRequestProvider, public BrowserContextKeyedService { public: - explicit FaviconService(HistoryService* history_service); + explicit FaviconService(Profile* profile); virtual ~FaviconService(); // Auxiliary argument structure for requesting favicons for URLs. struct FaviconForURLParams { - FaviconForURLParams(Profile* profile, - const GURL& page_url, + FaviconForURLParams(const GURL& page_url, int icon_types, int desired_size_in_dip) - : profile(profile), - page_url(page_url), + : page_url(page_url), icon_types(icon_types), desired_size_in_dip(desired_size_in_dip) {} - Profile* profile; GURL page_url; int icon_types; int desired_size_in_dip; @@ -244,6 +241,7 @@ class FaviconService : public CancelableRequestProvider, typedef uint32 MissingFaviconURLHash; base::hash_set<MissingFaviconURLHash> missing_favicon_urls_; HistoryService* history_service_; + Profile* profile_; // Helper function for GetFaviconImageForURL(), GetRawFaviconForURL() and // GetFaviconForURL(). diff --git a/chrome/browser/favicon/favicon_service_factory.cc b/chrome/browser/favicon/favicon_service_factory.cc index fce9098..4a2ed7e 100644 --- a/chrome/browser/favicon/favicon_service_factory.cc +++ b/chrome/browser/favicon/favicon_service_factory.cc @@ -46,9 +46,7 @@ FaviconServiceFactory::~FaviconServiceFactory() {} BrowserContextKeyedService* FaviconServiceFactory::BuildServiceInstanceFor( content::BrowserContext* profile) const { - HistoryService* history_service = HistoryServiceFactory::GetForProfile( - static_cast<Profile*>(profile), Profile::EXPLICIT_ACCESS); - return new FaviconService(history_service); + return new FaviconService(static_cast<Profile*>(profile)); } bool FaviconServiceFactory::ServiceIsNULLWhileTesting() const { diff --git a/chrome/browser/history/android/sqlite_cursor_unittest.cc b/chrome/browser/history/android/sqlite_cursor_unittest.cc index ccca02a..46f0f00 100644 --- a/chrome/browser/history/android/sqlite_cursor_unittest.cc +++ b/chrome/browser/history/android/sqlite_cursor_unittest.cc @@ -195,7 +195,7 @@ TEST_F(SQLiteCursorTest, Run) { column_names.push_back(HistoryAndBookmarkRow::GetAndroidName( HistoryAndBookmarkRow::FAVICON)); - FaviconService* favicon_service = new FaviconService(hs_); + FaviconService* favicon_service = new FaviconService(testing_profile_); SQLiteCursor* cursor = new SQLiteCursor(column_names, statement, service_.get(), favicon_service); diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc index 4bd1160..c5436ea 100644 --- a/chrome/browser/jumplist_win.cc +++ b/chrome/browser/jumplist_win.cc @@ -684,8 +684,7 @@ void JumpList::StartLoadingFavicon() { FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); task_id_ = favicon_service->GetFaviconImageForURL( - FaviconService::FaviconForURLParams(profile_, - url, + FaviconService::FaviconForURLParams(url, chrome::FAVICON, gfx::kFaviconSize), base::Bind(&JumpList::OnFaviconDataAvailable, diff --git a/chrome/browser/notifications/message_center_settings_controller.cc b/chrome/browser/notifications/message_center_settings_controller.cc index 580b20b..e18061c 100644 --- a/chrome/browser/notifications/message_center_settings_controller.cc +++ b/chrome/browser/notifications/message_center_settings_controller.cc @@ -247,7 +247,6 @@ void MessageCenterSettingsController::GetNotifierList( notification_service->IsNotifierEnabled(notifier_id))); patterns_[name] = iter->primary_pattern; FaviconService::FaviconForURLParams favicon_params( - profile, url, chrome::FAVICON | chrome::TOUCH_ICON, message_center::kSettingsIconSize); diff --git a/chrome/browser/sync/glue/favicon_cache.cc b/chrome/browser/sync/glue/favicon_cache.cc index d6dcaa8..f250d9b 100644 --- a/chrome/browser/sync/glue/favicon_cache.cc +++ b/chrome/browser/sync/glue/favicon_cache.cc @@ -468,8 +468,8 @@ void FaviconCache::OnPageFaviconUpdated(const GURL& page_url) { // desired_size_in_dip). Figure out a way to fetch all favicons we support. // See crbug.com/181068. CancelableTaskTracker::TaskId id = favicon_service->GetFaviconForURL( - FaviconService::FaviconForURLParams( - profile_, page_url, SupportedFaviconTypes(), kMaxFaviconResolution), + FaviconService::FaviconForURLParams(page_url, SupportedFaviconTypes(), + kMaxFaviconResolution), base::Bind(&FaviconCache::OnFaviconDataAvailable, weak_ptr_factory_.GetWeakPtr(), page_url), &cancelable_task_tracker_); diff --git a/chrome/browser/ui/android/navigation_popup.cc b/chrome/browser/ui/android/navigation_popup.cc index 4033b31..fca009d 100644 --- a/chrome/browser/ui/android/navigation_popup.cc +++ b/chrome/browser/ui/android/navigation_popup.cc @@ -49,8 +49,7 @@ void NavigationPopup::FetchFaviconForUrl(JNIEnv* env, // TODO(tedchoc): Request higher favicons based on screen density instead of // hardcoding kFaviconSize. favicon_service->GetFaviconImageForURL( - FaviconService::FaviconForURLParams(profile, - url, + FaviconService::FaviconForURLParams(url, chrome::FAVICON, gfx::kFaviconSize), base::Bind(&NavigationPopup::OnFaviconDataAvailable, diff --git a/chrome/browser/ui/cocoa/history_menu_bridge.mm b/chrome/browser/ui/cocoa/history_menu_bridge.mm index a2cffbf..d206e8e 100644 --- a/chrome/browser/ui/cocoa/history_menu_bridge.mm +++ b/chrome/browser/ui/cocoa/history_menu_bridge.mm @@ -459,8 +459,7 @@ void HistoryMenuBridge::GetFaviconForHistoryItem(HistoryItem* item) { FaviconService* service = FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); CancelableTaskTracker::TaskId task_id = service->GetFaviconImageForURL( - FaviconService::FaviconForURLParams(profile_, - item->url, + FaviconService::FaviconForURLParams(item->url, chrome::FAVICON, gfx::kFaviconSize), base::Bind(&HistoryMenuBridge::GotFaviconData, diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model.cc b/chrome/browser/ui/toolbar/back_forward_menu_model.cc index 9f26f69..db4efe2 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model.cc +++ b/chrome/browser/ui/toolbar/back_forward_menu_model.cc @@ -255,8 +255,7 @@ void BackForwardMenuModel::FetchFavicon(NavigationEntry* entry) { return; favicon_service->GetFaviconImageForURL( - FaviconService::FaviconForURLParams(browser_->profile(), - entry->GetURL(), + FaviconService::FaviconForURLParams(entry->GetURL(), chrome::FAVICON, gfx::kFaviconSize), base::Bind(&BackForwardMenuModel::OnFavIconDataAvailable, diff --git a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc index 6f56a86..4049cc4 100644 --- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc +++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc @@ -609,8 +609,7 @@ void RecentTabsSubMenuModel::AddTabFavicon(int command_id, const GURL& url) { return; favicon_service->GetFaviconImageForURL( - FaviconService::FaviconForURLParams(browser_->profile(), - url, + FaviconService::FaviconForURLParams(url, chrome::FAVICON, gfx::kFaviconSize), base::Bind(&RecentTabsSubMenuModel::OnFaviconDataAvailable, diff --git a/chrome/browser/ui/webui/extensions/extension_icon_source.cc b/chrome/browser/ui/webui/extensions/extension_icon_source.cc index 22dcf45..591edac 100644 --- a/chrome/browser/ui/webui/extensions/extension_icon_source.cc +++ b/chrome/browser/ui/webui/extensions/extension_icon_source.cc @@ -220,8 +220,8 @@ void ExtensionIconSource::LoadFaviconImage(int request_id) { GURL favicon_url = AppLaunchInfo::GetFullLaunchURL(GetData(request_id)->extension); favicon_service->GetRawFaviconForURL( - FaviconService::FaviconForURLParams( - profile_, favicon_url, chrome::FAVICON, gfx::kFaviconSize), + FaviconService::FaviconForURLParams(favicon_url, chrome::FAVICON, + gfx::kFaviconSize), ui::SCALE_FACTOR_100P, base::Bind(&ExtensionIconSource::OnFaviconDataAvailable, base::Unretained(this), request_id), diff --git a/chrome/browser/ui/webui/favicon_source.cc b/chrome/browser/ui/webui/favicon_source.cc index 12ddab0..d5744ac 100644 --- a/chrome/browser/ui/webui/favicon_source.cc +++ b/chrome/browser/ui/webui/favicon_source.cc @@ -108,8 +108,8 @@ void FaviconSource::StartDataRequest( } favicon_service->GetRawFaviconForURL( - FaviconService::FaviconForURLParams( - profile_, url, icon_types_, parsed.size_in_dip), + FaviconService::FaviconForURLParams(url, icon_types_, + parsed.size_in_dip), parsed.scale_factor, base::Bind(&FaviconSource::OnFaviconDataAvailable, base::Unretained(this), diff --git a/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc b/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc index 91661f9..69e406d 100644 --- a/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc +++ b/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc @@ -406,7 +406,6 @@ void BookmarksHandler::HandleCreateHomeScreenBookmarkShortcut( profile, Profile::EXPLICIT_ACCESS); favicon_service->GetRawFaviconForURL( FaviconService::FaviconForURLParams( - profile, node->url(), chrome::TOUCH_PRECOMPOSED_ICON | chrome::TOUCH_ICON | chrome::FAVICON, diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc index 7f8e49a..538fbf8 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc @@ -700,8 +700,7 @@ void AppLauncherHandler::HandleGenerateAppForLink(const ListValue* args) { install_info->page_ordinal = page_ordinal; favicon_service->GetFaviconImageForURL( - FaviconService::FaviconForURLParams(profile, - launch_url, + FaviconService::FaviconForURLParams(launch_url, chrome::FAVICON, gfx::kFaviconSize), base::Bind(&AppLauncherHandler::OnFaviconForApp, diff --git a/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc b/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc index b439c9f..4aeb6b7 100644 --- a/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc +++ b/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc @@ -112,7 +112,6 @@ void FaviconWebUIHandler::HandleGetFaviconDominantColor(const ListValue* args) { dom_id_map_[id_] = dom_id; favicon_service->GetRawFaviconForURL( FaviconService::FaviconForURLParams( - Profile::FromWebUI(web_ui()), url, chrome::FAVICON, gfx::kFaviconSize), diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index 83de4b4..ce933b6 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc @@ -396,9 +396,7 @@ TestingProfile::~TestingProfile() { static BrowserContextKeyedService* BuildFaviconService( content::BrowserContext* profile) { - return new FaviconService( - HistoryServiceFactory::GetForProfileWithoutCreating( - static_cast<Profile*>(profile))); + return new FaviconService(static_cast<Profile*>(profile)); } void TestingProfile::CreateFaviconService() { |