summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorrlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-23 01:08:25 +0000
committerrlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-23 01:08:25 +0000
commitc95bef3e6d79bffdb616f9965169c545dfb29097 (patch)
tree7c1eef07acb4a86adb7cb8f9d6d35a6ff8add1f2 /chrome/browser
parentbf732afbac0c44afeaefa931adfed359172aca5b (diff)
downloadchromium_src-c95bef3e6d79bffdb616f9965169c545dfb29097.zip
chromium_src-c95bef3e6d79bffdb616f9965169c545dfb29097.tar.gz
chromium_src-c95bef3e6d79bffdb616f9965169c545dfb29097.tar.bz2
Moving FaviconService to a ProfileKeyedService.
BUG=112526 Review URL: https://chromiumcodereview.appspot.com/10828263 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152904 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/bookmarks/bookmark_html_writer.cc7
-rw-r--r--chrome/browser/bookmarks/bookmark_html_writer_unittest.cc11
-rw-r--r--chrome/browser/bookmarks/bookmark_model.cc14
-rw-r--r--chrome/browser/favicon/favicon_handler.cc8
-rw-r--r--chrome/browser/favicon/favicon_service.cc56
-rw-r--r--chrome/browser/favicon/favicon_service.h12
-rw-r--r--chrome/browser/favicon/favicon_service_factory.cc55
-rw-r--r--chrome/browser/favicon/favicon_service_factory.h42
-rw-r--r--chrome/browser/favicon/favicon_tab_helper.cc9
-rw-r--r--chrome/browser/importer/profile_writer.cc3
-rw-r--r--chrome/browser/instant/instant_controller.cc5
-rw-r--r--chrome/browser/intents/register_intent_handler_helper.cc5
-rw-r--r--chrome/browser/jumplist_win.cc9
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.cc9
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.h1
-rw-r--r--chrome/browser/profiles/profile.h13
-rw-r--r--chrome/browser/profiles/profile_dependency_manager.cc2
-rw-r--r--chrome/browser/profiles/profile_impl.cc14
-rw-r--r--chrome/browser/profiles/profile_impl.h3
-rw-r--r--chrome/browser/sync/glue/bookmark_change_processor.cc3
-rw-r--r--chrome/browser/sync/glue/session_model_associator.cc8
-rw-r--r--chrome/browser/ui/cocoa/history_menu_bridge.mm12
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_controller.cc5
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc5
-rw-r--r--chrome/browser/ui/search_engines/template_url_table_model.cc6
-rw-r--r--chrome/browser/ui/toolbar/back_forward_menu_model.cc7
-rw-r--r--chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc6
-rw-r--r--chrome/browser/ui/webui/extensions/extension_icon_source.cc7
-rw-r--r--chrome/browser/ui/webui/favicon_source.cc6
-rw-r--r--chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc9
-rw-r--r--chrome/browser/ui/webui/ntp/app_launcher_handler.cc5
-rw-r--r--chrome/browser/ui/webui/ntp/favicon_webui_handler.cc10
32 files changed, 226 insertions, 141 deletions
diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc
index 014fbea..9bbd49d 100644
--- a/chrome/browser/bookmarks/bookmark_html_writer.cc
+++ b/chrome/browser/bookmarks/bookmark_html_writer.cc
@@ -20,6 +20,7 @@
#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"
@@ -457,9 +458,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 =
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
- favicon_service->GetFaviconForURL(GURL(url), history::FAVICON,
+ FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS);
+ favicon_service->GetFaviconForURL(profile_, 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 9ce76480..b9e8181 100644
--- a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc
+++ b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc
@@ -16,6 +16,7 @@
#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"
@@ -195,8 +196,9 @@ TEST_F(BookmarkHTMLWriterTest, Test) {
model->AddURLWithCreationTime(f1, 0, url1_title, url1, t1);
HistoryServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS)->
AddPage(url1, history::SOURCE_BROWSED);
- profile.GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1,
- url1_favicon, icon_data, history::FAVICON);
+ FaviconServiceFactory::GetForProfile(
+ &profile, 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);
@@ -219,8 +221,9 @@ TEST_F(BookmarkHTMLWriterTest, Test) {
// Clear favicon so that it would be read from file.
std::vector<unsigned char> empty_data;
- profile.GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1,
- url1_favicon, empty_data, history::FAVICON);
+ FaviconServiceFactory::GetForProfile(
+ &profile, 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 b6497a0..fcdea2f 100644
--- a/chrome/browser/bookmarks/bookmark_model.cc
+++ b/chrome/browser/bookmarks/bookmark_model.cc
@@ -18,6 +18,7 @@
#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"
@@ -779,7 +780,8 @@ void BookmarkModel::OnFaviconDataAvailable(
history::FaviconData favicon) {
BookmarkNode* node =
load_consumer_.GetClientData(
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle);
+ FaviconServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS), handle);
DCHECK(node);
node->set_favicon_load_handle(0);
if (favicon.is_valid()) {
@@ -798,12 +800,12 @@ void BookmarkModel::LoadFavicon(BookmarkNode* node) {
return;
DCHECK(node->url().is_valid());
- FaviconService* favicon_service =
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS);
if (!favicon_service)
return;
FaviconService::Handle handle = favicon_service->GetFaviconForURL(
- node->url(), history::FAVICON, &load_consumer_,
+ profile_, node->url(), history::FAVICON, &load_consumer_,
base::Bind(&BookmarkModel::OnFaviconDataAvailable,
base::Unretained(this)));
load_consumer_.SetClientData(favicon_service, handle, node);
@@ -817,8 +819,8 @@ void BookmarkModel::FaviconLoaded(const BookmarkNode* node) {
void BookmarkModel::CancelPendingFaviconLoadRequests(BookmarkNode* node) {
if (node->favicon_load_handle()) {
- FaviconService* favicon_service =
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
+ profile_, 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 d33e808..49adcd6 100644
--- a/chrome/browser/favicon/favicon_handler.cc
+++ b/chrome/browser/favicon/favicon_handler.cc
@@ -13,6 +13,7 @@
#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"
@@ -157,7 +158,8 @@ int FaviconHandler::DownloadImage(
}
FaviconService* FaviconHandler::GetFaviconService() {
- return profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ return FaviconServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS);
}
bool FaviconHandler::UpdateFaviconCandidate(const GURL& url,
@@ -372,8 +374,8 @@ void FaviconHandler::GetFaviconForURL(
int icon_types,
CancelableRequestConsumerBase* consumer,
const FaviconService::FaviconDataCallback& callback) {
- GetFaviconService()->GetFaviconForURL(page_url, icon_types, consumer,
- callback);
+ GetFaviconService()->GetFaviconForURL(profile_, 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 6c55b30..ff3d6e5 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(Profile* profile) : profile_(profile) {
+FaviconService::FaviconService(HistoryService* history_service)
+ : history_service_(history_service) {
}
FaviconService::Handle FaviconService::GetFavicon(
@@ -21,10 +21,8 @@ FaviconService::Handle FaviconService::GetFavicon(
const FaviconDataCallback& callback) {
GetFaviconRequest* request = new GetFaviconRequest(callback);
AddRequest(request, consumer);
- HistoryService* hs =
- HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->GetFavicon(request, icon_url, icon_type);
+ if (history_service_)
+ history_service_->GetFavicon(request, icon_url, icon_type);
else
ForwardEmptyResultAsync(request);
return request->handle();
@@ -38,16 +36,16 @@ FaviconService::Handle FaviconService::UpdateFaviconMappingAndFetch(
const FaviconDataCallback& callback) {
GetFaviconRequest* request = new GetFaviconRequest(callback);
AddRequest(request, consumer);
- HistoryService* hs =
- HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->UpdateFaviconMappingAndFetch(request, page_url, icon_url, icon_type);
+ if (history_service_)
+ history_service_->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,
@@ -58,12 +56,10 @@ 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 {
- HistoryService* hs = HistoryServiceFactory::GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->GetFaviconForURL(request, page_url, icon_types);
+ if (history_service_)
+ history_service_->GetFaviconForURL(request, page_url, icon_types);
else
ForwardEmptyResultAsync(request);
}
@@ -79,10 +75,8 @@ FaviconService::Handle FaviconService::GetFaviconForID(
GetFaviconRequest* request = new GetFaviconRequest(callback);
AddRequest(request, consumer);
FaviconService::Handle handle = request->handle();
- HistoryService* hs =
- HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->GetFaviconForID(request, favicon_id);
+ if (history_service_)
+ history_service_->GetFaviconForID(request, favicon_id);
else
ForwardEmptyResultAsync(request);
@@ -91,36 +85,28 @@ FaviconService::Handle FaviconService::GetFaviconForID(
void FaviconService::SetFaviconOutOfDateForPage(const GURL& page_url) {
- HistoryService* hs =
- HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->SetFaviconOutOfDateForPage(page_url);
+ if (history_service_)
+ history_service_->SetFaviconOutOfDateForPage(page_url);
}
void FaviconService::CloneFavicon(const GURL& old_page_url,
const GURL& new_page_url) {
- HistoryService* hs =
- HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->CloneFavicon(old_page_url, new_page_url);
+ if (history_service_)
+ history_service_->CloneFavicon(old_page_url, new_page_url);
}
void FaviconService::SetImportedFavicons(
const std::vector<history::ImportedFaviconUsage>& favicon_usage) {
- HistoryService* hs =
- HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->SetImportedFavicons(favicon_usage);
+ if (history_service_)
+ history_service_->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) {
- HistoryService* hs =
- HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (hs)
- hs->SetFavicon(page_url, icon_url, image_data, icon_type);
+ if (history_service_)
+ history_service_->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 d122dd6..b751760 100644
--- a/chrome/browser/favicon/favicon_service.h
+++ b/chrome/browser/favicon/favicon_service.h
@@ -11,9 +11,11 @@
#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
@@ -21,9 +23,10 @@ class Profile;
//
// This service is thread safe. Each request callback is invoked in the
// thread that made the request.
-class FaviconService : public CancelableRequestProvider {
+class FaviconService : public CancelableRequestProvider,
+ public ProfileKeyedService {
public:
- explicit FaviconService(Profile* profile);
+ explicit FaviconService(HistoryService* history_service);
virtual ~FaviconService();
@@ -71,7 +74,8 @@ 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(const GURL& page_url,
+ Handle GetFaviconForURL(Profile* profile,
+ const GURL& page_url,
int icon_types,
CancelableRequestConsumerBase* consumer,
const FaviconDataCallback& callback);
@@ -105,7 +109,7 @@ class FaviconService : public CancelableRequestProvider {
history::IconType icon_type);
private:
- Profile* profile_;
+ HistoryService* history_service_;
// 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
new file mode 100644
index 0000000..47398f4
--- /dev/null
+++ b/chrome/browser/favicon/favicon_service_factory.cc
@@ -0,0 +1,55 @@
+// 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
new file mode 100644
index 0000000..e9fbe9c
--- /dev/null
+++ b/chrome/browser/favicon/favicon_service_factory.h
@@ -0,0 +1,42 @@
+// 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 bcb95d3..b592d12 100644
--- a/chrome/browser/favicon/favicon_tab_helper.cc
+++ b/chrome/browser/favicon/favicon_tab_helper.cc
@@ -5,6 +5,7 @@
#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"
@@ -104,8 +105,8 @@ void FaviconTabHelper::SaveFavicon() {
return;
history->AddPageNoVisitForBookmark(entry->GetURL(), entry->GetTitle());
- FaviconService* service = profile_->
- GetOriginalProfile()->GetFaviconService(Profile::IMPLICIT_ACCESS);
+ FaviconService* service = FaviconServiceFactory::GetForProfile(
+ profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS);
if (!service)
return;
const FaviconStatus& favicon(entry->GetFavicon());
@@ -165,8 +166,8 @@ void FaviconTabHelper::NavigateToPendingEntry(
NavigationController::ReloadType reload_type) {
if (reload_type != NavigationController::NO_RELOAD &&
!profile_->IsOffTheRecord()) {
- FaviconService* favicon_service =
- profile_->GetFaviconService(Profile::IMPLICIT_ACCESS);
+ FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
+ profile_, 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 d7f6280..e7a6d20 100644
--- a/chrome/browser/importer/profile_writer.cc
+++ b/chrome/browser/importer/profile_writer.cc
@@ -14,6 +14,7 @@
#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"
@@ -232,7 +233,7 @@ void ProfileWriter::AddBookmarks(const std::vector<BookmarkEntry>& bookmarks,
void ProfileWriter::AddFavicons(
const std::vector<history::ImportedFaviconUsage>& favicons) {
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS)->
+ FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS)->
SetImportedFavicons(favicons);
}
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index 6133e45..07058ee 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -8,6 +8,7 @@
#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"
@@ -287,8 +288,8 @@ TabContents* InstantController::ReleasePreviewContents(InstantCommitType type) {
preview->history_tab_helper()->UpdateHistoryPageTitle(*entry);
// Update the favicon.
- FaviconService* favicon_service =
- preview->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
+ preview->profile(), 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 8701c7f..553971e 100644
--- a/chrome/browser/intents/register_intent_handler_helper.cc
+++ b/chrome/browser/intents/register_intent_handler_helper.cc
@@ -5,6 +5,7 @@
#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"
@@ -28,8 +29,8 @@ void Browser::RegisterIntentHandlerHelper(
if (!web_intents::IsWebIntentsEnabledForProfile(tab_contents->profile()))
return;
- FaviconService* favicon_service =
- tab_contents->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
+ tab_contents->profile(), 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 ddf53be..d66c0da 100644
--- a/chrome/browser/jumplist_win.cc
+++ b/chrome/browser/jumplist_win.cc
@@ -23,6 +23,7 @@
#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"
@@ -574,8 +575,8 @@ void JumpList::RemoveObserver() {
void JumpList::CancelPendingUpdate() {
if (handle_) {
- FaviconService* favicon_service =
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS);
favicon_service->CancelRequest(handle_);
handle_ = NULL;
}
@@ -699,9 +700,9 @@ bool JumpList::StartLoadingFavicon() {
url = GURL(icon_urls_.front().first);
}
FaviconService* favicon_service =
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
handle_ = favicon_service->GetFaviconForURL(
- url, history::FAVICON, &favicon_consumer_,
+ profile_, 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 4c0b81b..87c4c6d 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.cc
+++ b/chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -219,15 +219,6 @@ 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 c7826d6..0ec4628 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.h
+++ b/chrome/browser/profiles/off_the_record_profile_impl.h
@@ -46,7 +46,6 @@ 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 3883666..dcf54f9 100644
--- a/chrome/browser/profiles/profile.h
+++ b/chrome/browser/profiles/profile.h
@@ -215,19 +215,6 @@ 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 0a30db0..2f7aea2 100644
--- a/chrome/browser/profiles/profile_dependency_manager.cc
+++ b/chrome/browser/profiles/profile_dependency_manager.cc
@@ -18,6 +18,7 @@
#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"
@@ -216,6 +217,7 @@ 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 1f2b99d..65be424 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -39,7 +39,6 @@
#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"
@@ -260,7 +259,6 @@ 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) {
@@ -509,10 +507,6 @@ 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();
@@ -739,14 +733,6 @@ 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 ce1364b..925e863 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -84,7 +84,6 @@ 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;
@@ -210,9 +209,7 @@ 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 cae5745..b382eae 100644
--- a/chrome/browser/sync/glue/bookmark_change_processor.cc
+++ b/chrome/browser/sync/glue/bookmark_change_processor.cc
@@ -15,6 +15,7 @@
#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"
@@ -637,7 +638,7 @@ void BookmarkChangeProcessor::ApplyBookmarkFavicon(
HistoryService* history =
HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
FaviconService* favicon_service =
- profile->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconServiceFactory::GetForProfile(profile, 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 67a017d..f9e7d8c 100644
--- a/chrome/browser/sync/glue/session_model_associator.cc
+++ b/chrome/browser/sync/glue/session_model_associator.cc
@@ -13,6 +13,7 @@
#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"
@@ -541,7 +542,7 @@ void SessionModelAssociator::LoadFaviconForTab(TabLink* tab_link) {
if (!command_line.HasSwitch(switches::kSyncTabFavicons))
return;
FaviconService* favicon_service =
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
if (!favicon_service)
return;
SessionID::id_type tab_id = tab_link->tab()->GetSessionId();
@@ -551,7 +552,7 @@ void SessionModelAssociator::LoadFaviconForTab(TabLink* tab_link) {
}
DVLOG(1) << "Triggering favicon load for url " << tab_link->url().spec();
FaviconService::Handle handle = favicon_service->GetFaviconForURL(
- tab_link->url(), history::FAVICON, &load_consumer_,
+ profile_, tab_link->url(), history::FAVICON, &load_consumer_,
base::Bind(&SessionModelAssociator::OnFaviconDataAvailable,
AsWeakPtr()));
load_consumer_.SetClientData(favicon_service, handle, tab_id);
@@ -566,7 +567,8 @@ void SessionModelAssociator::OnFaviconDataAvailable(
return;
SessionID::id_type tab_id =
load_consumer_.GetClientData(
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle);
+ FaviconServiceFactory::GetForProfile(
+ profile_, 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 5b2cc84..6c55a9e 100644
--- a/chrome/browser/ui/cocoa/history_menu_bridge.mm
+++ b/chrome/browser/ui/cocoa/history_menu_bridge.mm
@@ -12,6 +12,7 @@
#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"
@@ -452,9 +453,9 @@ HistoryMenuBridge::HistoryItem* HistoryMenuBridge::HistoryItemForTab(
void HistoryMenuBridge::GetFaviconForHistoryItem(HistoryItem* item) {
FaviconService* service =
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
FaviconService::Handle handle = service->GetFaviconForURL(
- item->url, history::FAVICON, &favicon_consumer_,
+ profile_, item->url, history::FAVICON, &favicon_consumer_,
base::Bind(&HistoryMenuBridge::GotFaviconData, base::Unretained(this)));
favicon_consumer_.SetClientData(service, handle, item);
item->icon_handle = handle;
@@ -468,7 +469,8 @@ void HistoryMenuBridge::GotFaviconData(FaviconService::Handle handle,
HistoryItem* item =
favicon_consumer_.GetClientData(
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle);
+ FaviconServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS), handle);
DCHECK(item);
item->icon_requested = false;
item->icon_handle = 0;
@@ -491,8 +493,8 @@ void HistoryMenuBridge::GotFaviconData(FaviconService::Handle handle,
void HistoryMenuBridge::CancelFaviconRequest(HistoryItem* item) {
DCHECK(item);
if (item->icon_requested) {
- FaviconService* service =
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconService* service = FaviconServiceFactory::GetForProfile(
+ profile_, 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 90788a3..f84fe20 100644
--- a/chrome/browser/ui/intents/web_intent_picker_controller.cc
+++ b/chrome/browser/ui/intents/web_intent_picker_controller.cc
@@ -14,6 +14,7 @@
#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"
@@ -69,7 +70,8 @@ const int kMinThrobberDisplayTimeMs = 2000;
// Gets the favicon service for the profile in |tab_contents|.
FaviconService* GetFaviconService(TabContents* tab_contents) {
- return tab_contents->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ return FaviconServiceFactory::GetForProfile(tab_contents->profile(),
+ Profile::EXPLICIT_ACCESS);
}
// Gets the web intents registry for the profile in |tab_contents|.
@@ -503,6 +505,7 @@ 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 0815cc1..64355b8 100644
--- a/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc
+++ b/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc
@@ -13,6 +13,7 @@
#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"
@@ -237,8 +238,8 @@ class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest {
web_data_service_ = WebDataServiceFactory::GetForProfile(
GetBrowser()->profile(), Profile::EXPLICIT_ACCESS);
- favicon_service_ =
- GetBrowser()->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ favicon_service_ = FaviconServiceFactory::GetForProfile(
+ GetBrowser()->profile(), 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 280f386..8a1587b 100644
--- a/chrome/browser/ui/search_engines/template_url_table_model.cc
+++ b/chrome/browser/ui/search_engines/template_url_table_model.cc
@@ -10,6 +10,7 @@
#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"
@@ -75,9 +76,8 @@ class ModelEntry {
void LoadFavicon() {
load_state_ = LOADED;
- FaviconService* favicon_service =
- model_->template_url_service()->profile()->GetFaviconService(
- Profile::EXPLICIT_ACCESS);
+ FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
+ model_->template_url_service()->profile(), 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 955a9e7..87b4a70 100644
--- a/chrome/browser/ui/toolbar/back_forward_menu_model.cc
+++ b/chrome/browser/ui/toolbar/back_forward_menu_model.cc
@@ -10,6 +10,7 @@
#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"
@@ -240,12 +241,12 @@ void BackForwardMenuModel::FetchFavicon(NavigationEntry* entry) {
return;
}
requested_favicons_.insert(entry->GetUniqueID());
- FaviconService* favicon_service =
- browser_->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
+ browser_->profile(), Profile::EXPLICIT_ACCESS);
if (!favicon_service)
return;
FaviconService::Handle handle = favicon_service->GetFaviconForURL(
- entry->GetURL(), history::FAVICON, &load_consumer_,
+ browser_->profile(), 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 2abee51..d50dcff 100644
--- a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc
+++ b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc
@@ -8,6 +8,7 @@
#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"
@@ -529,8 +530,9 @@ TEST_F(BackFwdMenuModelTest, FaviconLoadTest) {
HistoryServiceFactory::GetForProfile(
profile(), Profile::EXPLICIT_ACCESS)->AddPage(
url1, history::SOURCE_BROWSED);
- profile()->GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1,
- url1_favicon, icon_data, history::FAVICON);
+ FaviconServiceFactory::GetForProfile(
+ profile(), 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 e0440fd..b0901fa 100644
--- a/chrome/browser/ui/webui/extensions/extension_icon_source.cc
+++ b/chrome/browser/ui/webui/extensions/extension_icon_source.cc
@@ -15,6 +15,7 @@
#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"
@@ -204,7 +205,7 @@ void ExtensionIconSource::LoadExtensionImage(const ExtensionResource& icon,
void ExtensionIconSource::LoadFaviconImage(int request_id) {
FaviconService* favicon_service =
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
// Fall back to the default icons if the service isn't available.
if (favicon_service == NULL) {
LoadDefaultImage(request_id);
@@ -213,6 +214,7 @@ 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_,
@@ -225,7 +227,8 @@ void ExtensionIconSource::OnFaviconDataAvailable(
FaviconService::Handle request_handle,
history::FaviconData favicon) {
int request_id = cancelable_consumer_.GetClientData(
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), request_handle);
+ FaviconServiceFactory::GetForProfile(profile_, 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 6fa19b9..3ba9bef 100644
--- a/chrome/browser/ui/webui/favicon_source.cc
+++ b/chrome/browser/ui/webui/favicon_source.cc
@@ -6,6 +6,7 @@
#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"
@@ -43,7 +44,7 @@ void FaviconSource::StartDataRequest(const std::string& path,
bool is_incognito,
int request_id) {
FaviconService* favicon_service =
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
if (!favicon_service || path.empty()) {
SendDefaultResponse(request_id);
return;
@@ -105,6 +106,7 @@ void FaviconSource::StartDataRequest(const std::string& path,
// TODO(estade): fetch the requested size.
handle = favicon_service->GetFaviconForURL(
+ profile_,
url,
icon_types_,
&cancelable_consumer_,
@@ -132,7 +134,7 @@ void FaviconSource::OnFaviconDataAvailable(
FaviconService::Handle request_handle,
history::FaviconData favicon) {
FaviconService* favicon_service =
- profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconServiceFactory::GetForProfile(profile_, 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 dab9682..21199c0 100644
--- a/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc
+++ b/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc
@@ -11,6 +11,7 @@
#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"
@@ -350,9 +351,10 @@ void BookmarksHandler::HandleCreateHomeScreenBookmarkShortcut(
if (!node)
return;
- FaviconService* favicon_service = profile->GetFaviconService(
- Profile::EXPLICIT_ACCESS);
+ FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
+ profile, Profile::EXPLICIT_ACCESS);
FaviconService::Handle handle = favicon_service->GetFaviconForURL(
+ profile,
node->url(),
history::FAVICON | history::TOUCH_ICON,
&cancelable_consumer_,
@@ -377,7 +379,8 @@ void BookmarksHandler::OnShortcutFaviconDataAvailable(
Profile* profile = Profile::FromBrowserContext(
web_ui()->GetWebContents()->GetBrowserContext());
const BookmarkNode* node = cancelable_consumer_.GetClientData(
- profile->GetFaviconService(Profile::EXPLICIT_ACCESS), handle);
+ FaviconServiceFactory::GetForProfile(profile, 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 305dac0..7cd0e0bb 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -25,6 +25,7 @@
#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"
@@ -691,7 +692,7 @@ void AppLauncherHandler::HandleGenerateAppForLink(const ListValue* args) {
Profile* profile = Profile::FromWebUI(web_ui());
FaviconService* favicon_service =
- profile->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
if (!favicon_service) {
LOG(ERROR) << "No favicon service";
return;
@@ -704,7 +705,7 @@ void AppLauncherHandler::HandleGenerateAppForLink(const ListValue* args) {
install_info->page_ordinal = page_ordinal;
FaviconService::Handle h = favicon_service->GetFaviconForURL(
- launch_url, history::FAVICON, &favicon_consumer_,
+ profile, 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 1002ddd..1691142 100644
--- a/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc
+++ b/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc
@@ -13,6 +13,7 @@
#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"
@@ -88,8 +89,8 @@ void FaviconWebUIHandler::HandleGetFaviconDominantColor(const ListValue* args) {
std::string dom_id;
CHECK(args->GetString(1, &dom_id));
- FaviconService* favicon_service =
- Profile::FromWebUI(web_ui())->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
+ Profile::FromWebUI(web_ui()), Profile::EXPLICIT_ACCESS);
if (!favicon_service || path.empty())
return;
@@ -109,6 +110,7 @@ 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_,
@@ -120,8 +122,8 @@ void FaviconWebUIHandler::HandleGetFaviconDominantColor(const ListValue* args) {
void FaviconWebUIHandler::OnFaviconDataAvailable(
FaviconService::Handle request_handle,
history::FaviconData favicon) {
- FaviconService* favicon_service =
- Profile::FromWebUI(web_ui())->GetFaviconService(Profile::EXPLICIT_ACCESS);
+ FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
+ Profile::FromWebUI(web_ui()), Profile::EXPLICIT_ACCESS);
int id = consumer_.GetClientData(favicon_service, request_handle);
scoped_ptr<StringValue> color_value;