Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7206)

Unified Diff: chrome/browser/favicon/favicon_handler.cc

Issue 228783002: Moves knowledge of Profile out of FaviconHandler, into FaviconTabHelper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@FAVICON_3
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/favicon/favicon_handler.cc
diff --git a/chrome/browser/favicon/favicon_handler.cc b/chrome/browser/favicon/favicon_handler.cc
index 9c4f2a9d7989f515959a0d66e47a99c071239d36..04ade79820507cf6a538a5a081af2da80d1fcc93 100644
--- a/chrome/browser/favicon/favicon_handler.cc
+++ b/chrome/browser/favicon/favicon_handler.cc
@@ -211,6 +211,7 @@ FaviconHandler::FaviconCandidate::FaviconCandidate(
////////////////////////////////////////////////////////////////////////////////
FaviconHandler::FaviconHandler(Profile* profile,
+ FaviconClient* client,
FaviconDriver* driver,
FaviconHandlerDelegate* delegate,
Type icon_type)
@@ -220,6 +221,7 @@ FaviconHandler::FaviconHandler(Profile* profile,
? chrome::FAVICON
: chrome::TOUCH_ICON | chrome::TOUCH_PRECOMPOSED_ICON),
profile_(profile),
+ client_(client),
driver_(driver),
delegate_(delegate) {
DCHECK(profile_);
@@ -241,7 +243,7 @@ void FaviconHandler::FetchFavicon(const GURL& url) {
// Request the favicon from the history service. In parallel to this the
// renderer is going to notify us (well WebContents) when the favicon url is
// available.
- if (GetFaviconService()) {
+ if (client_->GetFaviconService()) {
GetFaviconForURLFromFaviconService(
url_,
icon_types_,
@@ -252,11 +254,6 @@ void FaviconHandler::FetchFavicon(const GURL& url) {
}
}
-FaviconService* FaviconHandler::GetFaviconService() {
- return FaviconServiceFactory::GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS);
-}
-
bool FaviconHandler::UpdateFaviconCandidate(const GURL& url,
const GURL& image_url,
const gfx::Image& image,
@@ -277,7 +274,7 @@ void FaviconHandler::SetFavicon(
const GURL& icon_url,
const gfx::Image& image,
chrome::IconType icon_type) {
- if (GetFaviconService() && ShouldSaveFavicon(url))
+ if (client_->GetFaviconService() && ShouldSaveFavicon(url))
SetHistoryFavicons(url, icon_url, icon_type, image);
if (UrlMatches(url, url_) && icon_type == chrome::FAVICON) {
@@ -337,7 +334,7 @@ void FaviconHandler::OnUpdateFaviconURL(
if (image_urls_.empty())
return;
- if (!GetFaviconService())
+ if (!client_->GetFaviconService())
return;
ProcessCurrentUrl();
@@ -444,7 +441,7 @@ void FaviconHandler::UpdateFaviconMappingAndFetch(
// UpdateFaviconMappingsAndFetch().
std::vector<GURL> icon_urls;
icon_urls.push_back(icon_url);
- GetFaviconService()->UpdateFaviconMappingsAndFetch(
+ client_->GetFaviconService()->UpdateFaviconMappingsAndFetch(
page_url, icon_urls, icon_type, preferred_icon_size(), callback, tracker);
}
@@ -453,7 +450,7 @@ void FaviconHandler::GetFaviconFromFaviconService(
chrome::IconType icon_type,
const FaviconService::FaviconResultsCallback& callback,
base::CancelableTaskTracker* tracker) {
- GetFaviconService()->GetFavicon(
+ client_->GetFaviconService()->GetFavicon(
icon_url, icon_type, preferred_icon_size(), callback, tracker);
}
@@ -462,9 +459,9 @@ void FaviconHandler::GetFaviconForURLFromFaviconService(
int icon_types,
const FaviconService::FaviconResultsCallback& callback,
base::CancelableTaskTracker* tracker) {
- GetFaviconService()->GetFaviconForURL(
- FaviconService::FaviconForURLParams(page_url, icon_types,
- preferred_icon_size()),
+ client_->GetFaviconService()->GetFaviconForURL(
+ FaviconService::FaviconForURLParams(
+ page_url, icon_types, preferred_icon_size()),
callback,
tracker);
}
@@ -473,7 +470,8 @@ void FaviconHandler::SetHistoryFavicons(const GURL& page_url,
const GURL& icon_url,
chrome::IconType icon_type,
const gfx::Image& image) {
- GetFaviconService()->SetFavicons(page_url, icon_url, icon_type, image);
+ client_->GetFaviconService()->SetFavicons(
+ page_url, icon_url, icon_type, image);
}
bool FaviconHandler::ShouldSaveFavicon(const GURL& url) {
@@ -550,7 +548,7 @@ void FaviconHandler::DownloadFaviconOrAskFaviconService(
if (favicon_expired_or_incomplete_) {
// We have the mapping, but the favicon is out of date. Download it now.
ScheduleDownload(page_url, icon_url, icon_type);
- } else if (GetFaviconService()) {
+ } else if (client_->GetFaviconService()) {
// We don't know the favicon, but we may have previously downloaded the
// favicon for another page that shares the same favicon. Ask for the
// favicon given the favicon URL.

Powered by Google App Engine
This is Rietveld 408576698