diff options
34 files changed, 148 insertions, 228 deletions
diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc index 9bbd49d..014fbea 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer.cc @@ -20,7 +20,6 @@ #include "chrome/browser/bookmarks/bookmark_codec.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_model_factory.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/history/history_types.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_notification_types.h" @@ -458,9 +457,9 @@ bool BookmarkFaviconFetcher::FetchNextFavicon() { // Filter out urls that we've already got favicon for. URLFaviconMap::const_iterator iter = favicons_map_->find(url); if (favicons_map_->end() == iter) { - FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( - profile_, Profile::EXPLICIT_ACCESS); - favicon_service->GetFaviconForURL(profile_, GURL(url), history::FAVICON, + FaviconService* favicon_service = + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); + favicon_service->GetFaviconForURL(GURL(url), history::FAVICON, &favicon_consumer_, base::Bind(&BookmarkFaviconFetcher::OnFaviconDataAvailable, base::Unretained(this))); diff --git a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc index b9e8181..9ce76480 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc @@ -16,7 +16,6 @@ #include "chrome/browser/bookmarks/bookmark_html_writer.h" #include "chrome/browser/bookmarks/bookmark_model.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/importer/firefox2_importer.h" #include "chrome/test/base/testing_profile.h" @@ -196,9 +195,8 @@ TEST_F(BookmarkHTMLWriterTest, Test) { model->AddURLWithCreationTime(f1, 0, url1_title, url1, t1); HistoryServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS)-> AddPage(url1, history::SOURCE_BROWSED); - FaviconServiceFactory::GetForProfile( - &profile, Profile::EXPLICIT_ACCESS)->SetFavicon( - url1, url1_favicon, icon_data, history::FAVICON); + profile.GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1, + url1_favicon, icon_data, history::FAVICON); message_loop.RunAllPending(); const BookmarkNode* f2 = model->AddFolder(f1, 1, f2_title); model->AddURLWithCreationTime(f2, 0, url2_title, url2, t2); @@ -221,9 +219,8 @@ TEST_F(BookmarkHTMLWriterTest, Test) { // Clear favicon so that it would be read from file. std::vector<unsigned char> empty_data; - FaviconServiceFactory::GetForProfile( - &profile, Profile::EXPLICIT_ACCESS)->SetFavicon( - url1, url1_favicon, empty_data, history::FAVICON); + profile.GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1, + url1_favicon, empty_data, history::FAVICON); message_loop.RunAllPending(); // Read the bookmarks back in. diff --git a/chrome/browser/bookmarks/bookmark_model.cc b/chrome/browser/bookmarks/bookmark_model.cc index fcdea2f..b6497a0 100644 --- a/chrome/browser/bookmarks/bookmark_model.cc +++ b/chrome/browser/bookmarks/bookmark_model.cc @@ -18,7 +18,6 @@ #include "chrome/browser/bookmarks/bookmark_storage.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/history/history_notifications.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/prefs/pref_service.h" @@ -780,8 +779,7 @@ void BookmarkModel::OnFaviconDataAvailable( history::FaviconData favicon) { BookmarkNode* node = load_consumer_.GetClientData( - FaviconServiceFactory::GetForProfile( - profile_, Profile::EXPLICIT_ACCESS), handle); + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle); DCHECK(node); node->set_favicon_load_handle(0); if (favicon.is_valid()) { @@ -800,12 +798,12 @@ void BookmarkModel::LoadFavicon(BookmarkNode* node) { return; DCHECK(node->url().is_valid()); - FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( - profile_, Profile::EXPLICIT_ACCESS); + FaviconService* favicon_service = + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); if (!favicon_service) return; FaviconService::Handle handle = favicon_service->GetFaviconForURL( - profile_, node->url(), history::FAVICON, &load_consumer_, + node->url(), history::FAVICON, &load_consumer_, base::Bind(&BookmarkModel::OnFaviconDataAvailable, base::Unretained(this))); load_consumer_.SetClientData(favicon_service, handle, node); @@ -819,8 +817,8 @@ void BookmarkModel::FaviconLoaded(const BookmarkNode* node) { void BookmarkModel::CancelPendingFaviconLoadRequests(BookmarkNode* node) { if (node->favicon_load_handle()) { - FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( - profile_, Profile::EXPLICIT_ACCESS); + FaviconService* favicon_service = + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); if (favicon_service) favicon_service->CancelRequest(node->favicon_load_handle()); node->set_favicon_load_handle(0); diff --git a/chrome/browser/favicon/favicon_handler.cc b/chrome/browser/favicon/favicon_handler.cc index 49adcd6..d33e808 100644 --- a/chrome/browser/favicon/favicon_handler.cc +++ b/chrome/browser/favicon/favicon_handler.cc @@ -13,7 +13,6 @@ #include "base/memory/ref_counted_memory.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_model_factory.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/icon_messages.h" #include "content/public/browser/favicon_status.h" @@ -158,8 +157,7 @@ int FaviconHandler::DownloadImage( } FaviconService* FaviconHandler::GetFaviconService() { - return FaviconServiceFactory::GetForProfile( - profile_, Profile::EXPLICIT_ACCESS); + return profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); } bool FaviconHandler::UpdateFaviconCandidate(const GURL& url, @@ -374,8 +372,8 @@ void FaviconHandler::GetFaviconForURL( int icon_types, CancelableRequestConsumerBase* consumer, const FaviconService::FaviconDataCallback& callback) { - GetFaviconService()->GetFaviconForURL(profile_, page_url, icon_types, - consumer, callback); + GetFaviconService()->GetFaviconForURL(page_url, icon_types, consumer, + callback); } void FaviconHandler::SetHistoryFavicon( diff --git a/chrome/browser/favicon/favicon_service.cc b/chrome/browser/favicon/favicon_service.cc index ff3d6e5..6c55b30 100644 --- a/chrome/browser/favicon/favicon_service.cc +++ b/chrome/browser/favicon/favicon_service.cc @@ -7,11 +7,11 @@ #include "chrome/browser/history/history.h" #include "chrome/browser/history/history_backend.h" #include "chrome/browser/history/history_service_factory.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" #include "chrome/common/url_constants.h" -FaviconService::FaviconService(HistoryService* history_service) - : history_service_(history_service) { +FaviconService::FaviconService(Profile* profile) : profile_(profile) { } FaviconService::Handle FaviconService::GetFavicon( @@ -21,8 +21,10 @@ FaviconService::Handle FaviconService::GetFavicon( const FaviconDataCallback& callback) { GetFaviconRequest* request = new GetFaviconRequest(callback); AddRequest(request, consumer); - if (history_service_) - history_service_->GetFavicon(request, icon_url, icon_type); + HistoryService* hs = + HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); + if (hs) + hs->GetFavicon(request, icon_url, icon_type); else ForwardEmptyResultAsync(request); return request->handle(); @@ -36,16 +38,16 @@ FaviconService::Handle FaviconService::UpdateFaviconMappingAndFetch( const FaviconDataCallback& callback) { GetFaviconRequest* request = new GetFaviconRequest(callback); AddRequest(request, consumer); - if (history_service_) - history_service_->UpdateFaviconMappingAndFetch(request, page_url, - icon_url, icon_type); + HistoryService* hs = + HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); + if (hs) + hs->UpdateFaviconMappingAndFetch(request, page_url, icon_url, icon_type); else ForwardEmptyResultAsync(request); return request->handle(); } FaviconService::Handle FaviconService::GetFaviconForURL( - Profile* profile, const GURL& page_url, int icon_types, CancelableRequestConsumerBase* consumer, @@ -56,10 +58,12 @@ FaviconService::Handle FaviconService::GetFaviconForURL( if (page_url.SchemeIs(chrome::kChromeUIScheme) || page_url.SchemeIs(chrome::kExtensionScheme)) { ChromeWebUIControllerFactory::GetInstance()->GetFaviconForURL( - profile, request, page_url); + profile_, request, page_url); } else { - if (history_service_) - history_service_->GetFaviconForURL(request, page_url, icon_types); + HistoryService* hs = HistoryServiceFactory::GetForProfile( + profile_, Profile::EXPLICIT_ACCESS); + if (hs) + hs->GetFaviconForURL(request, page_url, icon_types); else ForwardEmptyResultAsync(request); } @@ -75,8 +79,10 @@ FaviconService::Handle FaviconService::GetFaviconForID( GetFaviconRequest* request = new GetFaviconRequest(callback); AddRequest(request, consumer); FaviconService::Handle handle = request->handle(); - if (history_service_) - history_service_->GetFaviconForID(request, favicon_id); + HistoryService* hs = + HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); + if (hs) + hs->GetFaviconForID(request, favicon_id); else ForwardEmptyResultAsync(request); @@ -85,28 +91,36 @@ FaviconService::Handle FaviconService::GetFaviconForID( void FaviconService::SetFaviconOutOfDateForPage(const GURL& page_url) { - if (history_service_) - history_service_->SetFaviconOutOfDateForPage(page_url); + HistoryService* hs = + HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); + if (hs) + hs->SetFaviconOutOfDateForPage(page_url); } void FaviconService::CloneFavicon(const GURL& old_page_url, const GURL& new_page_url) { - if (history_service_) - history_service_->CloneFavicon(old_page_url, new_page_url); + HistoryService* hs = + HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); + if (hs) + hs->CloneFavicon(old_page_url, new_page_url); } void FaviconService::SetImportedFavicons( const std::vector<history::ImportedFaviconUsage>& favicon_usage) { - if (history_service_) - history_service_->SetImportedFavicons(favicon_usage); + HistoryService* hs = + HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); + if (hs) + hs->SetImportedFavicons(favicon_usage); } void FaviconService::SetFavicon(const GURL& page_url, const GURL& icon_url, const std::vector<unsigned char>& image_data, history::IconType icon_type) { - if (history_service_) - history_service_->SetFavicon(page_url, icon_url, image_data, icon_type); + HistoryService* hs = + HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); + if (hs) + hs->SetFavicon(page_url, icon_url, image_data, icon_type); } FaviconService::~FaviconService() { diff --git a/chrome/browser/favicon/favicon_service.h b/chrome/browser/favicon/favicon_service.h index b751760..d122dd6 100644 --- a/chrome/browser/favicon/favicon_service.h +++ b/chrome/browser/favicon/favicon_service.h @@ -11,11 +11,9 @@ #include "base/memory/ref_counted.h" #include "chrome/browser/cancelable_request.h" #include "chrome/browser/history/history_types.h" -#include "chrome/browser/profiles/profile_keyed_service.h" #include "chrome/common/ref_counted_util.h" class GURL; -class HistoryService; class Profile; // The favicon service provides methods to access favicons. It calls the history @@ -23,10 +21,9 @@ class Profile; // // This service is thread safe. Each request callback is invoked in the // thread that made the request. -class FaviconService : public CancelableRequestProvider, - public ProfileKeyedService { +class FaviconService : public CancelableRequestProvider { public: - explicit FaviconService(HistoryService* history_service); + explicit FaviconService(Profile* profile); virtual ~FaviconService(); @@ -74,8 +71,7 @@ class FaviconService : public CancelableRequestProvider, // Note: this version is intended to be used to retrieve the favicon of a // page that has been browsed in the past. |expired| in the callback is // always false. - Handle GetFaviconForURL(Profile* profile, - const GURL& page_url, + Handle GetFaviconForURL(const GURL& page_url, int icon_types, CancelableRequestConsumerBase* consumer, const FaviconDataCallback& callback); @@ -109,7 +105,7 @@ class FaviconService : public CancelableRequestProvider, history::IconType icon_type); private: - HistoryService* history_service_; + Profile* profile_; // Helper to forward an empty result if we cannot get the history service. void ForwardEmptyResultAsync(GetFaviconRequest* request); diff --git a/chrome/browser/favicon/favicon_service_factory.cc b/chrome/browser/favicon/favicon_service_factory.cc deleted file mode 100644 index 47398f4..0000000 --- a/chrome/browser/favicon/favicon_service_factory.cc +++ /dev/null @@ -1,55 +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_service_factory.h" - -#include "base/memory/singleton.h" -#include "chrome/browser/favicon/favicon_service.h" -#include "chrome/browser/history/history.h" -#include "chrome/browser/history/history_service_factory.h" -#include "chrome/browser/prefs/pref_service.h" -#include "chrome/browser/profiles/profile_dependency_manager.h" -#include "chrome/common/pref_names.h" - -// static -FaviconService* FaviconServiceFactory::GetForProfile( - Profile* profile, Profile::ServiceAccessType sat) { - if (!profile->IsOffTheRecord()) { - return static_cast<FaviconService*>( - GetInstance()->GetServiceForProfile(profile, true)); - } else if (sat == Profile::EXPLICIT_ACCESS) { - // Profile must be OffTheRecord in this case. - return static_cast<FaviconService*>( - GetInstance()->GetServiceForProfile( - profile->GetOriginalProfile(), true)); - } - - // Profile is OffTheRecord without access. - NOTREACHED() << "This profile is OffTheRecord"; - return NULL; -} - -// static -FaviconServiceFactory* FaviconServiceFactory::GetInstance() { - return Singleton<FaviconServiceFactory>::get(); -} - -FaviconServiceFactory::FaviconServiceFactory() - : ProfileKeyedServiceFactory("FaviconService", - ProfileDependencyManager::GetInstance()) { - DependsOn(HistoryServiceFactory::GetInstance()); -} - -FaviconServiceFactory::~FaviconServiceFactory() {} - -ProfileKeyedService* FaviconServiceFactory::BuildServiceInstanceFor( - Profile* profile) const { - HistoryService* history_service = HistoryServiceFactory::GetForProfile( - profile, Profile::EXPLICIT_ACCESS); - return new FaviconService(history_service); -} - -bool FaviconServiceFactory::ServiceIsNULLWhileTesting() { - return true; -} diff --git a/chrome/browser/favicon/favicon_service_factory.h b/chrome/browser/favicon/favicon_service_factory.h deleted file mode 100644 index e9fbe9c..0000000 --- a/chrome/browser/favicon/favicon_service_factory.h +++ /dev/null @@ -1,42 +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_SERVICE_FACTORY_H_ -#define CHROME_BROWSER_FAVICON_FAVICON_SERVICE_FACTORY_H_ - -#include "base/memory/singleton.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profile_keyed_service_factory.h" - -template <typename T> struct DefaultSingletonTraits; - -class Profile; -class FaviconService; - -// Singleton that owns all FaviconService and associates them with -// Profiles. -class FaviconServiceFactory : public ProfileKeyedServiceFactory { - public: - // |access| defines what the caller plans to do with the service. See - // the ServiceAccessType definition in profile.h. - static FaviconService* GetForProfile(Profile* profile, - Profile::ServiceAccessType sat); - - static FaviconServiceFactory* GetInstance(); - - private: - friend struct DefaultSingletonTraits<FaviconServiceFactory>; - - FaviconServiceFactory(); - virtual ~FaviconServiceFactory(); - - // ProfileKeyedServiceFactory: - virtual ProfileKeyedService* BuildServiceInstanceFor( - Profile* profile) const OVERRIDE; - virtual bool ServiceIsNULLWhileTesting() OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(FaviconServiceFactory); -}; - -#endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_FACTORY_H_ diff --git a/chrome/browser/favicon/favicon_tab_helper.cc b/chrome/browser/favicon/favicon_tab_helper.cc index b592d12..bcb95d3 100644 --- a/chrome/browser/favicon/favicon_tab_helper.cc +++ b/chrome/browser/favicon/favicon_tab_helper.cc @@ -5,7 +5,6 @@ #include "chrome/browser/favicon/favicon_tab_helper.h" #include "chrome/browser/favicon/favicon_handler.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/favicon/favicon_util.h" #include "chrome/browser/favicon/select_favicon_frames.h" #include "chrome/browser/history/history.h" @@ -105,8 +104,8 @@ void FaviconTabHelper::SaveFavicon() { return; history->AddPageNoVisitForBookmark(entry->GetURL(), entry->GetTitle()); - FaviconService* service = FaviconServiceFactory::GetForProfile( - profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); + FaviconService* service = profile_-> + GetOriginalProfile()->GetFaviconService(Profile::IMPLICIT_ACCESS); if (!service) return; const FaviconStatus& favicon(entry->GetFavicon()); @@ -166,8 +165,8 @@ void FaviconTabHelper::NavigateToPendingEntry( NavigationController::ReloadType reload_type) { if (reload_type != NavigationController::NO_RELOAD && !profile_->IsOffTheRecord()) { - FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( - profile_, Profile::IMPLICIT_ACCESS); + FaviconService* favicon_service = + profile_->GetFaviconService(Profile::IMPLICIT_ACCESS); if (favicon_service) favicon_service->SetFaviconOutOfDateForPage(url); } diff --git a/chrome/browser/importer/profile_writer.cc b/chrome/browser/importer/profile_writer.cc index e7a6d20..d7f6280 100644 --- a/chrome/browser/importer/profile_writer.cc +++ b/chrome/browser/importer/profile_writer.cc @@ -14,7 +14,6 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/bookmarks/bookmark_model.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/password_manager/password_store.h" #include "chrome/browser/password_manager/password_store_factory.h" @@ -233,7 +232,7 @@ void ProfileWriter::AddBookmarks(const std::vector<BookmarkEntry>& bookmarks, void ProfileWriter::AddFavicons( const std::vector<history::ImportedFaviconUsage>& favicons) { - FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS)-> + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS)-> SetImportedFavicons(favicons); } diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc index 07058ee..6133e45 100644 --- a/chrome/browser/instant/instant_controller.cc +++ b/chrome/browser/instant/instant_controller.cc @@ -8,7 +8,6 @@ #include "base/i18n/case_conversion.h" #include "base/metrics/histogram.h" #include "chrome/browser/autocomplete/autocomplete_match.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/history/history.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/history_tab_helper.h" @@ -288,8 +287,8 @@ TabContents* InstantController::ReleasePreviewContents(InstantCommitType type) { preview->history_tab_helper()->UpdateHistoryPageTitle(*entry); // Update the favicon. - FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( - preview->profile(), Profile::EXPLICIT_ACCESS); + FaviconService* favicon_service = + preview->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS); if (favicon_service && entry->GetFavicon().valid && entry->GetFavicon().image.IsEmpty()) { std::vector<unsigned char> image_data; diff --git a/chrome/browser/intents/register_intent_handler_helper.cc b/chrome/browser/intents/register_intent_handler_helper.cc index 553971e..8701c7f 100644 --- a/chrome/browser/intents/register_intent_handler_helper.cc +++ b/chrome/browser/intents/register_intent_handler_helper.cc @@ -5,7 +5,6 @@ #include <string> #include "chrome/browser/favicon/favicon_service.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" #include "chrome/browser/intents/web_intents_registry_factory.h" #include "chrome/browser/intents/web_intents_util.h" @@ -29,8 +28,8 @@ void Browser::RegisterIntentHandlerHelper( if (!web_intents::IsWebIntentsEnabledForProfile(tab_contents->profile())) return; - FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( - tab_contents->profile(), Profile::EXPLICIT_ACCESS); + FaviconService* favicon_service = + tab_contents->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS); RegisterIntentHandlerInfoBarDelegate::MaybeShowIntentInfoBar( tab_contents->infobar_tab_helper(), diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc index d66c0da..ddf53be 100644 --- a/chrome/browser/jumplist_win.cc +++ b/chrome/browser/jumplist_win.cc @@ -23,7 +23,6 @@ #include "base/win/scoped_comptr.h" #include "base/win/windows_version.h" #include "chrome/browser/favicon/favicon_service.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/history/history.h" #include "chrome/browser/history/page_usage_data.h" #include "chrome/browser/history/top_sites.h" @@ -575,8 +574,8 @@ void JumpList::RemoveObserver() { void JumpList::CancelPendingUpdate() { if (handle_) { - FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( - profile_, Profile::EXPLICIT_ACCESS); + FaviconService* favicon_service = + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); favicon_service->CancelRequest(handle_); handle_ = NULL; } @@ -700,9 +699,9 @@ bool JumpList::StartLoadingFavicon() { url = GURL(icon_urls_.front().first); } FaviconService* favicon_service = - FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); handle_ = favicon_service->GetFaviconForURL( - profile_, url, history::FAVICON, &favicon_consumer_, + url, history::FAVICON, &favicon_consumer_, base::Bind(&JumpList::OnFaviconDataAvailable, base::Unretained(this))); return true; } diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc index 87c4c6d..4c0b81b 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.cc +++ b/chrome/browser/profiles/off_the_record_profile_impl.cc @@ -219,6 +219,15 @@ GAIAInfoUpdateService* OffTheRecordProfileImpl::GetGAIAInfoUpdateService() { return NULL; } +FaviconService* OffTheRecordProfileImpl::GetFaviconService( + ServiceAccessType sat) { + if (sat == EXPLICIT_ACCESS) + return profile_->GetFaviconService(sat); + + NOTREACHED() << "This profile is OffTheRecord"; + return NULL; +} + policy::UserCloudPolicyManager* OffTheRecordProfileImpl::GetUserCloudPolicyManager() { return profile_->GetUserCloudPolicyManager(); diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h index 0ec4628..c7826d6 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.h +++ b/chrome/browser/profiles/off_the_record_profile_impl.h @@ -46,6 +46,7 @@ class OffTheRecordProfileImpl : public Profile, virtual ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() OVERRIDE; virtual GAIAInfoUpdateService* GetGAIAInfoUpdateService() OVERRIDE; + virtual FaviconService* GetFaviconService(ServiceAccessType sat) OVERRIDE; virtual policy::UserCloudPolicyManager* GetUserCloudPolicyManager() OVERRIDE; virtual policy::PolicyService* GetPolicyService() OVERRIDE; virtual PrefService* GetPrefs() OVERRIDE; diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h index dcf54f9..3883666 100644 --- a/chrome/browser/profiles/profile.h +++ b/chrome/browser/profiles/profile.h @@ -215,6 +215,19 @@ class Profile : public content::BrowserContext { virtual ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() = 0; + // Retrieves a pointer to the FaviconService associated with this + // profile. The FaviconService is lazily created the first time + // that this method is called. + // + // Although FaviconService is refcounted, this will not addref, and callers + // do not need to do any reference counting as long as they keep the pointer + // only for the local scope (which they should do anyway since the browser + // process may decide to shut down). + // + // |access| defines what the caller plans to do with the service. See + // the ServiceAccessType definition above. + virtual FaviconService* GetFaviconService(ServiceAccessType access) = 0; + // Accessor. The instance is created upon first access. virtual GAIAInfoUpdateService* GetGAIAInfoUpdateService() = 0; diff --git a/chrome/browser/profiles/profile_dependency_manager.cc b/chrome/browser/profiles/profile_dependency_manager.cc index 2f7aea2..0a30db0 100644 --- a/chrome/browser/profiles/profile_dependency_manager.cc +++ b/chrome/browser/profiles/profile_dependency_manager.cc @@ -18,7 +18,6 @@ #include "chrome/browser/extensions/api/commands/command_service_factory.h" #include "chrome/browser/extensions/api/discovery/suggested_links_registry_factory.h" #include "chrome/browser/extensions/extension_system_factory.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/google/google_url_tracker_factory.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/shortcuts_backend_factory.h" @@ -217,7 +216,6 @@ void ProfileDependencyManager::AssertFactoriesBuilt() { extensions::SuggestedLinksRegistryFactory::GetInstance(); extensions::ExtensionSystemFactory::GetInstance(); #endif - FaviconServiceFactory::GetInstance(); FindBarStateFactory::GetInstance(); #if defined(USE_AURA) GesturePrefsObserverFactoryAura::GetInstance(); diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 65be424..1f2b99d 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -39,6 +39,7 @@ #include "chrome/browser/extensions/extension_special_storage_policy.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/user_script_master.h" +#include "chrome/browser/favicon/favicon_service.h" #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" #include "chrome/browser/history/shortcuts_backend.h" #include "chrome/browser/history/top_sites.h" @@ -259,6 +260,7 @@ ProfileImpl::ProfileImpl(const FilePath& path, new VisitedLinkEventListener(this))), ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), host_content_settings_map_(NULL), + favicon_service_created_(false), start_time_(Time::Now()), delegate_(delegate), predictor_(NULL) { @@ -507,6 +509,10 @@ ProfileImpl::~ProfileImpl() { if (top_sites_.get()) top_sites_->Shutdown(); + // FaviconService depends on HistoryServce so make sure we delete + // HistoryService first. + favicon_service_.reset(); + if (pref_proxy_config_tracker_.get()) pref_proxy_config_tracker_->DetachFromPrefService(); @@ -733,6 +739,14 @@ content::ResourceContext* ProfileImpl::GetResourceContext() { return io_data_.GetResourceContext(); } +FaviconService* ProfileImpl::GetFaviconService(ServiceAccessType sat) { + if (!favicon_service_created_) { + favicon_service_created_ = true; + favicon_service_.reset(new FaviconService(this)); + } + return favicon_service_.get(); +} + net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { return io_data_.GetExtensionsRequestContextGetter(); } diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h index 925e863..ce1364b 100644 --- a/chrome/browser/profiles/profile_impl.h +++ b/chrome/browser/profiles/profile_impl.h @@ -84,6 +84,7 @@ class ProfileImpl : public Profile, virtual extensions::EventRouter* GetExtensionEventRouter() OVERRIDE; virtual ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() OVERRIDE; + virtual FaviconService* GetFaviconService(ServiceAccessType sat) OVERRIDE; virtual GAIAInfoUpdateService* GetGAIAInfoUpdateService() OVERRIDE; virtual policy::UserCloudPolicyManager* GetUserCloudPolicyManager() OVERRIDE; virtual policy::PolicyService* GetPolicyService() OVERRIDE; @@ -209,7 +210,9 @@ class ProfileImpl : public Profile, scoped_refptr<content::GeolocationPermissionContext> geolocation_permission_context_; scoped_ptr<GAIAInfoUpdateService> gaia_info_update_service_; + scoped_ptr<FaviconService> favicon_service_; scoped_refptr<history::ShortcutsBackend> shortcuts_backend_; + bool favicon_service_created_; // Whether or not the last session exited cleanly. This is set only once. bool last_session_exited_cleanly_; diff --git a/chrome/browser/sync/glue/bookmark_change_processor.cc b/chrome/browser/sync/glue/bookmark_change_processor.cc index b382eae..cae5745 100644 --- a/chrome/browser/sync/glue/bookmark_change_processor.cc +++ b/chrome/browser/sync/glue/bookmark_change_processor.cc @@ -15,7 +15,6 @@ #include "chrome/browser/bookmarks/bookmark_model_factory.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/favicon/favicon_service.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/sync/profile_sync_service.h" @@ -638,7 +637,7 @@ void BookmarkChangeProcessor::ApplyBookmarkFavicon( HistoryService* history = HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); FaviconService* favicon_service = - FaviconServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); + profile->GetFaviconService(Profile::EXPLICIT_ACCESS); history->AddPageNoVisitForBookmark(bookmark_node->url(), bookmark_node->GetTitle()); diff --git a/chrome/browser/sync/glue/session_model_associator.cc b/chrome/browser/sync/glue/session_model_associator.cc index f9e7d8c..67a017d 100644 --- a/chrome/browser/sync/glue/session_model_associator.cc +++ b/chrome/browser/sync/glue/session_model_associator.cc @@ -13,7 +13,6 @@ #include "base/location.h" #include "base/logging.h" #include "base/threading/sequenced_worker_pool.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/history/history.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" @@ -542,7 +541,7 @@ void SessionModelAssociator::LoadFaviconForTab(TabLink* tab_link) { if (!command_line.HasSwitch(switches::kSyncTabFavicons)) return; FaviconService* favicon_service = - FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); if (!favicon_service) return; SessionID::id_type tab_id = tab_link->tab()->GetSessionId(); @@ -552,7 +551,7 @@ void SessionModelAssociator::LoadFaviconForTab(TabLink* tab_link) { } DVLOG(1) << "Triggering favicon load for url " << tab_link->url().spec(); FaviconService::Handle handle = favicon_service->GetFaviconForURL( - profile_, tab_link->url(), history::FAVICON, &load_consumer_, + tab_link->url(), history::FAVICON, &load_consumer_, base::Bind(&SessionModelAssociator::OnFaviconDataAvailable, AsWeakPtr())); load_consumer_.SetClientData(favicon_service, handle, tab_id); @@ -567,8 +566,7 @@ void SessionModelAssociator::OnFaviconDataAvailable( return; SessionID::id_type tab_id = load_consumer_.GetClientData( - FaviconServiceFactory::GetForProfile( - profile_, Profile::EXPLICIT_ACCESS), handle); + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle); TabLinksMap::iterator iter = tab_map_.find(tab_id); if (iter == tab_map_.end()) { DVLOG(1) << "Ignoring favicon for closed tab " << tab_id; diff --git a/chrome/browser/ui/cocoa/history_menu_bridge.mm b/chrome/browser/ui/cocoa/history_menu_bridge.mm index 6c55a9e..5b2cc84 100644 --- a/chrome/browser/ui/cocoa/history_menu_bridge.mm +++ b/chrome/browser/ui/cocoa/history_menu_bridge.mm @@ -12,7 +12,6 @@ #include "base/sys_string_conversions.h" #include "chrome/app/chrome_command_ids.h" // IDC_HISTORY_MENU #import "chrome/browser/app_controller_mac.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/page_usage_data.h" #include "chrome/browser/profiles/profile.h" @@ -453,9 +452,9 @@ HistoryMenuBridge::HistoryItem* HistoryMenuBridge::HistoryItemForTab( void HistoryMenuBridge::GetFaviconForHistoryItem(HistoryItem* item) { FaviconService* service = - FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); FaviconService::Handle handle = service->GetFaviconForURL( - profile_, item->url, history::FAVICON, &favicon_consumer_, + item->url, history::FAVICON, &favicon_consumer_, base::Bind(&HistoryMenuBridge::GotFaviconData, base::Unretained(this))); favicon_consumer_.SetClientData(service, handle, item); item->icon_handle = handle; @@ -469,8 +468,7 @@ void HistoryMenuBridge::GotFaviconData(FaviconService::Handle handle, HistoryItem* item = favicon_consumer_.GetClientData( - FaviconServiceFactory::GetForProfile( - profile_, Profile::EXPLICIT_ACCESS), handle); + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle); DCHECK(item); item->icon_requested = false; item->icon_handle = 0; @@ -493,8 +491,8 @@ void HistoryMenuBridge::GotFaviconData(FaviconService::Handle handle, void HistoryMenuBridge::CancelFaviconRequest(HistoryItem* item) { DCHECK(item); if (item->icon_requested) { - FaviconService* service = FaviconServiceFactory::GetForProfile( - profile_, Profile::EXPLICIT_ACCESS); + FaviconService* service = + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); service->CancelRequest(item->icon_handle); item->icon_requested = false; item->icon_handle = 0; diff --git a/chrome/browser/ui/intents/web_intent_picker_controller.cc b/chrome/browser/ui/intents/web_intent_picker_controller.cc index f84fe20..90788a3 100644 --- a/chrome/browser/ui/intents/web_intent_picker_controller.cc +++ b/chrome/browser/ui/intents/web_intent_picker_controller.cc @@ -14,7 +14,6 @@ #include "chrome/browser/extensions/platform_app_launcher.h" #include "chrome/browser/extensions/webstore_installer.h" #include "chrome/browser/favicon/favicon_service.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/intents/cws_intents_registry_factory.h" #include "chrome/browser/intents/default_web_intent_service.h" #include "chrome/browser/intents/web_intents_registry_factory.h" @@ -70,8 +69,7 @@ const int kMinThrobberDisplayTimeMs = 2000; // Gets the favicon service for the profile in |tab_contents|. FaviconService* GetFaviconService(TabContents* tab_contents) { - return FaviconServiceFactory::GetForProfile(tab_contents->profile(), - Profile::EXPLICIT_ACCESS); + return tab_contents->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS); } // Gets the web intents registry for the profile in |tab_contents|. @@ -505,7 +503,6 @@ void WebIntentPickerController::AddServiceToModel( pending_async_count_++; FaviconService::Handle handle = favicon_service->GetFaviconForURL( - tab_contents_->profile(), service.service_url, history::FAVICON, &favicon_consumer_, diff --git a/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc b/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc index 64355b8..0815cc1 100644 --- a/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc +++ b/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc @@ -13,7 +13,6 @@ #include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "chrome/browser/favicon/favicon_service.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/intents/default_web_intent_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" @@ -238,8 +237,8 @@ class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest { web_data_service_ = WebDataServiceFactory::GetForProfile( GetBrowser()->profile(), Profile::EXPLICIT_ACCESS); - favicon_service_ = FaviconServiceFactory::GetForProfile( - GetBrowser()->profile(), Profile::EXPLICIT_ACCESS); + favicon_service_ = + GetBrowser()->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS); controller_ = chrome::GetActiveTabContents(GetBrowser())-> web_intent_picker_controller(); diff --git a/chrome/browser/ui/search_engines/template_url_table_model.cc b/chrome/browser/ui/search_engines/template_url_table_model.cc index 8a1587b..280f386 100644 --- a/chrome/browser/ui/search_engines/template_url_table_model.cc +++ b/chrome/browser/ui/search_engines/template_url_table_model.cc @@ -10,7 +10,6 @@ #include "base/stl_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/favicon/favicon_service.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_service.h" @@ -76,8 +75,9 @@ class ModelEntry { void LoadFavicon() { load_state_ = LOADED; - FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( - model_->template_url_service()->profile(), Profile::EXPLICIT_ACCESS); + FaviconService* favicon_service = + model_->template_url_service()->profile()->GetFaviconService( + Profile::EXPLICIT_ACCESS); if (!favicon_service) return; GURL favicon_url = template_url()->favicon_url(); diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model.cc b/chrome/browser/ui/toolbar/back_forward_menu_model.cc index 87b4a70..955a9e7 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model.cc +++ b/chrome/browser/ui/toolbar/back_forward_menu_model.cc @@ -10,7 +10,6 @@ #include "base/bind_helpers.h" #include "base/string_number_conversions.h" #include "chrome/browser/event_disposition.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" @@ -241,12 +240,12 @@ void BackForwardMenuModel::FetchFavicon(NavigationEntry* entry) { return; } requested_favicons_.insert(entry->GetUniqueID()); - FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( - browser_->profile(), Profile::EXPLICIT_ACCESS); + FaviconService* favicon_service = + browser_->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS); if (!favicon_service) return; FaviconService::Handle handle = favicon_service->GetFaviconForURL( - browser_->profile(), entry->GetURL(), history::FAVICON, &load_consumer_, + entry->GetURL(), history::FAVICON, &load_consumer_, base::Bind(&BackForwardMenuModel::OnFavIconDataAvailable, base::Unretained(this))); load_consumer_.SetClientData(favicon_service, handle, entry->GetUniqueID()); diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc index d50dcff..2abee51 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc +++ b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc @@ -8,7 +8,6 @@ #include "base/string16.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/history/history.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/profiles/profile_manager.h" @@ -530,9 +529,8 @@ TEST_F(BackFwdMenuModelTest, FaviconLoadTest) { HistoryServiceFactory::GetForProfile( profile(), Profile::EXPLICIT_ACCESS)->AddPage( url1, history::SOURCE_BROWSED); - FaviconServiceFactory::GetForProfile( - profile(), Profile::EXPLICIT_ACCESS)->SetFavicon( - url1, url1_favicon, icon_data, history::FAVICON); + profile()->GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1, + url1_favicon, icon_data, history::FAVICON); // Will return the current icon (default) but start an anync call // to retrieve the favicon from the favicon service. diff --git a/chrome/browser/ui/webui/extensions/extension_icon_source.cc b/chrome/browser/ui/webui/extensions/extension_icon_source.cc index b0901fa..e0440fd 100644 --- a/chrome/browser/ui/webui/extensions/extension_icon_source.cc +++ b/chrome/browser/ui/webui/extensions/extension_icon_source.cc @@ -15,7 +15,6 @@ #include "base/threading/thread.h" #include "chrome/browser/extensions/extension_prefs.h" #include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" @@ -205,7 +204,7 @@ void ExtensionIconSource::LoadExtensionImage(const ExtensionResource& icon, void ExtensionIconSource::LoadFaviconImage(int request_id) { FaviconService* favicon_service = - FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); // Fall back to the default icons if the service isn't available. if (favicon_service == NULL) { LoadDefaultImage(request_id); @@ -214,7 +213,6 @@ void ExtensionIconSource::LoadFaviconImage(int request_id) { GURL favicon_url = GetData(request_id)->extension->GetFullLaunchURL(); FaviconService::Handle handle = favicon_service->GetFaviconForURL( - profile_, favicon_url, history::FAVICON, &cancelable_consumer_, @@ -227,8 +225,7 @@ void ExtensionIconSource::OnFaviconDataAvailable( FaviconService::Handle request_handle, history::FaviconData favicon) { int request_id = cancelable_consumer_.GetClientData( - FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS), - request_handle); + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), request_handle); ExtensionIconRequest* request = GetData(request_id); // Fallback to the default icon if there wasn't a favicon. diff --git a/chrome/browser/ui/webui/favicon_source.cc b/chrome/browser/ui/webui/favicon_source.cc index 3ba9bef..6fa19b9 100644 --- a/chrome/browser/ui/webui/favicon_source.cc +++ b/chrome/browser/ui/webui/favicon_source.cc @@ -6,7 +6,6 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/history/top_sites.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/url_constants.h" @@ -44,7 +43,7 @@ void FaviconSource::StartDataRequest(const std::string& path, bool is_incognito, int request_id) { FaviconService* favicon_service = - FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); if (!favicon_service || path.empty()) { SendDefaultResponse(request_id); return; @@ -106,7 +105,6 @@ void FaviconSource::StartDataRequest(const std::string& path, // TODO(estade): fetch the requested size. handle = favicon_service->GetFaviconForURL( - profile_, url, icon_types_, &cancelable_consumer_, @@ -134,7 +132,7 @@ void FaviconSource::OnFaviconDataAvailable( FaviconService::Handle request_handle, history::FaviconData favicon) { FaviconService* favicon_service = - FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); + profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); int request_id = cancelable_consumer_.GetClientData(favicon_service, request_handle); diff --git a/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc b/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc index 21199c0..dab9682 100644 --- a/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc +++ b/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc @@ -11,7 +11,6 @@ #include "chrome/browser/android/tab_android.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_model_factory.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h" @@ -351,10 +350,9 @@ void BookmarksHandler::HandleCreateHomeScreenBookmarkShortcut( if (!node) return; - FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( - profile, Profile::EXPLICIT_ACCESS); + FaviconService* favicon_service = profile->GetFaviconService( + Profile::EXPLICIT_ACCESS); FaviconService::Handle handle = favicon_service->GetFaviconForURL( - profile, node->url(), history::FAVICON | history::TOUCH_ICON, &cancelable_consumer_, @@ -379,8 +377,7 @@ void BookmarksHandler::OnShortcutFaviconDataAvailable( Profile* profile = Profile::FromBrowserContext( web_ui()->GetWebContents()->GetBrowserContext()); const BookmarkNode* node = cancelable_consumer_.GetClientData( - FaviconServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS), - handle); + profile->GetFaviconService(Profile::EXPLICIT_ACCESS), handle); TabAndroid* tab = TabAndroid::FromWebContents( web_ui()->GetWebContents()); diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc index 51dd848..748f18b 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc @@ -25,7 +25,6 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_sorting.h" #include "chrome/browser/extensions/extension_system.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/profiles/profile.h" @@ -692,7 +691,7 @@ void AppLauncherHandler::HandleGenerateAppForLink(const ListValue* args) { Profile* profile = Profile::FromWebUI(web_ui()); FaviconService* favicon_service = - FaviconServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); + profile->GetFaviconService(Profile::EXPLICIT_ACCESS); if (!favicon_service) { LOG(ERROR) << "No favicon service"; return; @@ -705,7 +704,7 @@ void AppLauncherHandler::HandleGenerateAppForLink(const ListValue* args) { install_info->page_ordinal = page_ordinal; FaviconService::Handle h = favicon_service->GetFaviconForURL( - profile, launch_url, history::FAVICON, &favicon_consumer_, + launch_url, history::FAVICON, &favicon_consumer_, base::Bind(&AppLauncherHandler::OnFaviconForApp, base::Unretained(this))); favicon_consumer_.SetClientData(favicon_service, h, install_info.release()); } diff --git a/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc b/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc index 1691142..1002ddd 100644 --- a/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc +++ b/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc @@ -13,7 +13,6 @@ #include "chrome/browser/history/top_sites.h" #include "chrome/browser/extensions/extension_icon_manager.h" #include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/extension_resource.h" #include "chrome/common/url_constants.h" @@ -89,8 +88,8 @@ void FaviconWebUIHandler::HandleGetFaviconDominantColor(const ListValue* args) { std::string dom_id; CHECK(args->GetString(1, &dom_id)); - FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( - Profile::FromWebUI(web_ui()), Profile::EXPLICIT_ACCESS); + FaviconService* favicon_service = + Profile::FromWebUI(web_ui())->GetFaviconService(Profile::EXPLICIT_ACCESS); if (!favicon_service || path.empty()) return; @@ -110,7 +109,6 @@ void FaviconWebUIHandler::HandleGetFaviconDominantColor(const ListValue* args) { dom_id_map_[id_] = dom_id; FaviconService::Handle handle = favicon_service->GetFaviconForURL( - Profile::FromWebUI(web_ui()), url, history::FAVICON, &consumer_, @@ -122,8 +120,8 @@ void FaviconWebUIHandler::HandleGetFaviconDominantColor(const ListValue* args) { void FaviconWebUIHandler::OnFaviconDataAvailable( FaviconService::Handle request_handle, history::FaviconData favicon) { - FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( - Profile::FromWebUI(web_ui()), Profile::EXPLICIT_ACCESS); + FaviconService* favicon_service = + Profile::FromWebUI(web_ui())->GetFaviconService(Profile::EXPLICIT_ACCESS); int id = consumer_.GetClientData(favicon_service, request_handle); scoped_ptr<StringValue> color_value; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index d5dd381..ffdb509 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1120,8 +1120,6 @@ 'browser/favicon/favicon_handler_delegate.h', 'browser/favicon/favicon_service.cc', 'browser/favicon/favicon_service.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', 'browser/favicon/favicon_util.cc', diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h index df53185..a38823f 100644 --- a/chrome/test/base/testing_profile.h +++ b/chrome/test/base/testing_profile.h @@ -223,6 +223,7 @@ class TestingProfile : public Profile { ExtensionSpecialStoragePolicy* extension_special_storage_policy); virtual ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() OVERRIDE; + virtual FaviconService* GetFaviconService(ServiceAccessType access) OVERRIDE; // The CookieMonster will only be returned if a Context has been created. Do // this by calling CreateRequestContext(). See the note at GetRequestContext // for more information. @@ -314,12 +315,18 @@ class TestingProfile : public Profile { // Finishes initialization when a profile is created asynchronously. void FinishInit(); + // Destroys favicon service if it has been created. + void DestroyFaviconService(); + // Creates a TestingPrefService and associates it with the TestingProfile. void CreateTestingPrefService(); virtual base::Callback<ChromeURLDataManagerBackend*(void)> GetChromeURLDataManagerBackendGetter() const OVERRIDE; + // The favicon service. Only created if CreateFaviconService is invoked. + scoped_ptr<FaviconService> favicon_service_; + // The policy service. Lazily created as a stub. scoped_ptr<policy::PolicyService> policy_service_; |