summaryrefslogtreecommitdiffstats
path: root/chrome/browser/favicon/favicon_service.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/favicon/favicon_service.cc')
-rw-r--r--chrome/browser/favicon/favicon_service.cc56
1 files changed, 21 insertions, 35 deletions
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() {