Commit a72f0b2c authored by jif@chromium.org's avatar jif@chromium.org

Replace content's faviconURL with components/favicon's

BUG=359586

Review URL: https://codereview.chromium.org/285293005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271367 0039d316-1c4b-4281-b951-d872f2087c98
parent dc437832
......@@ -21,7 +21,7 @@
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_util.h"
using content::FaviconURL;
using favicon::FaviconURL;
namespace {
......@@ -29,22 +29,6 @@ namespace {
// the apple touch icon for iPad.
const int kTouchIconSize = 144;
// Returns favicon_base::IconType the given icon_type corresponds to.
favicon_base::IconType ToChromeIconType(FaviconURL::IconType icon_type) {
switch (icon_type) {
case FaviconURL::FAVICON:
return favicon_base::FAVICON;
case FaviconURL::TOUCH_ICON:
return favicon_base::TOUCH_ICON;
case FaviconURL::TOUCH_PRECOMPOSED_ICON:
return favicon_base::TOUCH_PRECOMPOSED_ICON;
case FaviconURL::INVALID_ICON:
return favicon_base::INVALID_ICON;
}
NOTREACHED();
return favicon_base::INVALID_ICON;
}
// Get the maximal icon size in pixels for a icon of type |icon_type| for the
// current platform.
int GetMaximalIconSize(favicon_base::IconType icon_type) {
......@@ -68,8 +52,7 @@ int GetMaximalIconSize(favicon_base::IconType icon_type) {
bool DoUrlAndIconMatch(const FaviconURL& favicon_url,
const GURL& url,
favicon_base::IconType icon_type) {
return favicon_url.icon_url == url &&
ToChromeIconType(favicon_url.icon_type) == icon_type;
return favicon_url.icon_url == url && favicon_url.icon_type == icon_type;
}
// Returns true if all of the icon URLs and icon types in |bitmap_results| are
......@@ -81,8 +64,7 @@ bool DoUrlsAndIconsMatch(
if (bitmap_results.empty())
return false;
const favicon_base::IconType icon_type =
ToChromeIconType(favicon_url.icon_type);
const favicon_base::IconType icon_type = favicon_url.icon_type;
for (size_t i = 0; i < bitmap_results.size(); ++i) {
if (favicon_url.icon_url != bitmap_results[i].icon_url ||
......@@ -393,7 +375,7 @@ void FaviconHandler::ProcessCurrentUrl() {
if (PageChangedSinceFaviconWasRequested() || !current_candidate())
return;
if (current_candidate()->icon_type == FaviconURL::FAVICON) {
if (current_candidate()->icon_type == favicon_base::FAVICON) {
if (!favicon_expired_or_incomplete_ &&
driver_->GetActiveFaviconValidity() &&
DoUrlAndIconMatch(*current_candidate(),
......@@ -407,10 +389,9 @@ void FaviconHandler::ProcessCurrentUrl() {
}
if (got_favicon_from_history_)
DownloadFaviconOrAskFaviconService(
driver_->GetActiveURL(),
current_candidate()->icon_url,
ToChromeIconType(current_candidate()->icon_type));
DownloadFaviconOrAskFaviconService(driver_->GetActiveURL(),
current_candidate()->icon_url,
current_candidate()->icon_type);
}
void FaviconHandler::OnDidDownloadFavicon(
......@@ -592,19 +573,17 @@ void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService(
// Mapping in the database is wrong. DownloadFavIconOrAskHistory will
// update the mapping for this url and download the favicon if we don't
// already have it.
DownloadFaviconOrAskFaviconService(
driver_->GetActiveURL(),
current_candidate()->icon_url,
ToChromeIconType(current_candidate()->icon_type));
DownloadFaviconOrAskFaviconService(driver_->GetActiveURL(),
current_candidate()->icon_url,
current_candidate()->icon_type);
}
} else if (current_candidate()) {
// We know the official url for the favicon, but either don't have the
// favicon or it's expired. Continue on to DownloadFaviconOrAskHistory to
// either download or check history again.
DownloadFaviconOrAskFaviconService(
driver_->GetActiveURL(),
current_candidate()->icon_url,
ToChromeIconType(current_candidate()->icon_type));
DownloadFaviconOrAskFaviconService(driver_->GetActiveURL(),
current_candidate()->icon_url,
current_candidate()->icon_type);
}
// else we haven't got the icon url. When we get it we'll ask the
// renderer to download the icon.
......@@ -669,7 +648,7 @@ void FaviconHandler::OnFaviconData(const std::vector<
// one got from page. Request the current one.
ScheduleDownload(driver_->GetActiveURL(),
current_candidate()->icon_url,
ToChromeIconType(current_candidate()->icon_type));
current_candidate()->icon_type);
}
history_results_ = favicon_bitmap_results;
}
......@@ -699,7 +678,7 @@ void FaviconHandler::SortAndPruneImageUrls() {
++i;
continue;
}
int max_size = GetMaximalIconSize(ToChromeIconType(i->icon_type));
int max_size = GetMaximalIconSize(i->icon_type);
int index = GetLargestSizeIndex(i->icon_sizes, max_size * max_size);
if (index == -1) {
i = image_urls_.erase(i);
......
......@@ -15,7 +15,7 @@
#include "base/task/cancelable_task_tracker.h"
#include "chrome/browser/favicon/favicon_service.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
#include "content/public/common/favicon_url.h"
#include "components/favicon/core/favicon_url.h"
#include "ui/gfx/favicon_size.h"
#include "ui/gfx/image/image.h"
#include "url/gurl.h"
......@@ -92,7 +92,7 @@ class FaviconHandler {
// Message Handler. Must be public, because also called from
// PrerenderContents. Collects the |image_urls| list.
void OnUpdateFaviconURL(const std::vector<content::FaviconURL>& candidates);
void OnUpdateFaviconURL(const std::vector<favicon::FaviconURL>& candidates);
// Processes the current image_irls_ entry, requesting the image from the
// history / download service.
......@@ -110,7 +110,7 @@ class FaviconHandler {
const std::vector<gfx::Size>& original_bitmap_sizes);
// For testing.
const std::vector<content::FaviconURL>& image_urls() const {
const std::vector<favicon::FaviconURL>& image_urls() const {
return image_urls_;
}
......@@ -229,7 +229,7 @@ class FaviconHandler {
void SetFaviconOnActivePage(const GURL& icon_url, const gfx::Image& image);
// Return the current candidate if any.
content::FaviconURL* current_candidate() {
favicon::FaviconURL* current_candidate() {
return (!image_urls_.empty()) ? &image_urls_.front() : NULL;
}
......@@ -275,7 +275,7 @@ class FaviconHandler {
const bool download_largest_icon_;
// The prioritized favicon candidates from the page back from the renderer.
std::vector<content::FaviconURL> image_urls_;
std::vector<favicon::FaviconURL> image_urls_;
// The FaviconBitmapResults from history.
std::vector<favicon_base::FaviconBitmapResult> history_results_;
......
......@@ -15,7 +15,7 @@
class TestFaviconHandler;
using content::FaviconURL;
using favicon::FaviconURL;
namespace {
......@@ -503,14 +503,14 @@ TEST_F(FaviconHandlerTest, GetFaviconFromHistory) {
// Simulates update favicon url.
std::vector<FaviconURL> urls;
urls.push_back(
FaviconURL(icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>()));
FaviconURL(icon_url, favicon_base::FAVICON, std::vector<gfx::Size>()));
helper.OnUpdateFaviconURL(urls);
// Verify FaviconHandler status
EXPECT_EQ(1U, helper.urls().size());
ASSERT_TRUE(helper.current_candidate());
ASSERT_EQ(icon_url, helper.current_candidate()->icon_url);
ASSERT_EQ(FaviconURL::FAVICON, helper.current_candidate()->icon_type);
ASSERT_EQ(favicon_base::FAVICON, helper.current_candidate()->icon_type);
// Favicon shouldn't request to download icon.
EXPECT_FALSE(helper.download_handler()->HasDownload());
......@@ -547,14 +547,14 @@ TEST_F(FaviconHandlerTest, DownloadFavicon) {
// Simulates update favicon url.
std::vector<FaviconURL> urls;
urls.push_back(
FaviconURL(icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>()));
FaviconURL(icon_url, favicon_base::FAVICON, std::vector<gfx::Size>()));
helper.OnUpdateFaviconURL(urls);
// Verify FaviconHandler status
EXPECT_EQ(1U, helper.urls().size());
ASSERT_TRUE(helper.current_candidate());
ASSERT_EQ(icon_url, helper.current_candidate()->icon_url);
ASSERT_EQ(FaviconURL::FAVICON, helper.current_candidate()->icon_type);
ASSERT_EQ(favicon_base::FAVICON, helper.current_candidate()->icon_type);
// Favicon should request to download icon now.
DownloadHandler* download_handler = helper.download_handler();
......@@ -573,7 +573,7 @@ TEST_F(FaviconHandlerTest, DownloadFavicon) {
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(icon_url, history_handler->icon_url_);
EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_);
EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_);
EXPECT_LT(0U, history_handler->bitmap_data_.size());
EXPECT_EQ(page_url, history_handler->page_url_);
......@@ -617,21 +617,21 @@ TEST_F(FaviconHandlerTest, UpdateAndDownloadFavicon) {
// Simulates update with the different favicon url.
std::vector<FaviconURL> urls;
urls.push_back(
FaviconURL(new_icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>()));
urls.push_back(FaviconURL(
new_icon_url, favicon_base::FAVICON, std::vector<gfx::Size>()));
helper.OnUpdateFaviconURL(urls);
// Verify FaviconHandler status.
EXPECT_EQ(1U, helper.urls().size());
ASSERT_TRUE(helper.current_candidate());
ASSERT_EQ(new_icon_url, helper.current_candidate()->icon_url);
ASSERT_EQ(FaviconURL::FAVICON, helper.current_candidate()->icon_type);
ASSERT_EQ(favicon_base::FAVICON, helper.current_candidate()->icon_type);
// Favicon should be requested from history.
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(new_icon_url, history_handler->icon_url_);
EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_);
EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_);
EXPECT_EQ(page_url, history_handler->page_url_);
// Simulate not find icon.
......@@ -655,7 +655,7 @@ TEST_F(FaviconHandlerTest, UpdateAndDownloadFavicon) {
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(new_icon_url, history_handler->icon_url_);
EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_);
EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_);
EXPECT_LT(0U, history_handler->bitmap_data_.size());
EXPECT_EQ(page_url, history_handler->page_url_);
......@@ -707,7 +707,7 @@ TEST_F(FaviconHandlerTest, FaviconInHistoryInvalid) {
// Simulates update with matching favicon URL.
std::vector<FaviconURL> urls;
urls.push_back(
FaviconURL(icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>()));
FaviconURL(icon_url, favicon_base::FAVICON, std::vector<gfx::Size>()));
helper.OnUpdateFaviconURL(urls);
// A download for the favicon should be requested, and we should not do
......@@ -726,7 +726,7 @@ TEST_F(FaviconHandlerTest, FaviconInHistoryInvalid) {
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(icon_url, history_handler->icon_url_);
EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_);
EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_);
EXPECT_LT(0U, history_handler->bitmap_data_.size());
EXPECT_EQ(page_url, history_handler->page_url_);
......@@ -769,21 +769,21 @@ TEST_F(FaviconHandlerTest, UpdateFavicon) {
// Simulates update with the different favicon url.
std::vector<FaviconURL> urls;
urls.push_back(
FaviconURL(new_icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>()));
urls.push_back(FaviconURL(
new_icon_url, favicon_base::FAVICON, std::vector<gfx::Size>()));
helper.OnUpdateFaviconURL(urls);
// Verify FaviconHandler status.
EXPECT_EQ(1U, helper.urls().size());
ASSERT_TRUE(helper.current_candidate());
ASSERT_EQ(new_icon_url, helper.current_candidate()->icon_url);
ASSERT_EQ(FaviconURL::FAVICON, helper.current_candidate()->icon_type);
ASSERT_EQ(favicon_base::FAVICON, helper.current_candidate()->icon_type);
// Favicon should be requested from history.
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(new_icon_url, history_handler->icon_url_);
EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_);
EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_);
EXPECT_EQ(page_url, history_handler->page_url_);
// Simulate find icon.
......@@ -832,26 +832,27 @@ TEST_F(FaviconHandlerTest, Download2ndFaviconURLCandidate) {
// Simulates update with the different favicon url.
std::vector<FaviconURL> urls;
urls.push_back(FaviconURL(icon_url,
favicon_base::TOUCH_PRECOMPOSED_ICON,
std::vector<gfx::Size>()));
urls.push_back(FaviconURL(
icon_url, FaviconURL::TOUCH_PRECOMPOSED_ICON, std::vector<gfx::Size>()));
new_icon_url, favicon_base::TOUCH_ICON, std::vector<gfx::Size>()));
urls.push_back(FaviconURL(
new_icon_url, FaviconURL::TOUCH_ICON, std::vector<gfx::Size>()));
urls.push_back(
FaviconURL(new_icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>()));
new_icon_url, favicon_base::FAVICON, std::vector<gfx::Size>()));
helper.OnUpdateFaviconURL(urls);
// Verify FaviconHandler status.
EXPECT_EQ(2U, helper.urls().size());
ASSERT_TRUE(helper.current_candidate());
ASSERT_EQ(icon_url, helper.current_candidate()->icon_url);
ASSERT_EQ(FaviconURL::TOUCH_PRECOMPOSED_ICON,
ASSERT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON,
helper.current_candidate()->icon_type);
// Favicon should be requested from history.
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(icon_url, history_handler->icon_url_);
EXPECT_EQ(FaviconURL::TOUCH_PRECOMPOSED_ICON, history_handler->icon_type_);
EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, history_handler->icon_type_);
EXPECT_EQ(page_url, history_handler->page_url_);
// Simulate not find icon.
......@@ -876,13 +877,13 @@ TEST_F(FaviconHandlerTest, Download2ndFaviconURLCandidate) {
EXPECT_EQ(1U, helper.urls().size());
ASSERT_TRUE(helper.current_candidate());
EXPECT_EQ(new_icon_url, helper.current_candidate()->icon_url);
EXPECT_EQ(FaviconURL::TOUCH_ICON, helper.current_candidate()->icon_type);
EXPECT_EQ(favicon_base::TOUCH_ICON, helper.current_candidate()->icon_type);
// Favicon should be requested from history.
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(new_icon_url, history_handler->icon_url_);
EXPECT_EQ(FaviconURL::TOUCH_ICON, history_handler->icon_type_);
EXPECT_EQ(favicon_base::TOUCH_ICON, history_handler->icon_type_);
EXPECT_EQ(page_url, history_handler->page_url_);
// Reset download handler
......@@ -908,7 +909,7 @@ TEST_F(FaviconHandlerTest, Download2ndFaviconURLCandidate) {
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(new_icon_url, history_handler->icon_url_);
EXPECT_EQ(FaviconURL::TOUCH_ICON, history_handler->icon_type_);
EXPECT_EQ(favicon_base::TOUCH_ICON, history_handler->icon_type_);
EXPECT_LT(0U, history_handler->bitmap_data_.size());
EXPECT_EQ(page_url, history_handler->page_url_);
}
......@@ -946,26 +947,27 @@ TEST_F(FaviconHandlerTest, UpdateDuringDownloading) {
// Simulates update with the different favicon url.
std::vector<FaviconURL> urls;
urls.push_back(FaviconURL(icon_url,
favicon_base::TOUCH_PRECOMPOSED_ICON,
std::vector<gfx::Size>()));
urls.push_back(FaviconURL(
icon_url, FaviconURL::TOUCH_PRECOMPOSED_ICON, std::vector<gfx::Size>()));
new_icon_url, favicon_base::TOUCH_ICON, std::vector<gfx::Size>()));
urls.push_back(FaviconURL(
new_icon_url, FaviconURL::TOUCH_ICON, std::vector<gfx::Size>()));
urls.push_back(
FaviconURL(new_icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>()));
new_icon_url, favicon_base::FAVICON, std::vector<gfx::Size>()));
helper.OnUpdateFaviconURL(urls);
// Verify FaviconHandler status.
EXPECT_EQ(2U, helper.urls().size());
ASSERT_TRUE(helper.current_candidate());
ASSERT_EQ(icon_url, helper.current_candidate()->icon_url);
ASSERT_EQ(FaviconURL::TOUCH_PRECOMPOSED_ICON,
ASSERT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON,
helper.current_candidate()->icon_type);
// Favicon should be requested from history.
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(icon_url, history_handler->icon_url_);
EXPECT_EQ(FaviconURL::TOUCH_PRECOMPOSED_ICON, history_handler->icon_type_);
EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, history_handler->icon_type_);
EXPECT_EQ(page_url, history_handler->page_url_);
// Simulate not find icon.
......@@ -985,18 +987,18 @@ TEST_F(FaviconHandlerTest, UpdateDuringDownloading) {
const GURL latest_icon_url("http://www.google.com/latest_favicon");
std::vector<FaviconURL> latest_urls;
latest_urls.push_back(FaviconURL(
latest_icon_url, FaviconURL::TOUCH_ICON, std::vector<gfx::Size>()));
latest_icon_url, favicon_base::TOUCH_ICON, std::vector<gfx::Size>()));
helper.OnUpdateFaviconURL(latest_urls);
EXPECT_EQ(1U, helper.urls().size());
EXPECT_EQ(latest_icon_url, helper.current_candidate()->icon_url);
EXPECT_EQ(FaviconURL::TOUCH_ICON, helper.current_candidate()->icon_type);
EXPECT_EQ(favicon_base::TOUCH_ICON, helper.current_candidate()->icon_type);
// Whether new icon is requested from history
history_handler = helper.history_handler();
ASSERT_TRUE(history_handler);
EXPECT_EQ(latest_icon_url, history_handler->icon_url_);
EXPECT_EQ(FaviconURL::TOUCH_ICON, history_handler->icon_type_);
EXPECT_EQ(favicon_base::TOUCH_ICON, history_handler->icon_type_);
EXPECT_EQ(page_url, history_handler->page_url_);
// Reset the history_handler to verify whether favicon is request from
......@@ -1036,19 +1038,19 @@ TEST_F(FaviconHandlerTest, MultipleFavicons) {
const GURL kPageURL("http://www.google.com");
const FaviconURL kSourceIconURLs[] = {
FaviconURL(GURL("http://www.google.com/a"),
FaviconURL::FAVICON,
favicon_base::FAVICON,
std::vector<gfx::Size>()),
FaviconURL(GURL("http://www.google.com/b"),
FaviconURL::FAVICON,
favicon_base::FAVICON,
std::vector<gfx::Size>()),
FaviconURL(GURL("http://www.google.com/c"),
FaviconURL::FAVICON,
favicon_base::FAVICON,
std::vector<gfx::Size>()),
FaviconURL(GURL("http://www.google.com/d"),
FaviconURL::FAVICON,
favicon_base::FAVICON,
std::vector<gfx::Size>()),
FaviconURL(GURL("http://www.google.com/e"),
FaviconURL::FAVICON,
favicon_base::FAVICON,
std::vector<gfx::Size>())};
// Set the supported scale factors to 1x and 2x. This affects the behavior of
......@@ -1144,20 +1146,14 @@ TEST_F(FaviconHandlerTest, TestSortFavicon) {
icon3.push_back(gfx::Size(14, 14));
const FaviconURL kSourceIconURLs[] = {
FaviconURL(GURL("http://www.google.com/a"),
FaviconURL::FAVICON,
icon1),
FaviconURL(GURL("http://www.google.com/b"),
FaviconURL::FAVICON,
icon2),
FaviconURL(GURL("http://www.google.com/c"),
FaviconURL::FAVICON,
icon3),
FaviconURL(GURL("http://www.google.com/a"), favicon_base::FAVICON, icon1),
FaviconURL(GURL("http://www.google.com/b"), favicon_base::FAVICON, icon2),
FaviconURL(GURL("http://www.google.com/c"), favicon_base::FAVICON, icon3),
FaviconURL(GURL("http://www.google.com/d"),
FaviconURL::FAVICON,
favicon_base::FAVICON,
std::vector<gfx::Size>()),
FaviconURL(GURL("http://www.google.com/e"),
FaviconURL::FAVICON,
favicon_base::FAVICON,
std::vector<gfx::Size>())};
TestFaviconClient client;
......@@ -1209,20 +1205,17 @@ TEST_F(FaviconHandlerTest, TestDownloadLargestFavicon) {
two_icons.push_back(gfx::Size(14, 14));
const FaviconURL kSourceIconURLs[] = {
FaviconURL(GURL("http://www.google.com/a"),
FaviconURL::FAVICON,
too_large),
FaviconURL(GURL("http://www.google.com/b"),
FaviconURL::FAVICON,
one_icon),
FaviconURL(GURL("http://www.google.com/c"),
FaviconURL::FAVICON,
two_icons),
FaviconURL(
GURL("http://www.google.com/a"), favicon_base::FAVICON, too_large),
FaviconURL(
GURL("http://www.google.com/b"), favicon_base::FAVICON, one_icon),
FaviconURL(
GURL("http://www.google.com/c"), favicon_base::FAVICON, two_icons),
FaviconURL(GURL("http://www.google.com/d"),
FaviconURL::FAVICON,
favicon_base::FAVICON,
std::vector<gfx::Size>()),
FaviconURL(GURL("http://www.google.com/e"),
FaviconURL::FAVICON,
favicon_base::FAVICON,
std::vector<gfx::Size>())};
TestFaviconClient client;
......@@ -1290,12 +1283,10 @@ TEST_F(FaviconHandlerTest, TestSelectLargestFavicon) {
two_icons.push_back(gfx::Size(16, 16));
const FaviconURL kSourceIconURLs[] = {
FaviconURL(GURL("http://www.google.com/b"),
FaviconURL::FAVICON,
one_icon),
FaviconURL(GURL("http://www.google.com/c"),
FaviconURL::FAVICON,
two_icons)};
FaviconURL(
GURL("http://www.google.com/b"), favicon_base::FAVICON, one_icon),
FaviconURL(
GURL("http://www.google.com/c"), favicon_base::FAVICON, two_icons)};
TestFaviconClient client;
TestFaviconDriver driver1;
......@@ -1355,14 +1346,10 @@ TEST_F(FaviconHandlerTest, TestKeepDownloadedLargestFavicon) {
const int actual_size2 = 12;
const FaviconURL kSourceIconURLs[] = {
FaviconURL(GURL("http://www.google.com/b"),
FaviconURL::FAVICON,
icon1),
FaviconURL(GURL("http://www.google.com/c"),
FaviconURL::FAVICON,
icon2),
FaviconURL(GURL("http://www.google.com/b"), favicon_base::FAVICON, icon1),
FaviconURL(GURL("http://www.google.com/c"), favicon_base::FAVICON, icon2),
FaviconURL(GURL("http://www.google.com/d"),
FaviconURL::FAVICON,
favicon_base::FAVICON,
std::vector<gfx::Size>())};
TestFaviconClient client;
......
......@@ -16,6 +16,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/url_constants.h"
#include "components/bookmarks/core/browser/bookmark_model.h"
#include "components/favicon_base/favicon_types.h"
#include "content/public/browser/favicon_status.h"
#include "content/public/browser/invalidate_type.h"
#include "content/public/browser/navigation_controller.h"
......@@ -25,6 +26,7 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/favicon_url.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
......@@ -222,14 +224,40 @@ void FaviconTabHelper::DidNavigateMainFrame(
FetchFavicon(details.entry->GetURL());
}
// Returns favicon_base::IconType the given icon_type corresponds to.
// TODO(jif): Move function to /components/favicon_base/content/
// crbug.com/374281.
favicon_base::IconType ToChromeIconType(
content::FaviconURL::IconType icon_type) {
switch (icon_type) {
case content::FaviconURL::FAVICON:
return favicon_base::FAVICON;
case content::FaviconURL::TOUCH_ICON:
return favicon_base::TOUCH_ICON;
case content::FaviconURL::TOUCH_PRECOMPOSED_ICON:
return favicon_base::TOUCH_PRECOMPOSED_ICON;
case content::FaviconURL::INVALID_ICON:
return favicon_base::INVALID_ICON;
}
NOTREACHED();
return favicon_base::INVALID_ICON;
}
void FaviconTabHelper::DidUpdateFaviconURL(
const std::vector<content::FaviconURL>& candidates) {
DCHECK(!candidates.empty());
favicon_urls_ = candidates;
favicon_handler_->OnUpdateFaviconURL(candidates);
std::vector<favicon::FaviconURL> favicon_urls;
for (size_t i = 0; i < candidates.size(); i++) {
const content::FaviconURL& candidate = candidates[i];
favicon_urls.push_back(
favicon::FaviconURL(candidate.icon_url,
ToChromeIconType(candidate.icon_type),
candidate.icon_sizes));
}
favicon_handler_->OnUpdateFaviconURL(favicon_urls);
if (touch_icon_handler_.get())
touch_icon_handler_->OnUpdateFaviconURL(candidates);
touch_icon_handler_->OnUpdateFaviconURL(favicon_urls);
}
FaviconService* FaviconTabHelper::GetFaviconService() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment