summaryrefslogtreecommitdiffstats
path: root/chrome/browser/favicon
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/favicon')
-rw-r--r--chrome/browser/favicon/chrome_favicon_client.cc1
-rw-r--r--chrome/browser/favicon/chrome_favicon_client.h4
-rw-r--r--chrome/browser/favicon/chrome_favicon_client_factory.cc7
-rw-r--r--chrome/browser/favicon/chrome_favicon_client_factory.h13
-rw-r--r--chrome/browser/favicon/favicon_handler_unittest.cc100
-rw-r--r--chrome/browser/favicon/favicon_service_factory.cc16
-rw-r--r--chrome/browser/favicon/favicon_service_factory.h9
-rw-r--r--chrome/browser/favicon/favicon_tab_helper.cc63
-rw-r--r--chrome/browser/favicon/favicon_tab_helper.h35
-rw-r--r--chrome/browser/favicon/favicon_tab_helper_browsertest.cc2
10 files changed, 142 insertions, 108 deletions
diff --git a/chrome/browser/favicon/chrome_favicon_client.cc b/chrome/browser/favicon/chrome_favicon_client.cc
index ce0882e..99ef3ba 100644
--- a/chrome/browser/favicon/chrome_favicon_client.cc
+++ b/chrome/browser/favicon/chrome_favicon_client.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/favicon/chrome_favicon_client.h"
+#include "base/memory/singleton.h"
#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
#include "chrome/common/url_constants.h"
#include "components/bookmarks/browser/bookmark_model.h"
diff --git a/chrome/browser/favicon/chrome_favicon_client.h b/chrome/browser/favicon/chrome_favicon_client.h
index e8251f0..fc7f57f 100644
--- a/chrome/browser/favicon/chrome_favicon_client.h
+++ b/chrome/browser/favicon/chrome_favicon_client.h
@@ -16,14 +16,14 @@ class BookmarkModel;
}
// ChromeFaviconClient implements the the FaviconClient interface.
-class ChromeFaviconClient : public FaviconClient {
+class ChromeFaviconClient : public favicon::FaviconClient {
public:
ChromeFaviconClient(Profile* profile,
bookmarks::BookmarkModel* bookmark_model);
~ChromeFaviconClient() override;
private:
- // FaviconClient implementation:
+ // favicon::FaviconClient implementation:
bool IsBookmarked(const GURL& url) override;
bool IsNativeApplicationURL(const GURL& url) override;
base::CancelableTaskTracker::TaskId GetFaviconForNativeApplicationURL(
diff --git a/chrome/browser/favicon/chrome_favicon_client_factory.cc b/chrome/browser/favicon/chrome_favicon_client_factory.cc
index 2941499..ee2d769 100644
--- a/chrome/browser/favicon/chrome_favicon_client_factory.cc
+++ b/chrome/browser/favicon/chrome_favicon_client_factory.cc
@@ -4,7 +4,9 @@
#include "chrome/browser/favicon/chrome_favicon_client_factory.h"
+#include "base/memory/singleton.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
+#include "chrome/browser/favicon/chrome_favicon_client.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
@@ -20,8 +22,9 @@ ChromeFaviconClientFactory::~ChromeFaviconClientFactory() {
}
// static
-FaviconClient* ChromeFaviconClientFactory::GetForProfile(Profile* profile) {
- return static_cast<FaviconClient*>(
+favicon::FaviconClient* ChromeFaviconClientFactory::GetForProfile(
+ Profile* profile) {
+ return static_cast<favicon::FaviconClient*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
diff --git a/chrome/browser/favicon/chrome_favicon_client_factory.h b/chrome/browser/favicon/chrome_favicon_client_factory.h
index 46f8344..83fdcc0 100644
--- a/chrome/browser/favicon/chrome_favicon_client_factory.h
+++ b/chrome/browser/favicon/chrome_favicon_client_factory.h
@@ -5,19 +5,24 @@
#ifndef CHROME_BROWSER_FAVICON_CHROME_FAVICON_CLIENT_FACTORY_H_
#define CHROME_BROWSER_FAVICON_CHROME_FAVICON_CLIENT_FACTORY_H_
-#include "base/memory/singleton.h"
-#include "chrome/browser/favicon/chrome_favicon_client.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
+template <typename T>
+struct DefaultSingletonTraits;
+
class Profile;
+namespace favicon {
+class FaviconClient;
+}
+
// Singleton that owns all ChromeFaviconClients and associates them with
// Profiles.
class ChromeFaviconClientFactory : public BrowserContextKeyedServiceFactory {
public:
- // Returns the instance of FaviconClient associated with this profile
+ // Returns the instance of favicon::FaviconClient associated with |profile|
// (creating one if none exists).
- static FaviconClient* GetForProfile(Profile* profile);
+ static favicon::FaviconClient* GetForProfile(Profile* profile);
// Returns an instance of the factory singleton.
static ChromeFaviconClientFactory* GetInstance();
diff --git a/chrome/browser/favicon/favicon_handler_unittest.cc b/chrome/browser/favicon/favicon_handler_unittest.cc
index 4e4dd4c..be9db08 100644
--- a/chrome/browser/favicon/favicon_handler_unittest.cc
+++ b/chrome/browser/favicon/favicon_handler_unittest.cc
@@ -174,12 +174,12 @@ class HistoryRequestHandler {
} // namespace
-class TestFaviconClient : public FaviconClient {
+class TestFaviconClient : public favicon::FaviconClient {
public:
~TestFaviconClient() override {}
private:
- // FaviconClient implementation.
+ // favicon::FaviconClient implementation.
bool IsBookmarked(const GURL& url) override { return false; }
bool IsNativeApplicationURL(const GURL& url) override { return false; }
base::CancelableTaskTracker::TaskId GetFaviconForNativeApplicationURL(
@@ -191,7 +191,7 @@ class TestFaviconClient : public FaviconClient {
}
};
-class TestFaviconDriver : public FaviconDriver {
+class TestFaviconDriver : public favicon::FaviconDriver {
public:
TestFaviconDriver()
: favicon_validity_(false),
@@ -275,18 +275,22 @@ class TestFaviconDriver : public FaviconDriver {
// This class is used to catch the FaviconHandler's download and history
// request, and also provide the methods to access the FaviconHandler
// internals.
-class TestFaviconHandler : public FaviconHandler {
+class TestFaviconHandler : public favicon::FaviconHandler {
public:
static int GetMaximalIconSize(favicon_base::IconType icon_type) {
return FaviconHandler::GetMaximalIconSize(icon_type);
}
TestFaviconHandler(const GURL& page_url,
- FaviconClient* client,
+ favicon::FaviconClient* client,
TestFaviconDriver* driver,
Type type,
bool download_largest_icon)
- : FaviconHandler(nullptr, client, driver, type, download_largest_icon),
+ : favicon::FaviconHandler(nullptr,
+ client,
+ driver,
+ type,
+ download_largest_icon),
download_id_(0) {
driver->SetActiveURL(page_url);
download_handler_.reset(new DownloadHandler(this));
@@ -313,7 +317,7 @@ class TestFaviconHandler : public FaviconHandler {
}
FaviconURL* current_candidate() {
- return FaviconHandler::current_candidate();
+ return favicon::FaviconHandler::current_candidate();
}
const FaviconCandidate& best_favicon_candidate() {
@@ -472,7 +476,7 @@ class FaviconHandlerTest : public ChromeRenderViewHostTestHarness {
void SetUp() override {
// The score computed by SelectFaviconFrames() is dependent on the supported
// scale factors of the platform. It is used for determining the goodness of
- // a downloaded bitmap in FaviconHandler::OnDidDownloadFavicon().
+ // a downloaded bitmap in favicon::FaviconHandler::OnDidDownloadFavicon().
// Force the values of the scale factors so that the tests produce the same
// results on all platforms.
std::vector<ui::ScaleFactor> scale_factors;
@@ -503,8 +507,8 @@ TEST_F(FaviconHandlerTest, GetFaviconFromHistory) {
TestFaviconDriver driver;
TestFaviconClient client;
- TestFaviconHandler helper(
- page_url, &client, &driver, FaviconHandler::FAVICON, false);
+ TestFaviconHandler helper(page_url, &client, &driver,
+ favicon::FaviconHandler::FAVICON, false);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -544,8 +548,8 @@ TEST_F(FaviconHandlerTest, DownloadFavicon) {
TestFaviconDriver driver;
TestFaviconClient client;
- TestFaviconHandler helper(
- page_url, &client, &driver, FaviconHandler::FAVICON, false);
+ TestFaviconHandler helper(page_url, &client, &driver,
+ favicon::FaviconHandler::FAVICON, false);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -613,8 +617,8 @@ TEST_F(FaviconHandlerTest, UpdateAndDownloadFavicon) {
TestFaviconDriver driver;
TestFaviconClient client;
- TestFaviconHandler helper(
- page_url, &client, &driver, FaviconHandler::FAVICON, false);
+ TestFaviconHandler helper(page_url, &client, &driver,
+ favicon::FaviconHandler::FAVICON, false);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -694,8 +698,8 @@ TEST_F(FaviconHandlerTest, FaviconInHistoryInvalid) {
TestFaviconDriver driver;
TestFaviconClient client;
- TestFaviconHandler helper(
- page_url, &client, &driver, FaviconHandler::FAVICON, false);
+ TestFaviconHandler helper(page_url, &client, &driver,
+ favicon::FaviconHandler::FAVICON, false);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -766,8 +770,8 @@ TEST_F(FaviconHandlerTest, UpdateFavicon) {
TestFaviconDriver driver;
TestFaviconClient client;
- TestFaviconHandler helper(
- page_url, &client, &driver, FaviconHandler::FAVICON, false);
+ TestFaviconHandler helper(page_url, &client, &driver,
+ favicon::FaviconHandler::FAVICON, false);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -828,8 +832,8 @@ TEST_F(FaviconHandlerTest, Download2ndFaviconURLCandidate) {
TestFaviconDriver driver;
TestFaviconClient client;
- TestFaviconHandler helper(
- page_url, &client, &driver, FaviconHandler::TOUCH, false);
+ TestFaviconHandler helper(page_url, &client, &driver,
+ favicon::FaviconHandler::TOUCH, false);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -943,8 +947,8 @@ TEST_F(FaviconHandlerTest, UpdateDuringDownloading) {
TestFaviconDriver driver;
TestFaviconClient client;
- TestFaviconHandler helper(
- page_url, &client, &driver, FaviconHandler::TOUCH, false);
+ TestFaviconHandler helper(page_url, &client, &driver,
+ favicon::FaviconHandler::TOUCH, false);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -1086,8 +1090,8 @@ TEST_F(FaviconHandlerTest, MultipleFavicons) {
// that the largest exact match is chosen.
TestFaviconDriver driver1;
TestFaviconClient client;
- TestFaviconHandler handler1(
- kPageURL, &client, &driver1, FaviconHandler::FAVICON, false);
+ TestFaviconHandler handler1(kPageURL, &client, &driver1,
+ favicon::FaviconHandler::FAVICON, false);
const int kSizes1[] = { 16, 24, 32, 48, 256 };
std::vector<FaviconURL> urls1(kSourceIconURLs,
@@ -1108,8 +1112,8 @@ TEST_F(FaviconHandlerTest, MultipleFavicons) {
// 2) Test that if there are several single resolution favicons to choose
// from, the exact match is preferred even if it results in upsampling.
TestFaviconDriver driver2;
- TestFaviconHandler handler2(
- kPageURL, &client, &driver2, FaviconHandler::FAVICON, false);
+ TestFaviconHandler handler2(kPageURL, &client, &driver2,
+ favicon::FaviconHandler::FAVICON, false);
const int kSizes2[] = { 16, 24, 48, 256 };
std::vector<FaviconURL> urls2(kSourceIconURLs,
@@ -1125,8 +1129,8 @@ TEST_F(FaviconHandlerTest, MultipleFavicons) {
// 3) Test that favicons which need to be upsampled a little or downsampled
// a little are preferred over huge favicons.
TestFaviconDriver driver3;
- TestFaviconHandler handler3(
- kPageURL, &client, &driver3, FaviconHandler::FAVICON, false);
+ TestFaviconHandler handler3(kPageURL, &client, &driver3,
+ favicon::FaviconHandler::FAVICON, false);
const int kSizes3[] = { 256, 48 };
std::vector<FaviconURL> urls3(kSourceIconURLs,
@@ -1140,8 +1144,8 @@ TEST_F(FaviconHandlerTest, MultipleFavicons) {
driver3.GetActiveFaviconURL());
TestFaviconDriver driver4;
- TestFaviconHandler handler4(
- kPageURL, &client, &driver4, FaviconHandler::FAVICON, false);
+ TestFaviconHandler handler4(kPageURL, &client, &driver4,
+ favicon::FaviconHandler::FAVICON, false);
const int kSizes4[] = { 17, 256 };
std::vector<FaviconURL> urls4(kSourceIconURLs,
@@ -1184,8 +1188,8 @@ TEST_F(FaviconHandlerTest, TestSortFavicon) {
TestFaviconClient client;
TestFaviconDriver driver1;
- TestFaviconHandler handler1(
- kPageURL, &client, &driver1, FaviconHandler::FAVICON, true);
+ TestFaviconHandler handler1(kPageURL, &client, &driver1,
+ favicon::FaviconHandler::FAVICON, true);
std::vector<FaviconURL> urls1(kSourceIconURLs,
kSourceIconURLs + arraysize(kSourceIconURLs));
UpdateFaviconURL(&driver1, &handler1, kPageURL, urls1);
@@ -1248,8 +1252,8 @@ TEST_F(FaviconHandlerTest, TestDownloadLargestFavicon) {
TestFaviconClient client;
TestFaviconDriver driver1;
- TestFaviconHandler handler1(
- kPageURL, &client, &driver1, FaviconHandler::FAVICON, true);
+ TestFaviconHandler handler1(kPageURL, &client, &driver1,
+ favicon::FaviconHandler::FAVICON, true);
std::vector<FaviconURL> urls1(kSourceIconURLs,
kSourceIconURLs + arraysize(kSourceIconURLs));
UpdateFaviconURL(&driver1, &handler1, kPageURL, urls1);
@@ -1314,8 +1318,8 @@ TEST_F(FaviconHandlerTest, TestSelectLargestFavicon) {
TestFaviconClient client;
TestFaviconDriver driver1;
- TestFaviconHandler handler1(
- kPageURL, &client, &driver1, FaviconHandler::FAVICON, true);
+ TestFaviconHandler handler1(kPageURL, &client, &driver1,
+ favicon::FaviconHandler::FAVICON, true);
std::vector<FaviconURL> urls1(kSourceIconURLs,
kSourceIconURLs + arraysize(kSourceIconURLs));
UpdateFaviconURL(&driver1, &handler1, kPageURL, urls1);
@@ -1382,8 +1386,8 @@ TEST_F(FaviconHandlerTest, TestFaviconWasScaledAfterDownload) {
TestFaviconClient client;
TestFaviconDriver driver1;
- TestFaviconHandler handler1(
- kPageURL, &client, &driver1, FaviconHandler::FAVICON, true);
+ TestFaviconHandler handler1(kPageURL, &client, &driver1,
+ favicon::FaviconHandler::FAVICON, true);
std::vector<FaviconURL> urls1(kSourceIconURLs,
kSourceIconURLs + arraysize(kSourceIconURLs));
UpdateFaviconURL(&driver1, &handler1, kPageURL, urls1);
@@ -1444,8 +1448,8 @@ TEST_F(FaviconHandlerTest, TestKeepDownloadedLargestFavicon) {
TestFaviconClient client;
TestFaviconDriver driver1;
- TestFaviconHandler handler1(
- kPageURL, &client, &driver1, FaviconHandler::FAVICON, true);
+ TestFaviconHandler handler1(kPageURL, &client, &driver1,
+ favicon::FaviconHandler::FAVICON, true);
std::vector<FaviconURL> urls1(kSourceIconURLs,
kSourceIconURLs + arraysize(kSourceIconURLs));
UpdateFaviconURL(&driver1, &handler1, kPageURL, urls1);
@@ -1495,9 +1499,10 @@ TEST_F(FaviconHandlerTest, TestKeepDownloadedLargestFavicon) {
static KeyedService* BuildFaviconService(content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
- return new FaviconService(ChromeFaviconClientFactory::GetForProfile(profile),
- HistoryServiceFactory::GetForProfile(
- profile, ServiceAccessType::EXPLICIT_ACCESS));
+ return new favicon::FaviconService(
+ ChromeFaviconClientFactory::GetForProfile(profile),
+ HistoryServiceFactory::GetForProfile(profile,
+ ServiceAccessType::EXPLICIT_ACCESS));
}
static KeyedService* BuildHistoryService(content::BrowserContext* context) {
@@ -1519,8 +1524,9 @@ TEST_F(FaviconHandlerTest, UnableToDownloadFavicon) {
HistoryServiceFactory::GetInstance()->SetTestingFactory(
profile, BuildHistoryService);
- FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
- profile, ServiceAccessType::IMPLICIT_ACCESS);
+ favicon::FaviconService* favicon_service =
+ FaviconServiceFactory::GetForProfile(profile,
+ ServiceAccessType::IMPLICIT_ACCESS);
FaviconTabHelper::CreateForWebContents(web_contents());
FaviconTabHelper* favicon_tab_helper =
@@ -1608,8 +1614,8 @@ TEST_P(FaviconHandlerActiveFaviconValidityParamTest,
FaviconURL(new_favicon_url, favicon_base::FAVICON, one_icon)};
TestFaviconClient client;
TestFaviconDriver driver1;
- TestFaviconHandler handler1(
- page_url, &client, &driver1, FaviconHandler::FAVICON, true);
+ TestFaviconHandler handler1(page_url, &client, &driver1,
+ favicon::FaviconHandler::FAVICON, true);
std::vector<FaviconURL> urls1(source_icon_urls,
source_icon_urls + arraysize(source_icon_urls));
UpdateFaviconURL(&driver1, &handler1, page_url, urls1);
diff --git a/chrome/browser/favicon/favicon_service_factory.cc b/chrome/browser/favicon/favicon_service_factory.cc
index 1fe2f8b..cb0840c 100644
--- a/chrome/browser/favicon/favicon_service_factory.cc
+++ b/chrome/browser/favicon/favicon_service_factory.cc
@@ -14,14 +14,15 @@
#include "components/keyed_service/content/browser_context_dependency_manager.h"
// static
-FaviconService* FaviconServiceFactory::GetForProfile(Profile* profile,
- ServiceAccessType sat) {
+favicon::FaviconService* FaviconServiceFactory::GetForProfile(
+ Profile* profile,
+ ServiceAccessType sat) {
if (!profile->IsOffTheRecord()) {
- return static_cast<FaviconService*>(
+ return static_cast<favicon::FaviconService*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
} else if (sat == ServiceAccessType::EXPLICIT_ACCESS) {
// Profile must be OffTheRecord in this case.
- return static_cast<FaviconService*>(
+ return static_cast<favicon::FaviconService*>(
GetInstance()->GetServiceForBrowserContext(
profile->GetOriginalProfile(), true));
}
@@ -50,9 +51,10 @@ FaviconServiceFactory::~FaviconServiceFactory() {
KeyedService* FaviconServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile = Profile::FromBrowserContext(context);
- return new FaviconService(ChromeFaviconClientFactory::GetForProfile(profile),
- HistoryServiceFactory::GetForProfile(
- profile, ServiceAccessType::EXPLICIT_ACCESS));
+ return new favicon::FaviconService(
+ ChromeFaviconClientFactory::GetForProfile(profile),
+ HistoryServiceFactory::GetForProfile(profile,
+ ServiceAccessType::EXPLICIT_ACCESS));
}
bool FaviconServiceFactory::ServiceIsNULLWhileTesting() const {
diff --git a/chrome/browser/favicon/favicon_service_factory.h b/chrome/browser/favicon/favicon_service_factory.h
index f62e408..fd159de 100644
--- a/chrome/browser/favicon/favicon_service_factory.h
+++ b/chrome/browser/favicon/favicon_service_factory.h
@@ -5,22 +5,25 @@
#ifndef CHROME_BROWSER_FAVICON_FAVICON_SERVICE_FACTORY_H_
#define CHROME_BROWSER_FAVICON_FAVICON_SERVICE_FACTORY_H_
-#include "base/memory/singleton.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "components/keyed_service/core/service_access_type.h"
template <typename T> struct DefaultSingletonTraits;
-class FaviconService;
class Profile;
+namespace favicon {
+class FaviconService;
+}
+
// Singleton that owns all FaviconService and associates them with
// Profiles.
class FaviconServiceFactory : public BrowserContextKeyedServiceFactory {
public:
// |sat| defines what the caller plans to do with the service. See
// the ServiceAccessType definition in profile.h.
- static FaviconService* GetForProfile(Profile* profile, ServiceAccessType sat);
+ static favicon::FaviconService* GetForProfile(Profile* profile,
+ ServiceAccessType sat);
static FaviconServiceFactory* GetInstance();
diff --git a/chrome/browser/favicon/favicon_tab_helper.cc b/chrome/browser/favicon/favicon_tab_helper.cc
index 6d9c9dc..b9716b8 100644
--- a/chrome/browser/favicon/favicon_tab_helper.cc
+++ b/chrome/browser/favicon/favicon_tab_helper.cc
@@ -15,9 +15,10 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/url_constants.h"
#include "components/favicon/content/favicon_url_util.h"
+#include "components/favicon/core/favicon_client.h"
+#include "components/favicon/core/favicon_driver_observer.h"
#include "components/favicon/core/favicon_handler.h"
#include "components/favicon/core/favicon_service.h"
-#include "components/favicon/core/favicon_tab_helper_observer.h"
#include "components/favicon_base/favicon_types.h"
#include "components/history/core/browser/history_service.h"
#include "components/variations/variations_associated_data.h"
@@ -50,27 +51,32 @@ bool IsIconNTPEnabled() {
return variations::GetVariationParamValue("IconNTP", "state") == "enabled";
}
+#if defined(OS_ANDROID) || defined(OS_IOS)
+const bool kDownloadLargestIcon = true;
+#else
+const bool kDownloadLargestIcon = false;
+#endif
+
} // namespace
FaviconTabHelper::FaviconTabHelper(WebContents* web_contents)
: content::WebContentsObserver(web_contents),
profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())) {
client_ = ChromeFaviconClientFactory::GetForProfile(profile_);
-#if defined(OS_ANDROID) || defined(OS_IOS)
- bool download_largest_icon = true;
-#else
- bool download_largest_icon = false;
-#endif
- FaviconService* service = FaviconServiceFactory::GetForProfile(
+ favicon::FaviconService* service = FaviconServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
- favicon_handler_.reset(new FaviconHandler(
- service, client_, this, FaviconHandler::FAVICON, download_largest_icon));
- if (chrome::kEnableTouchIcon)
- touch_icon_handler_.reset(new FaviconHandler(
- service, client_, this, FaviconHandler::TOUCH, download_largest_icon));
- if (IsIconNTPEnabled())
- large_icon_handler_.reset(new FaviconHandler(
- service, client_, this, FaviconHandler::LARGE, true));
+ favicon_handler_.reset(new favicon::FaviconHandler(
+ service, client_, this, favicon::FaviconHandler::FAVICON,
+ kDownloadLargestIcon));
+ if (chrome::kEnableTouchIcon) {
+ touch_icon_handler_.reset(new favicon::FaviconHandler(
+ service, client_, this, favicon::FaviconHandler::TOUCH,
+ kDownloadLargestIcon));
+ }
+ if (IsIconNTPEnabled()) {
+ large_icon_handler_.reset(new favicon::FaviconHandler(
+ service, client_, this, favicon::FaviconHandler::LARGE, true));
+ }
}
FaviconTabHelper::~FaviconTabHelper() {
@@ -143,7 +149,7 @@ void FaviconTabHelper::SaveFavicon() {
return;
history->AddPageNoVisitForBookmark(entry->GetURL(), entry->GetTitle());
- FaviconService* service = FaviconServiceFactory::GetForProfile(
+ favicon::FaviconService* service = FaviconServiceFactory::GetForProfile(
profile_->GetOriginalProfile(), ServiceAccessType::IMPLICIT_ACCESS);
if (!service)
return;
@@ -156,17 +162,19 @@ void FaviconTabHelper::SaveFavicon() {
entry->GetURL(), favicon.url, favicon_base::FAVICON, favicon.image);
}
-void FaviconTabHelper::AddObserver(FaviconTabHelperObserver* observer) {
+void FaviconTabHelper::AddObserver(favicon::FaviconDriverObserver* observer) {
observer_list_.AddObserver(observer);
}
-void FaviconTabHelper::RemoveObserver(FaviconTabHelperObserver* observer) {
+void FaviconTabHelper::RemoveObserver(
+ favicon::FaviconDriverObserver* observer) {
observer_list_.RemoveObserver(observer);
}
int FaviconTabHelper::StartDownload(const GURL& url, int max_image_size) {
- FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
- profile_->GetOriginalProfile(), ServiceAccessType::IMPLICIT_ACCESS);
+ favicon::FaviconService* favicon_service =
+ FaviconServiceFactory::GetForProfile(profile_->GetOriginalProfile(),
+ ServiceAccessType::IMPLICIT_ACCESS);
if (favicon_service && favicon_service->WasUnableToDownloadFavicon(url)) {
DVLOG(1) << "Skip Failed FavIcon: " << url;
return 0;
@@ -236,9 +244,10 @@ void FaviconTabHelper::OnFaviconAvailable(const gfx::Image& image,
content::Details<bool>(&icon_url_changed));
web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB);
}
- if (!image.IsEmpty())
- FOR_EACH_OBSERVER(FaviconTabHelperObserver, observer_list_,
+ if (!image.IsEmpty()) {
+ FOR_EACH_OBSERVER(favicon::FaviconDriverObserver, observer_list_,
OnFaviconAvailable(image));
+ }
}
content::FaviconStatus& FaviconTabHelper::GetFaviconStatus() {
@@ -253,8 +262,9 @@ void FaviconTabHelper::DidStartNavigationToPendingEntry(
!profile_->IsOffTheRecord()) {
bypass_cache_page_url_ = url;
- FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
- profile_, ServiceAccessType::IMPLICIT_ACCESS);
+ favicon::FaviconService* favicon_service =
+ FaviconServiceFactory::GetForProfile(
+ profile_, ServiceAccessType::IMPLICIT_ACCESS);
if (favicon_service) {
favicon_service->SetFaviconOutOfDateForPage(url);
if (reload_type == NavigationController::RELOAD_IGNORING_CACHE)
@@ -305,8 +315,9 @@ void FaviconTabHelper::DidDownloadFavicon(
if (bitmaps.empty() && http_status_code == 404) {
DVLOG(1) << "Failed to Download Favicon:" << image_url;
- FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
- profile_->GetOriginalProfile(), ServiceAccessType::IMPLICIT_ACCESS);
+ favicon::FaviconService* favicon_service =
+ FaviconServiceFactory::GetForProfile(
+ profile_->GetOriginalProfile(), ServiceAccessType::IMPLICIT_ACCESS);
if (favicon_service)
favicon_service->UnableToDownloadFavicon(image_url);
}
diff --git a/chrome/browser/favicon/favicon_tab_helper.h b/chrome/browser/favicon/favicon_tab_helper.h
index b916d6d..547b37a 100644
--- a/chrome/browser/favicon/favicon_tab_helper.h
+++ b/chrome/browser/favicon/favicon_tab_helper.h
@@ -10,12 +10,15 @@
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/observer_list.h"
-#include "components/favicon/core/favicon_client.h"
#include "components/favicon/core/favicon_driver.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
#include "content/public/common/favicon_url.h"
+class GURL;
+class Profile;
+class SkBitmap;
+
namespace gfx {
class Image;
}
@@ -24,20 +27,20 @@ namespace content {
struct FaviconStatus;
}
-class GURL;
+namespace favicon {
+class FaviconClient;
+class FaviconDriverObserver;
class FaviconHandler;
-class FaviconTabHelperObserver;
-class Profile;
-class SkBitmap;
+}
-// FaviconTabHelper works with FaviconHandlers to fetch the favicons.
+// FaviconTabHelper works with favicon::FaviconHandlers to fetch the favicons.
//
// FetchFavicon fetches the given page's icons. It requests the icons from the
// history backend. If the icon is not available or expired, the icon will be
// downloaded and saved in the history backend.
//
class FaviconTabHelper : public content::WebContentsObserver,
- public FaviconDriver,
+ public favicon::FaviconDriver,
public content::WebContentsUserData<FaviconTabHelper> {
public:
~FaviconTabHelper() override;
@@ -72,10 +75,10 @@ class FaviconTabHelper : public content::WebContentsObserver,
// Saves the favicon for the current page.
void SaveFavicon();
- void AddObserver(FaviconTabHelperObserver* observer);
- void RemoveObserver(FaviconTabHelperObserver* observer);
+ void AddObserver(favicon::FaviconDriverObserver* observer);
+ void RemoveObserver(favicon::FaviconDriverObserver* observer);
- // FaviconDriver methods.
+ // favicon::FaviconDriver methods.
int StartDownload(const GURL& url, int max_bitmap_size) override;
bool IsOffTheRecord() override;
const gfx::Image GetActiveFaviconImage() override;
@@ -123,22 +126,22 @@ class FaviconTabHelper : public content::WebContentsObserver,
Profile* profile_;
- FaviconClient* client_;
+ favicon::FaviconClient* client_;
std::vector<content::FaviconURL> favicon_urls_;
// Bypass cache when downloading favicons for this page URL.
GURL bypass_cache_page_url_;
- scoped_ptr<FaviconHandler> favicon_handler_;
+ scoped_ptr<favicon::FaviconHandler> favicon_handler_;
- // Handles downloading touchicons. It is NULL if
+ // Handles downloading touchicons. It is null if
// browser_defaults::kEnableTouchIcon is false.
- scoped_ptr<FaviconHandler> touch_icon_handler_;
+ scoped_ptr<favicon::FaviconHandler> touch_icon_handler_;
- scoped_ptr<FaviconHandler> large_icon_handler_;
+ scoped_ptr<favicon::FaviconHandler> large_icon_handler_;
- ObserverList<FaviconTabHelperObserver> observer_list_;
+ ObserverList<favicon::FaviconDriverObserver> observer_list_;
DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper);
};
diff --git a/chrome/browser/favicon/favicon_tab_helper_browsertest.cc b/chrome/browser/favicon/favicon_tab_helper_browsertest.cc
index 2fc363a..25e2223 100644
--- a/chrome/browser/favicon/favicon_tab_helper_browsertest.cc
+++ b/chrome/browser/favicon/favicon_tab_helper_browsertest.cc
@@ -170,7 +170,7 @@ class FaviconTabHelperTest : public InProcessBrowserTest,
// FaviconTabHelperPendingTaskChecker:
bool HasPendingTasks() override {
- FaviconHandler* favicon_handler =
+ favicon::FaviconHandler* favicon_handler =
FaviconTabHelper::FromWebContents(web_contents())
->favicon_handler_.get();
return !favicon_handler->download_requests_.empty() ||