| Index: chrome/browser/favicon/favicon_service.cc
|
| diff --git a/chrome/browser/favicon/favicon_service.cc b/chrome/browser/favicon/favicon_service.cc
|
| index 6c55b307fd75475ad91d8a8448a4aa5aa5b421dd..90b00eb7b691dfff9175d1e7f12d84c177c66be5 100644
|
| --- a/chrome/browser/favicon/favicon_service.cc
|
| +++ b/chrome/browser/favicon/favicon_service.cc
|
| @@ -6,12 +6,12 @@
|
|
|
| #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(scoped_refptr<HistoryService> hs,
|
| + Profile* profile)
|
| + : history_service_(hs), profile_(profile) {
|
| }
|
|
|
| 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,10 +36,9 @@ 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();
|
| @@ -57,13 +54,12 @@ FaviconService::Handle FaviconService::GetFaviconForURL(
|
| FaviconService::Handle handle = request->handle();
|
| if (page_url.SchemeIs(chrome::kChromeUIScheme) ||
|
| page_url.SchemeIs(chrome::kExtensionScheme)) {
|
| + DCHECK(profile_) << "FaviconService::Shutdown() was already called!";
|
| ChromeWebUIControllerFactory::GetInstance()->GetFaviconForURL(
|
| 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,41 +85,37 @@ 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() {
|
| }
|
|
|
| +void FaviconService::Shutdown() {
|
| + profile_ = NULL;
|
| +}
|
| +
|
| void FaviconService::ForwardEmptyResultAsync(GetFaviconRequest* request) {
|
| request->ForwardResultAsync(request->handle(), history::FaviconData());
|
| }
|
|
|