diff options
author | jif@chromium.org <jif@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-17 17:20:53 +0000 |
---|---|---|
committer | jif@chromium.org <jif@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-17 17:20:53 +0000 |
commit | 7627e0b44b3807ad604dc3b66170af723ddbfd99 (patch) | |
tree | 57d154202cd77890e0eff91eb18b72777bfb40fc /chrome/browser | |
parent | ea8c56cdad5c7f8e2bf66ae7427dae786a8f82e5 (diff) | |
download | chromium_src-7627e0b44b3807ad604dc3b66170af723ddbfd99.zip chromium_src-7627e0b44b3807ad604dc3b66170af723ddbfd99.tar.gz chromium_src-7627e0b44b3807ad604dc3b66170af723ddbfd99.tar.bz2 |
Moved favicon_types to favicon_base component.
The move caused includes, DEPS, and gyp to change.
This CL also adds droger as a temporary owner to the favicon and favicon_base components.
Reasoning behind the creation of a favicon_base component:
Bookmarks and History code do not fundamentally depend on the Favicon code, so we should be able to build those components without building the Favicon code.
Deep inside the Bookmarks and History code base there's usage of certain favicon types. Those typedefs are moved to a separate component to break the dependency between the Bookmark/History components and the Favicon component.
BUG=362481
Review URL: https://codereview.chromium.org/234893002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264555 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
71 files changed, 1056 insertions, 897 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index f2bc86d..15b869b 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -18,6 +18,7 @@ include_rules = [ "+components/data_reduction_proxy", "+components/dom_distiller", "+components/domain_reliability", + "+components/favicon_base", "+components/keyed_service", "+components/language_usage_metrics", "+components/nacl/browser", diff --git a/chrome/browser/android/favicon_helper.cc b/chrome/browser/android/favicon_helper.cc index 0fb4512..f6ae96c 100644 --- a/chrome/browser/android/favicon_helper.cc +++ b/chrome/browser/android/favicon_helper.cc @@ -37,7 +37,7 @@ namespace { void OnLocalFaviconAvailable( ScopedJavaGlobalRef<jobject>* j_favicon_image_callback, - const chrome::FaviconImageResult& favicon_image_result) { + const favicon_base::FaviconImageResult& favicon_image_result) { JNIEnv* env = AttachCurrentThread(); // Convert favicon_image_result to java objects. diff --git a/chrome/browser/android/provider/chrome_browser_provider.cc b/chrome/browser/android/provider/chrome_browser_provider.cc index f59de09..dd8aecd 100644 --- a/chrome/browser/android/provider/chrome_browser_provider.cc +++ b/chrome/browser/android/provider/chrome_browser_provider.cc @@ -670,29 +670,29 @@ class BookmarkIconFetchTask : public FaviconServiceTask { cancelable_consumer, cancelable_tracker) {} - chrome::FaviconBitmapResult Run(const GURL& url) { + favicon_base::FaviconBitmapResult Run(const GURL& url) { RunAsyncRequestOnUIThreadBlocking( base::Bind(&FaviconService::GetRawFaviconForURL, base::Unretained(service()), FaviconService::FaviconForURLParams( url, - chrome::FAVICON | chrome::TOUCH_ICON, + favicon_base::FAVICON | favicon_base::TOUCH_ICON, gfx::kFaviconSize), ResourceBundle::GetSharedInstance().GetMaxScaleFactor(), - base::Bind( - &BookmarkIconFetchTask::OnFaviconRetrieved, - base::Unretained(this)), + base::Bind(&BookmarkIconFetchTask::OnFaviconRetrieved, + base::Unretained(this)), cancelable_tracker())); return result_; } private: - void OnFaviconRetrieved(const chrome::FaviconBitmapResult& bitmap_result) { + void OnFaviconRetrieved( + const favicon_base::FaviconBitmapResult& bitmap_result) { result_ = bitmap_result; RequestCompleted(); } - chrome::FaviconBitmapResult result_; + favicon_base::FaviconBitmapResult result_; DISALLOW_COPY_AND_ASSIGN(BookmarkIconFetchTask); }; @@ -1548,7 +1548,7 @@ ScopedJavaLocalRef<jbyteArray> ChromeBrowserProvider::GetFaviconOrTouchIcon( profile_, &favicon_consumer_, &cancelable_task_tracker_); - chrome::FaviconBitmapResult bitmap_result = favicon_task.Run(url); + favicon_base::FaviconBitmapResult bitmap_result = favicon_task.Run(url); if (!bitmap_result.is_valid() || !bitmap_result.bitmap_data.get()) return ScopedJavaLocalRef<jbyteArray>(); diff --git a/chrome/browser/android/shortcut_helper.cc b/chrome/browser/android/shortcut_helper.cc index e6189d8..4539402 100644 --- a/chrome/browser/android/shortcut_helper.cc +++ b/chrome/browser/android/shortcut_helper.cc @@ -75,8 +75,9 @@ void ShortcutBuilder::OnDidRetrieveWebappInformation( // TODO(dfalcantara): Try combining with the new BookmarksHandler once its // rewrite is further along. std::vector<int> icon_types; - icon_types.push_back(chrome::FAVICON); - icon_types.push_back(chrome::TOUCH_PRECOMPOSED_ICON | chrome::TOUCH_ICON); + icon_types.push_back(favicon_base::FAVICON); + icon_types.push_back(favicon_base::TOUCH_PRECOMPOSED_ICON | + favicon_base::TOUCH_ICON); FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( profile, Profile::EXPLICIT_ACCESS); @@ -91,7 +92,7 @@ void ShortcutBuilder::OnDidRetrieveWebappInformation( } void ShortcutBuilder::FinishAddingShortcut( - const chrome::FaviconBitmapResult& bitmap_result) { + const favicon_base::FaviconBitmapResult& bitmap_result) { base::WorkerPool::PostTask( FROM_HERE, base::Bind(&ShortcutHelper::AddShortcutInBackground, @@ -139,7 +140,7 @@ void ShortcutHelper::AddShortcutInBackground( const GURL& url, const base::string16& title, ShortcutBuilder::ShortcutType shortcut_type, - const chrome::FaviconBitmapResult& bitmap_result) { + const favicon_base::FaviconBitmapResult& bitmap_result) { DCHECK(base::WorkerPool::RunsTasksOnCurrentThread()); // Grab the average color from the bitmap. diff --git a/chrome/browser/android/shortcut_helper.h b/chrome/browser/android/shortcut_helper.h index ad0183d..4177228 100644 --- a/chrome/browser/android/shortcut_helper.h +++ b/chrome/browser/android/shortcut_helper.h @@ -12,9 +12,9 @@ #include "chrome/browser/android/tab_android.h" #include "content/public/browser/web_contents_observer.h" -namespace chrome { +namespace favicon_base { struct FaviconBitmapResult; -} // namespace chrome +} // namespace favicon_base namespace content { class WebContents; @@ -52,7 +52,8 @@ class ShortcutBuilder : public content::WebContentsObserver { bool is_apple_mobile_webapp_capable, const GURL& expected_url); - void FinishAddingShortcut(const chrome::FaviconBitmapResult& bitmap_result); + void FinishAddingShortcut( + const favicon_base::FaviconBitmapResult& bitmap_result); // WebContentsObserver virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; @@ -84,7 +85,7 @@ class ShortcutHelper { const GURL& url, const base::string16& title, ShortcutBuilder::ShortcutType shortcut_type, - const chrome::FaviconBitmapResult& bitmap_result); + const favicon_base::FaviconBitmapResult& bitmap_result); // Registers JNI hooks. static bool RegisterShortcutHelper(JNIEnv* env); diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc index 5e075af..e3a4f19 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer.cc @@ -21,7 +21,7 @@ #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/favicon/favicon_service.h" #include "chrome/browser/favicon/favicon_service_factory.h" -#include "chrome/common/favicon/favicon_types.h" +#include "components/favicon_base/favicon_types.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_source.h" #include "grit/generated_resources.h" @@ -460,7 +460,7 @@ bool BookmarkFaviconFetcher::FetchNextFavicon() { profile_, Profile::EXPLICIT_ACCESS); favicon_service->GetRawFaviconForURL( FaviconService::FaviconForURLParams( - GURL(url), chrome::FAVICON, gfx::kFaviconSize), + GURL(url), favicon_base::FAVICON, gfx::kFaviconSize), ui::SCALE_FACTOR_100P, base::Bind(&BookmarkFaviconFetcher::OnFaviconDataAvailable, base::Unretained(this)), @@ -474,7 +474,7 @@ bool BookmarkFaviconFetcher::FetchNextFavicon() { } void BookmarkFaviconFetcher::OnFaviconDataAvailable( - const chrome::FaviconBitmapResult& bitmap_result) { + const favicon_base::FaviconBitmapResult& bitmap_result) { GURL url; if (!bookmark_urls_.empty()) { url = GURL(bookmark_urls_.front()); diff --git a/chrome/browser/bookmarks/bookmark_html_writer.h b/chrome/browser/bookmarks/bookmark_html_writer.h index a049551..bdb638c 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer.h +++ b/chrome/browser/bookmarks/bookmark_html_writer.h @@ -13,6 +13,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/ref_counted_memory.h" #include "base/task/cancelable_task_tracker.h" +#include "components/favicon_base/favicon_types.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" @@ -69,7 +70,8 @@ class BookmarkFaviconFetcher: public content::NotificationObserver { // Favicon fetch callback. After all favicons are fetched executes // html output on the file thread. - void OnFaviconDataAvailable(const chrome::FaviconBitmapResult& bitmap_result); + void OnFaviconDataAvailable( + const favicon_base::FaviconBitmapResult& bitmap_result); // The Profile object used for accessing FaviconService, bookmarks model. Profile* profile_; diff --git a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc index c2331be..376f8a6 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc @@ -202,10 +202,11 @@ TEST_F(BookmarkHTMLWriterTest, Test) { model->AddURLWithCreationTime(f1, 0, url1_title, url1, t1); HistoryServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS)-> AddPage(url1, base::Time::Now(), history::SOURCE_BROWSED); - FaviconServiceFactory::GetForProfile( - &profile, Profile::EXPLICIT_ACCESS)->SetFavicons( - url1, url1_favicon, chrome::FAVICON, - gfx::Image::CreateFrom1xBitmap(bitmap)); + FaviconServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS) + ->SetFavicons(url1, + url1_favicon, + favicon_base::FAVICON, + gfx::Image::CreateFrom1xBitmap(bitmap)); const BookmarkNode* f2 = model->AddFolder(f1, 1, f2_title); model->AddURLWithCreationTime(f2, 0, url2_title, url2, t2); model->AddURLWithCreationTime(model->bookmark_bar_node(), @@ -230,9 +231,8 @@ TEST_F(BookmarkHTMLWriterTest, Test) { run_loop.Run(); // Clear favicon so that it would be read from file. - FaviconServiceFactory::GetForProfile( - &profile, Profile::EXPLICIT_ACCESS)->SetFavicons( - url1, url1_favicon, chrome::FAVICON, gfx::Image()); + FaviconServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS) + ->SetFavicons(url1, url1_favicon, favicon_base::FAVICON, gfx::Image()); // Read the bookmarks back in. std::vector<ImportedBookmarkEntry> parsed_bookmarks; diff --git a/chrome/browser/bookmarks/bookmark_model.cc b/chrome/browser/bookmarks/bookmark_model.cc index afbe628..cdd91f5 100644 --- a/chrome/browser/bookmarks/bookmark_model.cc +++ b/chrome/browser/bookmarks/bookmark_model.cc @@ -23,8 +23,8 @@ #include "chrome/browser/history/history_service.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/common/favicon/favicon_types.h" #include "components/bookmarks/core/browser/bookmark_title_match.h" +#include "components/favicon_base/favicon_types.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" #include "grit/generated_resources.h" @@ -871,7 +871,7 @@ BookmarkPermanentNode* BookmarkModel::CreatePermanentNode( void BookmarkModel::OnFaviconDataAvailable( BookmarkNode* node, - const chrome::FaviconImageResult& image_result) { + const favicon_base::FaviconImageResult& image_result) { DCHECK(node); node->set_favicon_load_task_id(base::CancelableTaskTracker::kBadTaskId); node->set_favicon_state(BookmarkNode::LOADED_FAVICON); @@ -894,7 +894,7 @@ void BookmarkModel::LoadFavicon(BookmarkNode* node) { base::CancelableTaskTracker::TaskId taskId = favicon_service->GetFaviconImageForURL( FaviconService::FaviconForURLParams( - node->url(), chrome::FAVICON, gfx::kFaviconSize), + node->url(), favicon_base::FAVICON, gfx::kFaviconSize), base::Bind(&BookmarkModel::OnFaviconDataAvailable, base::Unretained(this), node), diff --git a/chrome/browser/bookmarks/bookmark_model.h b/chrome/browser/bookmarks/bookmark_model.h index ba85815..70ca10a 100644 --- a/chrome/browser/bookmarks/bookmark_model.h +++ b/chrome/browser/bookmarks/bookmark_model.h @@ -20,6 +20,7 @@ #include "base/task/cancelable_task_tracker.h" #include "chrome/browser/bookmarks/bookmark_service.h" #include "components/bookmarks/core/browser/bookmark_node.h" +#include "components/favicon_base/favicon_types.h" #include "components/keyed_service/core/keyed_service.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" @@ -317,8 +318,9 @@ class BookmarkModel : public content::NotificationObserver, // Notification that a favicon has finished loading. If we can decode the // favicon, FaviconLoaded is invoked. - void OnFaviconDataAvailable(BookmarkNode* node, - const chrome::FaviconImageResult& image_result); + void OnFaviconDataAvailable( + BookmarkNode* node, + const favicon_base::FaviconImageResult& image_result); // Invoked from the node to load the favicon. Requests the favicon from the // favicon service. diff --git a/chrome/browser/extensions/extension_web_ui.cc b/chrome/browser/extensions/extension_web_ui.cc index 2510e45..9ee2e90 100644 --- a/chrome/browser/extensions/extension_web_ui.cc +++ b/chrome/browser/extensions/extension_web_ui.cc @@ -89,8 +89,8 @@ void UnregisterAndReplaceOverrideForWebContents(const std::string& page, void RunFaviconCallbackAsync( const FaviconService::FaviconResultsCallback& callback, const gfx::Image& image) { - std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results = - new std::vector<chrome::FaviconBitmapResult>(); + std::vector<favicon_base::FaviconBitmapResult>* favicon_bitmap_results = + new std::vector<favicon_base::FaviconBitmapResult>(); const std::vector<gfx::ImageSkiaRep>& image_reps = image.AsImageSkia().image_reps(); @@ -101,12 +101,12 @@ void RunFaviconCallbackAsync( if (gfx::PNGCodec::EncodeBGRASkBitmap(image_rep.sk_bitmap(), false, &bitmap_data->data())) { - chrome::FaviconBitmapResult bitmap_result; + favicon_base::FaviconBitmapResult bitmap_result; bitmap_result.bitmap_data = bitmap_data; bitmap_result.pixel_size = gfx::Size(image_rep.pixel_width(), image_rep.pixel_height()); // Leave |bitmap_result|'s icon URL as the default of GURL(). - bitmap_result.icon_type = chrome::FAVICON; + bitmap_result.icon_type = favicon_base::FAVICON; favicon_bitmap_results->push_back(bitmap_result); } else { diff --git a/chrome/browser/favicon/favicon_handler.cc b/chrome/browser/favicon/favicon_handler.cc index f797780..e3b2921 100644 --- a/chrome/browser/favicon/favicon_handler.cc +++ b/chrome/browser/favicon/favicon_handler.cc @@ -33,36 +33,36 @@ namespace { // the apple touch icon for iPad. const int kTouchIconSize = 144; -// Returns chrome::IconType the given icon_type corresponds to. -chrome::IconType ToChromeIconType(FaviconURL::IconType icon_type) { +// 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 chrome::FAVICON; + return favicon_base::FAVICON; case FaviconURL::TOUCH_ICON: - return chrome::TOUCH_ICON; + return favicon_base::TOUCH_ICON; case FaviconURL::TOUCH_PRECOMPOSED_ICON: - return chrome::TOUCH_PRECOMPOSED_ICON; + return favicon_base::TOUCH_PRECOMPOSED_ICON; case FaviconURL::INVALID_ICON: - return chrome::INVALID_ICON; + return favicon_base::INVALID_ICON; } NOTREACHED(); - return chrome::INVALID_ICON; + 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(chrome::IconType icon_type) { +int GetMaximalIconSize(favicon_base::IconType icon_type) { switch (icon_type) { - case chrome::FAVICON: + case favicon_base::FAVICON: #if defined(OS_ANDROID) return 192; #else return gfx::ImageSkia::GetMaxSupportedScale() * gfx::kFaviconSize; #endif - case chrome::TOUCH_ICON: - case chrome::TOUCH_PRECOMPOSED_ICON: + case favicon_base::TOUCH_ICON: + case favicon_base::TOUCH_PRECOMPOSED_ICON: return kTouchIconSize; - case chrome::INVALID_ICON: + case favicon_base::INVALID_ICON: return 0; } NOTREACHED(); @@ -71,7 +71,7 @@ int GetMaximalIconSize(chrome::IconType icon_type) { bool DoUrlAndIconMatch(const FaviconURL& favicon_url, const GURL& url, - chrome::IconType icon_type) { + favicon_base::IconType icon_type) { return favicon_url.icon_url == url && ToChromeIconType(favicon_url.icon_type) == icon_type; } @@ -81,11 +81,12 @@ bool DoUrlAndIconMatch(const FaviconURL& favicon_url, // Returns false if |bitmap_results| is empty. bool DoUrlsAndIconsMatch( const FaviconURL& favicon_url, - const std::vector<chrome::FaviconBitmapResult>& bitmap_results) { + const std::vector<favicon_base::FaviconBitmapResult>& bitmap_results) { if (bitmap_results.empty()) return false; - const chrome::IconType icon_type = ToChromeIconType(favicon_url.icon_type); + const favicon_base::IconType icon_type = + ToChromeIconType(favicon_url.icon_type); for (size_t i = 0; i < bitmap_results.size(); ++i) { if (favicon_url.icon_url != bitmap_results[i].icon_url || @@ -107,12 +108,12 @@ bool UrlMatches(const GURL& gurl_a, const GURL& gurl_b) { } // Return true if |bitmap_result| is expired. -bool IsExpired(const chrome::FaviconBitmapResult& bitmap_result) { +bool IsExpired(const favicon_base::FaviconBitmapResult& bitmap_result) { return bitmap_result.expired; } // Return true if |bitmap_result| is valid. -bool IsValid(const chrome::FaviconBitmapResult& bitmap_result) { +bool IsValid(const favicon_base::FaviconBitmapResult& bitmap_result) { return bitmap_result.is_valid(); } @@ -121,9 +122,9 @@ bool IsValid(const chrome::FaviconBitmapResult& bitmap_result) { // the scale factors in FaviconUtil::GetFaviconScaleFactors(). bool HasExpiredOrIncompleteResult( int desired_size_in_dip, - const std::vector<chrome::FaviconBitmapResult>& bitmap_results) { + const std::vector<favicon_base::FaviconBitmapResult>& bitmap_results) { // Check if at least one of the bitmaps is expired. - std::vector<chrome::FaviconBitmapResult>::const_iterator it = + std::vector<favicon_base::FaviconBitmapResult>::const_iterator it = std::find_if(bitmap_results.begin(), bitmap_results.end(), IsExpired); if (it != bitmap_results.end()) return true; @@ -158,7 +159,7 @@ bool HasExpiredOrIncompleteResult( // Returns true if at least one of |bitmap_results| is valid. bool HasValidResult( - const std::vector<chrome::FaviconBitmapResult>& bitmap_results) { + const std::vector<favicon_base::FaviconBitmapResult>& bitmap_results) { return std::find_if(bitmap_results.begin(), bitmap_results.end(), IsValid) != bitmap_results.end(); } @@ -168,8 +169,7 @@ bool HasValidResult( //////////////////////////////////////////////////////////////////////////////// FaviconHandler::DownloadRequest::DownloadRequest() - : icon_type(chrome::INVALID_ICON) { -} + : icon_type(favicon_base::INVALID_ICON) {} FaviconHandler::DownloadRequest::~DownloadRequest() { } @@ -177,18 +177,13 @@ FaviconHandler::DownloadRequest::~DownloadRequest() { FaviconHandler::DownloadRequest::DownloadRequest( const GURL& url, const GURL& image_url, - chrome::IconType icon_type) - : url(url), - image_url(image_url), - icon_type(icon_type) { -} + favicon_base::IconType icon_type) + : url(url), image_url(image_url), icon_type(icon_type) {} //////////////////////////////////////////////////////////////////////////////// FaviconHandler::FaviconCandidate::FaviconCandidate() - : score(0), - icon_type(chrome::INVALID_ICON) { -} + : score(0), icon_type(favicon_base::INVALID_ICON) {} FaviconHandler::FaviconCandidate::~FaviconCandidate() { } @@ -198,13 +193,12 @@ FaviconHandler::FaviconCandidate::FaviconCandidate( const GURL& image_url, const gfx::Image& image, float score, - chrome::IconType icon_type) + favicon_base::IconType icon_type) : url(url), image_url(image_url), image(image), score(score), - icon_type(icon_type) { -} + icon_type(icon_type) {} //////////////////////////////////////////////////////////////////////////////// @@ -215,8 +209,9 @@ FaviconHandler::FaviconHandler(Profile* profile, : got_favicon_from_history_(false), favicon_expired_or_incomplete_(false), icon_types_(icon_type == FAVICON - ? chrome::FAVICON - : chrome::TOUCH_ICON | chrome::TOUCH_PRECOMPOSED_ICON), + ? favicon_base::FAVICON + : favicon_base::TOUCH_ICON | + favicon_base::TOUCH_PRECOMPOSED_ICON), profile_(profile), client_(client), delegate_(delegate) { @@ -253,10 +248,10 @@ bool FaviconHandler::UpdateFaviconCandidate(const GURL& url, const GURL& image_url, const gfx::Image& image, float score, - chrome::IconType icon_type) { + favicon_base::IconType icon_type) { const bool exact_match = score == 1 || preferred_icon_size() == 0; if (exact_match || - best_favicon_candidate_.icon_type == chrome::INVALID_ICON || + best_favicon_candidate_.icon_type == favicon_base::INVALID_ICON || score > best_favicon_candidate_.score) { best_favicon_candidate_ = FaviconCandidate( url, image_url, image, score, icon_type); @@ -264,15 +259,14 @@ bool FaviconHandler::UpdateFaviconCandidate(const GURL& url, return exact_match; } -void FaviconHandler::SetFavicon( - const GURL& url, - const GURL& icon_url, - const gfx::Image& image, - chrome::IconType icon_type) { +void FaviconHandler::SetFavicon(const GURL& url, + const GURL& icon_url, + const gfx::Image& image, + favicon_base::IconType icon_type) { if (client_->GetFaviconService() && ShouldSaveFavicon(url)) SetHistoryFavicons(url, icon_url, icon_type, image); - if (UrlMatches(url, url_) && icon_type == chrome::FAVICON) { + if (UrlMatches(url, url_) && icon_type == favicon_base::FAVICON) { NavigationEntry* entry = GetEntry(); if (entry) SetFaviconOnNavigationEntry(entry, icon_url, image); @@ -281,7 +275,8 @@ void FaviconHandler::SetFavicon( void FaviconHandler::SetFaviconOnNavigationEntry( NavigationEntry* entry, - const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results) { + const std::vector<favicon_base::FaviconBitmapResult>& + favicon_bitmap_results) { gfx::Image resized_image = FaviconUtil::SelectFaviconFramesFromPNGs( favicon_bitmap_results, FaviconUtil::GetFaviconScaleFactors(), @@ -344,8 +339,9 @@ void FaviconHandler::ProcessCurrentUrl() { if (current_candidate()->icon_type == FaviconURL::FAVICON) { if (!favicon_expired_or_incomplete_ && entry->GetFavicon().valid && - DoUrlAndIconMatch(*current_candidate(), entry->GetFavicon().url, - chrome::FAVICON)) + DoUrlAndIconMatch(*current_candidate(), + entry->GetFavicon().url, + favicon_base::FAVICON)) return; } else if (!favicon_expired_or_incomplete_ && got_favicon_from_history_ && HasValidResult(history_results_) && @@ -393,7 +389,8 @@ void FaviconHandler::OnDidDownloadFavicon( // Remove the first member of image_urls_ and process the remaining. image_urls_.pop_front(); ProcessCurrentUrl(); - } else if (best_favicon_candidate_.icon_type != chrome::INVALID_ICON) { + } else if (best_favicon_candidate_.icon_type != + favicon_base::INVALID_ICON) { // No more icons to request, set the favicon from the candidate. SetFavicon(best_favicon_candidate_.url, best_favicon_candidate_.image_url, @@ -429,7 +426,7 @@ int FaviconHandler::DownloadFavicon(const GURL& image_url, void FaviconHandler::UpdateFaviconMappingAndFetch( const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, const FaviconService::FaviconResultsCallback& callback, base::CancelableTaskTracker* tracker) { // TODO(pkotwicz): pass in all of |image_urls_| to @@ -442,7 +439,7 @@ void FaviconHandler::UpdateFaviconMappingAndFetch( void FaviconHandler::GetFaviconFromFaviconService( const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, const FaviconService::FaviconResultsCallback& callback, base::CancelableTaskTracker* tracker) { client_->GetFaviconService()->GetFavicon( @@ -463,7 +460,7 @@ void FaviconHandler::GetFaviconForURLFromFaviconService( void FaviconHandler::SetHistoryFavicons(const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, const gfx::Image& image) { client_->GetFaviconService()->SetFavicons( page_url, icon_url, icon_type, image); @@ -482,7 +479,8 @@ void FaviconHandler::NotifyFaviconUpdated(bool icon_url_changed) { } void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService( - const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results) { + const std::vector<favicon_base::FaviconBitmapResult>& + favicon_bitmap_results) { NavigationEntry* entry = GetEntry(); if (!entry) return; @@ -494,7 +492,7 @@ void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService( favicon_expired_or_incomplete_ = has_results && HasExpiredOrIncompleteResult( preferred_icon_size(), favicon_bitmap_results); - if (has_results && icon_types_ == chrome::FAVICON && + if (has_results && icon_types_ == favicon_base::FAVICON && !entry->GetFavicon().valid && (!current_candidate() || DoUrlsAndIconsMatch(*current_candidate(), favicon_bitmap_results))) { @@ -537,7 +535,7 @@ void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService( void FaviconHandler::DownloadFaviconOrAskFaviconService( const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type) { + favicon_base::IconType icon_type) { 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); @@ -564,8 +562,8 @@ void FaviconHandler::DownloadFaviconOrAskFaviconService( } } -void FaviconHandler::OnFaviconData( - const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results) { +void FaviconHandler::OnFaviconData(const std::vector< + favicon_base::FaviconBitmapResult>& favicon_bitmap_results) { NavigationEntry* entry = GetEntry(); if (!entry) return; @@ -574,7 +572,7 @@ void FaviconHandler::OnFaviconData( bool has_expired_or_incomplete_result = HasExpiredOrIncompleteResult( preferred_icon_size(), favicon_bitmap_results); - if (has_results && icon_types_ == chrome::FAVICON) { + if (has_results && icon_types_ == favicon_base::FAVICON) { if (HasValidResult(favicon_bitmap_results)) { // There is a favicon, set it now. If expired we'll download the current // one again, but at least the user will get some icon instead of the @@ -583,8 +581,8 @@ void FaviconHandler::OnFaviconData( } if (has_expired_or_incomplete_result) { // The favicon is out of date. Request the current one. - ScheduleDownload(entry->GetURL(), entry->GetFavicon().url, - chrome::FAVICON); + ScheduleDownload( + entry->GetURL(), entry->GetFavicon().url, favicon_base::FAVICON); } } else if (current_candidate() && (!has_results || has_expired_or_incomplete_result || @@ -597,10 +595,9 @@ void FaviconHandler::OnFaviconData( history_results_ = favicon_bitmap_results; } -int FaviconHandler::ScheduleDownload( - const GURL& url, - const GURL& image_url, - chrome::IconType icon_type) { +int FaviconHandler::ScheduleDownload(const GURL& url, + const GURL& image_url, + favicon_base::IconType icon_type) { // A max bitmap size is specified to avoid receiving huge bitmaps in // OnDidDownloadFavicon(). See FaviconHandlerDelegate::StartDownload() // for more details about the max bitmap size. diff --git a/chrome/browser/favicon/favicon_handler.h b/chrome/browser/favicon/favicon_handler.h index 94d3c5d..da7bbc4 100644 --- a/chrome/browser/favicon/favicon_handler.h +++ b/chrome/browser/favicon/favicon_handler.h @@ -134,13 +134,13 @@ class FaviconHandler { virtual void UpdateFaviconMappingAndFetch( const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, const FaviconService::FaviconResultsCallback& callback, base::CancelableTaskTracker* tracker); virtual void GetFaviconFromFaviconService( const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, const FaviconService::FaviconResultsCallback& callback, base::CancelableTaskTracker* tracker); @@ -152,7 +152,7 @@ class FaviconHandler { virtual void SetHistoryFavicons(const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, const gfx::Image& image); // Returns true if the favicon should be saved. @@ -173,11 +173,11 @@ class FaviconHandler { DownloadRequest(const GURL& url, const GURL& image_url, - chrome::IconType icon_type); + favicon_base::IconType icon_type); GURL url; GURL image_url; - chrome::IconType icon_type; + favicon_base::IconType icon_type; }; // Used to track a candidate for the favicon. @@ -189,54 +189,55 @@ class FaviconHandler { const GURL& image_url, const gfx::Image& image, float score, - chrome::IconType icon_type); + favicon_base::IconType icon_type); GURL url; GURL image_url; gfx::Image image; float score; - chrome::IconType icon_type; + favicon_base::IconType icon_type; }; // See description above class for details. - void OnFaviconDataForInitialURLFromFaviconService( - const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results); + void OnFaviconDataForInitialURLFromFaviconService(const std::vector< + favicon_base::FaviconBitmapResult>& favicon_bitmap_results); // If the favicon has expired, asks the renderer to download the favicon. // Otherwise asks history to update the mapping between page url and icon // url with a callback to OnFaviconData when done. void DownloadFaviconOrAskFaviconService(const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type); + favicon_base::IconType icon_type); // See description above class for details. - void OnFaviconData( - const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results); + void OnFaviconData(const std::vector<favicon_base::FaviconBitmapResult>& + favicon_bitmap_results); // Schedules a download for the specified entry. This adds the request to // download_requests_. int ScheduleDownload(const GURL& url, const GURL& image_url, - chrome::IconType icon_type); + favicon_base::IconType icon_type); // Updates |favicon_candidate_| and returns true if it is an exact match. bool UpdateFaviconCandidate(const GURL& url, const GURL& image_url, const gfx::Image& image, float score, - chrome::IconType icon_type); + favicon_base::IconType icon_type); // Sets the image data for the favicon. void SetFavicon(const GURL& url, const GURL& icon_url, const gfx::Image& image, - chrome::IconType icon_type); + favicon_base::IconType icon_type); // Sets the favicon's data on the NavigationEntry. // If the WebContents has a delegate, it is invalidated (INVALIDATE_TYPE_TAB). void SetFaviconOnNavigationEntry( content::NavigationEntry* entry, - const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results); + const std::vector<favicon_base::FaviconBitmapResult>& + favicon_bitmap_results); void SetFaviconOnNavigationEntry(content::NavigationEntry* entry, const GURL& icon_url, const gfx::Image& image); @@ -252,7 +253,7 @@ class FaviconHandler { #if defined(OS_ANDROID) return 0; #else - return icon_types_ == chrome::FAVICON ? gfx::kFaviconSize : 0; + return icon_types_ == favicon_base::FAVICON ? gfx::kFaviconSize : 0; #endif } @@ -282,7 +283,7 @@ class FaviconHandler { std::deque<content::FaviconURL> image_urls_; // The FaviconBitmapResults from history. - std::vector<chrome::FaviconBitmapResult> history_results_; + std::vector<favicon_base::FaviconBitmapResult> history_results_; // The Profile associated with this handler. Profile* profile_; diff --git a/chrome/browser/favicon/favicon_handler_unittest.cc b/chrome/browser/favicon/favicon_handler_unittest.cc index edc83dc..82b63b2 100644 --- a/chrome/browser/favicon/favicon_handler_unittest.cc +++ b/chrome/browser/favicon/favicon_handler_unittest.cc @@ -49,12 +49,12 @@ void FillBitmap(int w, int h, std::vector<unsigned char>* output) { void SetFaviconBitmapResult( const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, bool expired, - std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results) { + std::vector<favicon_base::FaviconBitmapResult>* favicon_bitmap_results) { scoped_refptr<base::RefCountedBytes> data(new base::RefCountedBytes()); FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); - chrome::FaviconBitmapResult bitmap_result; + favicon_base::FaviconBitmapResult bitmap_result; bitmap_result.expired = expired; bitmap_result.bitmap_data = data; // Use a pixel size other than (0,0) as (0,0) has a special meaning. @@ -67,8 +67,10 @@ void SetFaviconBitmapResult( void SetFaviconBitmapResult( const GURL& icon_url, - std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results) { - SetFaviconBitmapResult(icon_url, chrome::FAVICON, false /* expired */, + std::vector<favicon_base::FaviconBitmapResult>* favicon_bitmap_results) { + SetFaviconBitmapResult(icon_url, + favicon_base::FAVICON, + false /* expired */, favicon_bitmap_results); } @@ -158,7 +160,7 @@ class HistoryRequestHandler { const GURL icon_url_; const int icon_type_; const std::vector<unsigned char> bitmap_data_; - std::vector<chrome::FaviconBitmapResult> history_results_; + std::vector<favicon_base::FaviconBitmapResult> history_results_; FaviconService::FaviconResultsCallback callback_; private: @@ -270,7 +272,7 @@ class TestFaviconHandler : public FaviconHandler { virtual void UpdateFaviconMappingAndFetch( const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, const FaviconService::FaviconResultsCallback& callback, base::CancelableTaskTracker* tracker) OVERRIDE { history_handler_.reset(new HistoryRequestHandler(page_url, icon_url, @@ -279,7 +281,7 @@ class TestFaviconHandler : public FaviconHandler { virtual void GetFaviconFromFaviconService( const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, const FaviconService::FaviconResultsCallback& callback, base::CancelableTaskTracker* tracker) OVERRIDE { history_handler_.reset(new HistoryRequestHandler(GURL(), icon_url, @@ -305,7 +307,7 @@ class TestFaviconHandler : public FaviconHandler { virtual void SetHistoryFavicons(const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, const gfx::Image& image) OVERRIDE { scoped_refptr<base::RefCountedMemory> bytes = image.As1xPNGBytes(); std::vector<unsigned char> bitmap_data(bytes->front(), @@ -458,7 +460,7 @@ TEST_F(FaviconHandlerTest, GetFaviconFromHistory) { ASSERT_TRUE(history_handler); EXPECT_EQ(page_url, history_handler->page_url_); EXPECT_EQ(GURL(), history_handler->icon_url_); - EXPECT_EQ(chrome::FAVICON, history_handler->icon_type_); + EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); SetFaviconBitmapResult(icon_url, &history_handler->history_results_); @@ -501,10 +503,12 @@ TEST_F(FaviconHandlerTest, DownloadFavicon) { ASSERT_TRUE(history_handler); EXPECT_EQ(page_url, history_handler->page_url_); EXPECT_EQ(GURL(), history_handler->icon_url_); - EXPECT_EQ(chrome::FAVICON, history_handler->icon_type_); + EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); // Set icon data expired - SetFaviconBitmapResult(icon_url, chrome::FAVICON, true /* expired */, + SetFaviconBitmapResult(icon_url, + favicon_base::FAVICON, + true /* expired */, &history_handler->history_results_); // Send history response. history_handler->InvokeCallback(); @@ -571,7 +575,7 @@ TEST_F(FaviconHandlerTest, UpdateAndDownloadFavicon) { ASSERT_TRUE(history_handler); EXPECT_EQ(page_url, history_handler->page_url_); EXPECT_EQ(GURL(), history_handler->icon_url_); - EXPECT_EQ(chrome::FAVICON, history_handler->icon_type_); + EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); // Set valid icon data. SetFaviconBitmapResult(icon_url, &history_handler->history_results_); @@ -655,15 +659,15 @@ TEST_F(FaviconHandlerTest, FaviconInHistoryInvalid) { ASSERT_TRUE(history_handler); EXPECT_EQ(page_url, history_handler->page_url_); EXPECT_EQ(GURL(), history_handler->icon_url_); - EXPECT_EQ(chrome::FAVICON, history_handler->icon_type_); + EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); // Set non empty but invalid data. - chrome::FaviconBitmapResult bitmap_result; + favicon_base::FaviconBitmapResult bitmap_result; bitmap_result.expired = false; // Empty bitmap data is invalid. bitmap_result.bitmap_data = new base::RefCountedBytes(); bitmap_result.pixel_size = gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize); - bitmap_result.icon_type = chrome::FAVICON; + bitmap_result.icon_type = favicon_base::FAVICON; bitmap_result.icon_url = icon_url; history_handler->history_results_.clear(); history_handler->history_results_.push_back(bitmap_result); @@ -730,7 +734,7 @@ TEST_F(FaviconHandlerTest, UpdateFavicon) { ASSERT_TRUE(history_handler); EXPECT_EQ(page_url, history_handler->page_url_); EXPECT_EQ(GURL(), history_handler->icon_url_); - EXPECT_EQ(chrome::FAVICON, history_handler->icon_type_); + EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); SetFaviconBitmapResult(icon_url, &history_handler->history_results_); @@ -794,7 +798,7 @@ TEST_F(FaviconHandlerTest, Download2ndFaviconURLCandidate) { ASSERT_TRUE(history_handler); EXPECT_EQ(page_url, history_handler->page_url_); EXPECT_EQ(GURL(), history_handler->icon_url_); - EXPECT_EQ(chrome::TOUCH_PRECOMPOSED_ICON | chrome::TOUCH_ICON, + EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON | favicon_base::TOUCH_ICON, history_handler->icon_type_); // Icon not found. @@ -868,8 +872,10 @@ TEST_F(FaviconHandlerTest, Download2ndFaviconURLCandidate) { download_handler->Reset(); // Simulates getting a expired icon from history. - SetFaviconBitmapResult(new_icon_url, chrome::TOUCH_ICON, - true /* expired */, &history_handler->history_results_); + SetFaviconBitmapResult(new_icon_url, + favicon_base::TOUCH_ICON, + true /* expired */, + &history_handler->history_results_); history_handler->InvokeCallback(); // Verify the download request. @@ -908,7 +914,7 @@ TEST_F(FaviconHandlerTest, UpdateDuringDownloading) { ASSERT_TRUE(history_handler); EXPECT_EQ(page_url, history_handler->page_url_); EXPECT_EQ(GURL(), history_handler->icon_url_); - EXPECT_EQ(chrome::TOUCH_PRECOMPOSED_ICON | chrome::TOUCH_ICON, + EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON | favicon_base::TOUCH_ICON, history_handler->icon_type_); // Icon not found. @@ -993,10 +999,12 @@ TEST_F(FaviconHandlerTest, UpdateDuringDownloading) { // Simulates getting the icon from history. scoped_ptr<HistoryRequestHandler> handler; - handler.reset(new HistoryRequestHandler(page_url, latest_icon_url, - chrome::TOUCH_ICON, callback)); - SetFaviconBitmapResult(latest_icon_url, chrome::TOUCH_ICON, - false /* expired */, &handler->history_results_); + handler.reset(new HistoryRequestHandler( + page_url, latest_icon_url, favicon_base::TOUCH_ICON, callback)); + SetFaviconBitmapResult(latest_icon_url, + favicon_base::TOUCH_ICON, + false /* expired */, + &handler->history_results_); handler->InvokeCallback(); // No download request. diff --git a/chrome/browser/favicon/favicon_service.cc b/chrome/browser/favicon/favicon_service.cc index 9afc75f..8587a02 100644 --- a/chrome/browser/favicon/favicon_service.cc +++ b/chrome/browser/favicon/favicon_service.cc @@ -12,9 +12,9 @@ #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/select_favicon_frames.h" #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" -#include "chrome/common/favicon/favicon_types.h" #include "chrome/common/importer/imported_favicon_usage.h" #include "chrome/common/url_constants.h" +#include "components/favicon_base/favicon_types.h" #include "extensions/common/constants.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/codec/png_codec.h" @@ -28,7 +28,7 @@ namespace { void CancelOrRunFaviconResultsCallback( const base::CancelableTaskTracker::IsCanceledCallback& is_canceled, const FaviconService::FaviconResultsCallback& callback, - const std::vector<chrome::FaviconBitmapResult>& results) { + const std::vector<favicon_base::FaviconBitmapResult>& results) { if (is_canceled.Run()) return; callback.Run(results); @@ -42,7 +42,7 @@ base::CancelableTaskTracker::TaskId RunWithEmptyResultAsync( return tracker->PostTask( base::MessageLoopProxy::current().get(), FROM_HERE, - Bind(callback, std::vector<chrome::FaviconBitmapResult>())); + Bind(callback, std::vector<favicon_base::FaviconBitmapResult>())); } // Return the TaskId to retreive the favicon from chrome specific URL. @@ -73,13 +73,13 @@ FaviconService::FaviconService(Profile* profile) // static void FaviconService::FaviconResultsCallbackRunner( const FaviconResultsCallback& callback, - const std::vector<chrome::FaviconBitmapResult>* results) { + const std::vector<favicon_base::FaviconBitmapResult>* results) { callback.Run(*results); } base::CancelableTaskTracker::TaskId FaviconService::GetFaviconImage( const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, int desired_size_in_dip, const FaviconImageCallback& callback, base::CancelableTaskTracker* tracker) { @@ -99,7 +99,7 @@ base::CancelableTaskTracker::TaskId FaviconService::GetFaviconImage( base::CancelableTaskTracker::TaskId FaviconService::GetRawFavicon( const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, const FaviconRawCallback& callback, @@ -125,7 +125,7 @@ base::CancelableTaskTracker::TaskId FaviconService::GetRawFavicon( base::CancelableTaskTracker::TaskId FaviconService::GetFavicon( const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, int desired_size_in_dip, const FaviconResultsCallback& callback, base::CancelableTaskTracker* tracker) { @@ -223,7 +223,7 @@ base::CancelableTaskTracker::TaskId FaviconService::GetFaviconForURL( } base::CancelableTaskTracker::TaskId FaviconService::GetLargestRawFaviconForID( - chrome::FaviconID favicon_id, + favicon_base::FaviconID favicon_id, const FaviconRawCallback& callback, base::CancelableTaskTracker* tracker) { // Use 0 as |desired_size_in_dip| to get the largest bitmap for |favicon_id| @@ -264,7 +264,7 @@ void FaviconService::SetImportedFavicons( void FaviconService::MergeFavicon( const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, scoped_refptr<base::RefCountedMemory> bitmap_data, const gfx::Size& pixel_size) { if (history_service_) { @@ -275,7 +275,7 @@ void FaviconService::MergeFavicon( void FaviconService::SetFavicons(const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, const gfx::Image& image) { if (!history_service_) return; @@ -283,7 +283,7 @@ void FaviconService::SetFavicons(const GURL& page_url, gfx::ImageSkia image_skia = image.AsImageSkia(); image_skia.EnsureRepsForSupportedScales(); const std::vector<gfx::ImageSkiaRep>& image_reps = image_skia.image_reps(); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; for (size_t i = 0; i < image_reps.size(); ++i) { scoped_refptr<base::RefCountedBytes> bitmap_data( new base::RefCountedBytes()); @@ -292,7 +292,7 @@ void FaviconService::SetFavicons(const GURL& page_url, &bitmap_data->data())) { gfx::Size pixel_size(image_reps[i].pixel_width(), image_reps[i].pixel_height()); - chrome::FaviconBitmapData bitmap_data_element; + favicon_base::FaviconBitmapData bitmap_data_element; bitmap_data_element.bitmap_data = bitmap_data; bitmap_data_element.pixel_size = pixel_size; bitmap_data_element.icon_url = icon_url; @@ -343,8 +343,9 @@ base::CancelableTaskTracker::TaskId FaviconService::GetFaviconForURLImpl( void FaviconService::RunFaviconImageCallbackWithBitmapResults( const FaviconImageCallback& callback, int desired_size_in_dip, - const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results) { - chrome::FaviconImageResult image_result; + const std::vector<favicon_base::FaviconBitmapResult>& + favicon_bitmap_results) { + favicon_base::FaviconImageResult image_result; image_result.image = FaviconUtil::SelectFaviconFramesFromPNGs( favicon_bitmap_results, FaviconUtil::GetFaviconScaleFactors(), @@ -360,14 +361,15 @@ void FaviconService::RunFaviconRawCallbackWithBitmapResults( const FaviconRawCallback& callback, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, - const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results) { + const std::vector<favicon_base::FaviconBitmapResult>& + favicon_bitmap_results) { if (favicon_bitmap_results.empty() || !favicon_bitmap_results[0].is_valid()) { - callback.Run(chrome::FaviconBitmapResult()); + callback.Run(favicon_base::FaviconBitmapResult()); return; } DCHECK_EQ(1u, favicon_bitmap_results.size()); - chrome::FaviconBitmapResult bitmap_result = favicon_bitmap_results[0]; + favicon_base::FaviconBitmapResult bitmap_result = favicon_bitmap_results[0]; // If the desired size is 0, SelectFaviconFrames() will return the largest // bitmap without doing any resizing. As |favicon_bitmap_results| has bitmap @@ -398,7 +400,7 @@ void FaviconService::RunFaviconRawCallbackWithBitmapResults( std::vector<unsigned char> resized_bitmap_data; if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, &resized_bitmap_data)) { - callback.Run(chrome::FaviconBitmapResult()); + callback.Run(favicon_base::FaviconBitmapResult()); return; } diff --git a/chrome/browser/favicon/favicon_service.h b/chrome/browser/favicon/favicon_service.h index 1df4879..665d36a 100644 --- a/chrome/browser/favicon/favicon_service.h +++ b/chrome/browser/favicon/favicon_service.h @@ -11,7 +11,7 @@ #include "base/containers/hash_tables.h" #include "base/memory/ref_counted.h" #include "base/task/cancelable_task_tracker.h" -#include "chrome/common/favicon/favicon_types.h" +#include "components/favicon_base/favicon_types.h" #include "components/keyed_service/core/keyed_service.h" #include "ui/base/layout.h" @@ -55,13 +55,13 @@ class FaviconService : public KeyedService { // |image| originate from. // TODO(pkotwicz): Enable constructing |image| from bitmaps from several // icon URLs. - typedef base::Callback<void(const chrome::FaviconImageResult&)> + typedef base::Callback<void(const favicon_base::FaviconImageResult&)> FaviconImageCallback; // Callback for GetRawFavicon(), GetRawFaviconForURL() and // GetLargestRawFavicon(). // See function for details on value. - typedef base::Callback<void(const chrome::FaviconBitmapResult&)> + typedef base::Callback<void(const favicon_base::FaviconBitmapResult&)> FaviconRawCallback; // Callback for GetFavicon() and GetFaviconForURL(). @@ -72,14 +72,14 @@ class FaviconService : public KeyedService { // platform (eg MacOS) in addition to 1x. The vector has at most one result // for each of the scale factors. There are less entries if a single result // is the best bitmap to use for several scale factors. - typedef base::Callback<void(const std::vector<chrome::FaviconBitmapResult>&)> - FaviconResultsCallback; + typedef base::Callback<void(const std::vector< + favicon_base::FaviconBitmapResult>&)> FaviconResultsCallback; // We usually pass parameters with pointer to avoid copy. This function is a // helper to run FaviconResultsCallback with pointer parameters. static void FaviconResultsCallbackRunner( const FaviconResultsCallback& callback, - const std::vector<chrome::FaviconBitmapResult>* results); + const std::vector<favicon_base::FaviconBitmapResult>* results); // Requests the favicon at |icon_url| of |icon_type| whose size most closely // matches |desired_size_in_dip|. If |desired_size_in_dip| is 0, the largest @@ -91,14 +91,14 @@ class FaviconService : public KeyedService { // current platform (eg MacOS) are requested for GetFaviconImage(). base::CancelableTaskTracker::TaskId GetFaviconImage( const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, int desired_size_in_dip, const FaviconImageCallback& callback, base::CancelableTaskTracker* tracker); base::CancelableTaskTracker::TaskId GetRawFavicon( const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, const FaviconRawCallback& callback, @@ -106,7 +106,7 @@ class FaviconService : public KeyedService { base::CancelableTaskTracker::TaskId GetFavicon( const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, int desired_size_in_dip, const FaviconResultsCallback& callback, base::CancelableTaskTracker* tracker); @@ -180,7 +180,7 @@ class FaviconService : public KeyedService { // multiple favicon bitmaps for |favicon_id|, the largest favicon bitmap is // returned. base::CancelableTaskTracker::TaskId GetLargestRawFaviconForID( - chrome::FaviconID favicon_id, + favicon_base::FaviconID favicon_id, const FaviconRawCallback& callback, base::CancelableTaskTracker* tracker); @@ -207,7 +207,7 @@ class FaviconService : public KeyedService { // known. void MergeFavicon(const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, scoped_refptr<base::RefCountedMemory> bitmap_data, const gfx::Size& pixel_size); @@ -223,7 +223,7 @@ class FaviconService : public KeyedService { // thumbnail database. void SetFavicons(const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, const gfx::Image& image); // Avoid repeated requests to download missing favicon. @@ -247,21 +247,24 @@ class FaviconService : public KeyedService { // Intermediate callback for GetFaviconImage() and GetFaviconImageForURL() // so that history service can deal solely with FaviconResultsCallback. - // Builds chrome::FaviconImageResult from |favicon_bitmap_results| and runs + // Builds favicon_base::FaviconImageResult from |favicon_bitmap_results| and + // runs // |callback|. void RunFaviconImageCallbackWithBitmapResults( const FaviconImageCallback& callback, int desired_size_in_dip, - const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results); + const std::vector<favicon_base::FaviconBitmapResult>& + favicon_bitmap_results); // Intermediate callback for GetRawFavicon() and GetRawFaviconForURL() // so that history service can deal solely with FaviconResultsCallback. - // Resizes chrome::FaviconBitmapResult if necessary and runs |callback|. + // Resizes favicon_base::FaviconBitmapResult if necessary and runs |callback|. void RunFaviconRawCallbackWithBitmapResults( const FaviconRawCallback& callback, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, - const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results); + const std::vector<favicon_base::FaviconBitmapResult>& + favicon_bitmap_results); DISALLOW_COPY_AND_ASSIGN(FaviconService); }; diff --git a/chrome/browser/favicon/favicon_tab_helper.cc b/chrome/browser/favicon/favicon_tab_helper.cc index f9f5d4b..41b5990 100644 --- a/chrome/browser/favicon/favicon_tab_helper.cc +++ b/chrome/browser/favicon/favicon_tab_helper.cc @@ -124,7 +124,7 @@ void FaviconTabHelper::SaveFavicon() { return; } service->SetFavicons( - entry->GetURL(), favicon.url, chrome::FAVICON, favicon.image); + entry->GetURL(), favicon.url, favicon_base::FAVICON, favicon.image); } NavigationEntry* FaviconTabHelper::GetActiveEntry() { diff --git a/chrome/browser/favicon/favicon_util.cc b/chrome/browser/favicon/favicon_util.cc index 8d73e78..9cd480e 100644 --- a/chrome/browser/favicon/favicon_util.cc +++ b/chrome/browser/favicon/favicon_util.cc @@ -5,7 +5,7 @@ #include "chrome/browser/favicon/favicon_util.h" #include "chrome/browser/history/select_favicon_frames.h" -#include "chrome/common/favicon/favicon_types.h" +#include "components/favicon_base/favicon_types.h" #include "skia/ext/image_operations.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkCanvas.h" @@ -25,7 +25,7 @@ namespace { // |scale_factors| for which the image reps can be created without resizing // or decoding the bitmap data. std::vector<gfx::ImagePNGRep> SelectFaviconFramesFromPNGsWithoutResizing( - const std::vector<chrome::FaviconBitmapResult>& png_data, + const std::vector<favicon_base::FaviconBitmapResult>& png_data, const std::vector<ui::ScaleFactor>& scale_factors, int favicon_size) { std::vector<gfx::ImagePNGRep> png_reps; @@ -173,9 +173,9 @@ void FaviconUtil::SetFaviconColorSpace(gfx::Image* image) { // static gfx::Image FaviconUtil::SelectFaviconFramesFromPNGs( - const std::vector<chrome::FaviconBitmapResult>& png_data, - const std::vector<ui::ScaleFactor>& scale_factors, - int favicon_size) { + const std::vector<favicon_base::FaviconBitmapResult>& png_data, + const std::vector<ui::ScaleFactor>& scale_factors, + int favicon_size) { // Create image reps for as many scale factors as possible without resizing // the bitmap data or decoding it. FaviconHandler stores already resized // favicons into history so no additional resizing should be needed in the diff --git a/chrome/browser/favicon/favicon_util.h b/chrome/browser/favicon/favicon_util.h index b8dc460..08c40ca 100644 --- a/chrome/browser/favicon/favicon_util.h +++ b/chrome/browser/favicon/favicon_util.h @@ -7,6 +7,7 @@ #include <vector> +#include "components/favicon_base/favicon_types.h" #include "ui/base/layout.h" namespace chrome { @@ -36,7 +37,7 @@ class FaviconUtil { // Takes a vector of png-encoded frames, decodes them, and converts them to // a favicon of size favicon_size (in DIPs) at the desired ui scale factors. static gfx::Image SelectFaviconFramesFromPNGs( - const std::vector<chrome::FaviconBitmapResult>& png_data, + const std::vector<favicon_base::FaviconBitmapResult>& png_data, const std::vector<ui::ScaleFactor>& scale_factors, int favicon_size); }; diff --git a/chrome/browser/history/android/android_cache_database.cc b/chrome/browser/history/android/android_cache_database.cc index 5df7951..ca10317 100644 --- a/chrome/browser/history/android/android_cache_database.cc +++ b/chrome/browser/history/android/android_cache_database.cc @@ -93,7 +93,7 @@ bool AndroidCacheDatabase::MarkURLsAsBookmarked( } bool AndroidCacheDatabase::SetFaviconID(URLID url_id, - chrome::FaviconID favicon_id) { + favicon_base::FaviconID favicon_id) { sql::Statement update_statement(GetDB().GetCachedStatement(SQL_FROM_HERE, "UPDATE android_cache_db.bookmark_cache " "SET favicon_id = ? WHERE url_id = ? ")); diff --git a/chrome/browser/history/android/android_cache_database.h b/chrome/browser/history/android/android_cache_database.h index 314e0d1..3fb977b 100644 --- a/chrome/browser/history/android/android_cache_database.h +++ b/chrome/browser/history/android/android_cache_database.h @@ -42,7 +42,7 @@ class AndroidCacheDatabase { // Set the given |url_id|'s favicon column to |favicon_id|. Returns true on // success. - bool SetFaviconID(URLID url_id, chrome::FaviconID favicon_id); + bool SetFaviconID(URLID url_id, favicon_base::FaviconID favicon_id); // The search_terms table ------------------------------------------------- // diff --git a/chrome/browser/history/android/android_provider_backend.cc b/chrome/browser/history/android/android_provider_backend.cc index 62752c1..7b5a4f27 100644 --- a/chrome/browser/history/android/android_provider_backend.cc +++ b/chrome/browser/history/android/android_provider_backend.cc @@ -840,7 +840,8 @@ bool AndroidProviderBackend::UpdateFavicon() { if (!thumbnail_db_) return true; - if (!thumbnail_db_->InitIconMappingEnumerator(chrome::FAVICON, &enumerator)) + if (!thumbnail_db_->InitIconMappingEnumerator(favicon_base::FAVICON, + &enumerator)) return false; IconMapping icon_mapping; @@ -1016,7 +1017,7 @@ bool AndroidProviderBackend::SimulateUpdateURL( return false; deleted_details->rows.push_back(old_url_row); - chrome::FaviconID favicon_id = statement->statement()->ColumnInt64(4); + favicon_base::FaviconID favicon_id = statement->statement()->ColumnInt64(4); if (favicon_id) { std::vector<FaviconBitmap> favicon_bitmaps; if (!thumbnail_db_ || diff --git a/chrome/browser/history/android/android_provider_backend_unittest.cc b/chrome/browser/history/android/android_provider_backend_unittest.cc index b7c2ae5..3d2e92b 100644 --- a/chrome/browser/history/android/android_provider_backend_unittest.cc +++ b/chrome/browser/history/android/android_provider_backend_unittest.cc @@ -50,7 +50,7 @@ struct BookmarkCacheRow { Time create_time_; Time last_visit_time_; bool bookmark_; - chrome::FaviconID favicon_id_; + favicon_base::FaviconID favicon_id_; }; } // namespace @@ -253,14 +253,15 @@ TEST_F(AndroidProviderBackendTest, UpdateTables) { // Set favicon to url2. std::vector<unsigned char> data; data.push_back('1'); - chrome::FaviconBitmapData bitmap_data_element; + favicon_base::FaviconBitmapData bitmap_data_element; bitmap_data_element.bitmap_data = new base::RefCountedBytes(data); bitmap_data_element.pixel_size = gfx::Size(); bitmap_data_element.icon_url = GURL(); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; favicon_bitmap_data.push_back(bitmap_data_element); - history_backend->SetFavicons(url2, chrome::FAVICON, favicon_bitmap_data); + history_backend->SetFavicons( + url2, favicon_base::FAVICON, favicon_bitmap_data); history_backend->Closing(); } @@ -402,14 +403,15 @@ TEST_F(AndroidProviderBackendTest, QueryHistoryAndBookmarks) { // Set favicon to url2. std::vector<unsigned char> data; data.push_back('1'); - chrome::FaviconBitmapData bitmap_data_element; + favicon_base::FaviconBitmapData bitmap_data_element; bitmap_data_element.bitmap_data = new base::RefCountedBytes(data); bitmap_data_element.pixel_size = gfx::Size(); bitmap_data_element.icon_url = GURL(); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; favicon_bitmap_data.push_back(bitmap_data_element); - history_backend->SetFavicons(url2, chrome::FAVICON, favicon_bitmap_data); + history_backend->SetFavicons( + url2, favicon_base::FAVICON, favicon_bitmap_data); history_backend->Closing(); } @@ -1154,7 +1156,7 @@ TEST_F(AndroidProviderBackendTest, UpdateFavicon) { std::vector<IconMapping> icon_mappings; EXPECT_TRUE(thumbnail_db_.GetIconMappingsForPageURL( - row1.url(), chrome::FAVICON, &icon_mappings)); + row1.url(), favicon_base::FAVICON, &icon_mappings)); EXPECT_EQ(1u, icon_mappings.size()); std::vector<FaviconBitmap> favicon_bitmaps; EXPECT_TRUE(thumbnail_db_.GetFaviconBitmaps(icon_mappings[0].icon_id, @@ -1183,7 +1185,7 @@ TEST_F(AndroidProviderBackendTest, UpdateFavicon) { delegate_.favicon_details()->urls.find(row1.url())); EXPECT_FALSE(thumbnail_db_.GetIconMappingsForPageURL( - row1.url(), chrome::FAVICON, NULL)); + row1.url(), favicon_base::FAVICON, NULL)); } TEST_F(AndroidProviderBackendTest, UpdateSearchTermTable) { @@ -1801,14 +1803,15 @@ TEST_F(AndroidProviderBackendTest, QueryWithoutThumbnailDB) { // Set favicon to url2. std::vector<unsigned char> data; data.push_back('1'); - chrome::FaviconBitmapData bitmap_data_element; + favicon_base::FaviconBitmapData bitmap_data_element; bitmap_data_element.bitmap_data = new base::RefCountedBytes(data); bitmap_data_element.pixel_size = gfx::Size(); bitmap_data_element.icon_url = GURL(); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; favicon_bitmap_data.push_back(bitmap_data_element); - history_backend->SetFavicons(url2, chrome::FAVICON, favicon_bitmap_data); + history_backend->SetFavicons( + url2, favicon_base::FAVICON, favicon_bitmap_data); history_backend->Closing(); } diff --git a/chrome/browser/history/android/favicon_sql_handler.cc b/chrome/browser/history/android/favicon_sql_handler.cc index 6c0c3d7..e56d71c 100644 --- a/chrome/browser/history/android/favicon_sql_handler.cc +++ b/chrome/browser/history/android/favicon_sql_handler.cc @@ -37,23 +37,19 @@ bool FaviconSQLHandler::Update(const HistoryAndBookmarkRow& row, // If the image_data will be updated, it is not reasonable to find if the // icon is already in database, just create a new favicon. // TODO(pkotwicz): Pass in real pixel size. - chrome::FaviconID favicon_id = thumbnail_db_->AddFavicon( - GURL(), - chrome::FAVICON, - row.favicon(), - Time::Now(), - gfx::Size()); + favicon_base::FaviconID favicon_id = thumbnail_db_->AddFavicon( + GURL(), favicon_base::FAVICON, row.favicon(), Time::Now(), gfx::Size()); if (!favicon_id) return false; - std::vector<chrome::FaviconID> favicon_ids; + std::vector<favicon_base::FaviconID> favicon_ids; for (TableIDRows::const_iterator i = ids_set.begin(); i != ids_set.end(); ++i) { // Remove all icon mappings to favicons of type FAVICON. std::vector<IconMapping> icon_mappings; thumbnail_db_->GetIconMappingsForPageURL( - i->url, chrome::FAVICON, &icon_mappings); + i->url, favicon_base::FAVICON, &icon_mappings); for (std::vector<IconMapping>::const_iterator m = icon_mappings.begin(); m != icon_mappings.end(); ++m) { if (!thumbnail_db_->DeleteIconMapping(m->mapping_id)) @@ -74,7 +70,7 @@ bool FaviconSQLHandler::Update(const HistoryAndBookmarkRow& row, } bool FaviconSQLHandler::Delete(const TableIDRows& ids_set) { - std::vector<chrome::FaviconID> favicon_ids; + std::vector<favicon_base::FaviconID> favicon_ids; for (TableIDRows::const_iterator i = ids_set.begin(); i != ids_set.end(); ++i) { // Since the URL was deleted, we delete all types of icon mappings. @@ -106,20 +102,16 @@ bool FaviconSQLHandler::Insert(HistoryAndBookmarkRow* row) { // Is it a problem to give a empty URL? // TODO(pkotwicz): Pass in real pixel size. - chrome::FaviconID id = thumbnail_db_->AddFavicon( - GURL(), - chrome::FAVICON, - row->favicon(), - Time::Now(), - gfx::Size()); + favicon_base::FaviconID id = thumbnail_db_->AddFavicon( + GURL(), favicon_base::FAVICON, row->favicon(), Time::Now(), gfx::Size()); if (!id) return false; return thumbnail_db_->AddIconMapping(row->url(), id); } bool FaviconSQLHandler::DeleteUnusedFavicon( - const std::vector<chrome::FaviconID>& ids) { - for (std::vector<chrome::FaviconID>::const_iterator i = ids.begin(); + const std::vector<favicon_base::FaviconID>& ids) { + for (std::vector<favicon_base::FaviconID>::const_iterator i = ids.begin(); i != ids.end(); ++i) { if (!thumbnail_db_->HasMappingFor(*i) && !thumbnail_db_->DeleteFavicon(*i)) diff --git a/chrome/browser/history/android/favicon_sql_handler.h b/chrome/browser/history/android/favicon_sql_handler.h index f004cb6..d4b2d3f 100644 --- a/chrome/browser/history/android/favicon_sql_handler.h +++ b/chrome/browser/history/android/favicon_sql_handler.h @@ -26,7 +26,7 @@ class FaviconSQLHandler : public SQLHandler { private: // Deletes the given favicons if they are not used by any pages. Returns // true if all unused favicons are deleted. - bool DeleteUnusedFavicon(const std::vector<chrome::FaviconID>& ids); + bool DeleteUnusedFavicon(const std::vector<favicon_base::FaviconID>& ids); ThumbnailDatabase* thumbnail_db_; diff --git a/chrome/browser/history/android/sqlite_cursor.cc b/chrome/browser/history/android/sqlite_cursor.cc index 9fd16ce..cde8674 100644 --- a/chrome/browser/history/android/sqlite_cursor.cc +++ b/chrome/browser/history/android/sqlite_cursor.cc @@ -172,7 +172,7 @@ void SQLiteCursor::DestroyOnUIThread() { delete this; } -bool SQLiteCursor::GetFavicon(chrome::FaviconID id, +bool SQLiteCursor::GetFavicon(favicon_base::FaviconID id, std::vector<unsigned char>* image_data) { if (id) { BrowserThread::PostTask( @@ -201,7 +201,7 @@ bool SQLiteCursor::GetFavicon(chrome::FaviconID id, } void SQLiteCursor::GetFaviconForIDInUIThread( - chrome::FaviconID id, + favicon_base::FaviconID id, const FaviconService::FaviconRawCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (!tracker_.get()) @@ -209,9 +209,8 @@ void SQLiteCursor::GetFaviconForIDInUIThread( favicon_service_->GetLargestRawFaviconForID(id, callback, tracker_.get()); } - void SQLiteCursor::OnFaviconData( - const chrome::FaviconBitmapResult& bitmap_result) { + const favicon_base::FaviconBitmapResult& bitmap_result) { favicon_bitmap_result_ = bitmap_result; event_.Signal(); if (test_observer_) diff --git a/chrome/browser/history/android/sqlite_cursor.h b/chrome/browser/history/android/sqlite_cursor.h index 389a05c..0a4349b 100644 --- a/chrome/browser/history/android/sqlite_cursor.h +++ b/chrome/browser/history/android/sqlite_cursor.h @@ -146,15 +146,15 @@ class SQLiteCursor { } // Get Favicon from history backend. - bool GetFavicon(chrome::FaviconID id, + bool GetFavicon(favicon_base::FaviconID id, std::vector<unsigned char>* image_data); void GetFaviconForIDInUIThread( - chrome::FaviconID id, + favicon_base::FaviconID id, const FaviconService::FaviconRawCallback& callback); // The callback function of FaviconService::GetLargestRawFaviconForID(). - void OnFaviconData(const chrome::FaviconBitmapResult& bitmap_result); + void OnFaviconData(const favicon_base::FaviconBitmapResult& bitmap_result); // The callback function of MoveTo(). void OnMoved(AndroidHistoryProviderService::Handle handle, int pos); @@ -187,7 +187,7 @@ class SQLiteCursor { int count_; // The favicon image. - chrome::FaviconBitmapResult favicon_bitmap_result_; + favicon_base::FaviconBitmapResult favicon_bitmap_result_; TestObserver* test_observer_; diff --git a/chrome/browser/history/expire_history_backend.cc b/chrome/browser/history/expire_history_backend.cc index cf77fe4..5d3e4ad 100644 --- a/chrome/browser/history/expire_history_backend.cc +++ b/chrome/browser/history/expire_history_backend.cc @@ -157,7 +157,7 @@ struct ExpireHistoryBackend::DeleteDependencies { // The list of all favicon IDs that the affected URLs had. Favicons will be // shared between all URLs with the same favicon, so this is the set of IDs // that we will need to check when the delete operations are complete. - std::set<chrome::FaviconID> affected_favicons; + std::set<favicon_base::FaviconID> affected_favicons; // The list of all favicon urls that were actually deleted from the thumbnail // db. @@ -343,16 +343,18 @@ void ExpireHistoryBackend::StartArchivingOldStuff( } void ExpireHistoryBackend::DeleteFaviconsIfPossible( - const std::set<chrome::FaviconID>& favicon_set, + const std::set<favicon_base::FaviconID>& favicon_set, std::set<GURL>* expired_favicons) { if (!thumb_db_) return; - for (std::set<chrome::FaviconID>::const_iterator i = favicon_set.begin(); - i != favicon_set.end(); ++i) { + for (std::set<favicon_base::FaviconID>::const_iterator i = + favicon_set.begin(); + i != favicon_set.end(); + ++i) { if (!thumb_db_->HasMappingFor(*i)) { GURL icon_url; - chrome::IconType icon_type; + favicon_base::IconType icon_type; if (thumb_db_->GetFaviconHeader(*i, &icon_url, &icon_type) && @@ -649,11 +651,12 @@ bool ExpireHistoryBackend::ArchiveSomeOldHistory( // Create a union of all affected favicons (we don't store favicons for // archived URLs) and delete them. - std::set<chrome::FaviconID> affected_favicons( + std::set<favicon_base::FaviconID> affected_favicons( archived_dependencies.affected_favicons); - for (std::set<chrome::FaviconID>::const_iterator i = + for (std::set<favicon_base::FaviconID>::const_iterator i = deleted_dependencies.affected_favicons.begin(); - i != deleted_dependencies.affected_favicons.end(); ++i) { + i != deleted_dependencies.affected_favicons.end(); + ++i) { affected_favicons.insert(*i); } DeleteFaviconsIfPossible(affected_favicons, diff --git a/chrome/browser/history/expire_history_backend.h b/chrome/browser/history/expire_history_backend.h index 471dd7b..0322476 100644 --- a/chrome/browser/history/expire_history_backend.h +++ b/chrome/browser/history/expire_history_backend.h @@ -198,8 +198,9 @@ class ExpireHistoryBackend { // care about favicons so much, so don't want to stop everything if it fails). // Fills |expired_favicons| with the set of favicon urls that no longer // have associated visits and were therefore expired. - void DeleteFaviconsIfPossible(const std::set<chrome::FaviconID>& favicon_id, - std::set<GURL>* expired_favicons); + void DeleteFaviconsIfPossible( + const std::set<favicon_base::FaviconID>& favicon_id, + std::set<GURL>* expired_favicons); // Enum representing what type of action resulted in the history DB deletion. enum DeletionType { diff --git a/chrome/browser/history/expire_history_backend_unittest.cc b/chrome/browser/history/expire_history_backend_unittest.cc index 28be4e1..5d5c859 100644 --- a/chrome/browser/history/expire_history_backend_unittest.cc +++ b/chrome/browser/history/expire_history_backend_unittest.cc @@ -70,11 +70,11 @@ class ExpireHistoryTest : public testing::Test, void AddExampleSourceData(const GURL& url, URLID* id); // Returns true if the given favicon/thumanil has an entry in the DB. - bool HasFavicon(chrome::FaviconID favicon_id); + bool HasFavicon(favicon_base::FaviconID favicon_id); bool HasThumbnail(URLID url_id); - chrome::FaviconID GetFavicon(const GURL& page_url, - chrome::IconType icon_type); + favicon_base::FaviconID GetFavicon(const GURL& page_url, + favicon_base::IconType icon_type); // EXPECTs that each URL-specific history thing (basically, everything but // favicons) is gone. @@ -197,10 +197,10 @@ void ExpireHistoryTest::AddExampleData(URLID url_ids[3], Time visit_times[4]) { // Two favicons. The first two URLs will share the same one, while the last // one will have a unique favicon. - chrome::FaviconID favicon1 = thumb_db_->AddFavicon( - GURL("http://favicon/url1"), chrome::FAVICON); - chrome::FaviconID favicon2 = thumb_db_->AddFavicon( - GURL("http://favicon/url2"), chrome::FAVICON); + favicon_base::FaviconID favicon1 = + thumb_db_->AddFavicon(GURL("http://favicon/url1"), favicon_base::FAVICON); + favicon_base::FaviconID favicon2 = + thumb_db_->AddFavicon(GURL("http://favicon/url2"), favicon_base::FAVICON); // Three URLs. URLRow url_row1(GURL("http://www.google.com/1")); @@ -287,14 +287,15 @@ void ExpireHistoryTest::AddExampleSourceData(const GURL& url, URLID* id) { main_db_->AddVisit(&visit_row4, SOURCE_FIREFOX_IMPORTED); } -bool ExpireHistoryTest::HasFavicon(chrome::FaviconID favicon_id) { +bool ExpireHistoryTest::HasFavicon(favicon_base::FaviconID favicon_id) { if (!thumb_db_.get() || favicon_id == 0) return false; return thumb_db_->GetFaviconHeader(favicon_id, NULL, NULL); } -chrome::FaviconID ExpireHistoryTest::GetFavicon(const GURL& page_url, - chrome::IconType icon_type) { +favicon_base::FaviconID ExpireHistoryTest::GetFavicon( + const GURL& page_url, + favicon_base::IconType icon_type) { std::vector<IconMapping> icon_mappings; if (thumb_db_->GetIconMappingsForPageURL(page_url, icon_type, &icon_mappings)) { @@ -352,13 +353,13 @@ void ExpireHistoryTest::EnsureURLInfoGone(const URLRow& row) { TEST_F(ExpireHistoryTest, DeleteFaviconsIfPossible) { // Add a favicon record. const GURL favicon_url("http://www.google.com/favicon.ico"); - chrome::FaviconID icon_id = thumb_db_->AddFavicon( - favicon_url, chrome::FAVICON); + favicon_base::FaviconID icon_id = + thumb_db_->AddFavicon(favicon_url, favicon_base::FAVICON); EXPECT_TRUE(icon_id); EXPECT_TRUE(HasFavicon(icon_id)); // The favicon should be deletable with no users. - std::set<chrome::FaviconID> favicon_set; + std::set<favicon_base::FaviconID> favicon_set; std::set<GURL> expired_favicons; favicon_set.insert(icon_id); expirer_.DeleteFaviconsIfPossible(favicon_set, &expired_favicons); @@ -367,8 +368,7 @@ TEST_F(ExpireHistoryTest, DeleteFaviconsIfPossible) { EXPECT_EQ(1U, expired_favicons.count(favicon_url)); // Add back the favicon. - icon_id = thumb_db_->AddFavicon( - favicon_url, chrome::TOUCH_ICON); + icon_id = thumb_db_->AddFavicon(favicon_url, favicon_base::TOUCH_ICON); EXPECT_TRUE(icon_id); EXPECT_TRUE(HasFavicon(icon_id)); @@ -406,7 +406,8 @@ TEST_F(ExpireHistoryTest, DISABLED_DeleteURLAndFavicon) { // Verify things are the way we expect with a URL row, favicon, thumbnail. URLRow last_row; ASSERT_TRUE(main_db_->GetURLRow(url_ids[2], &last_row)); - chrome::FaviconID favicon_id = GetFavicon(last_row.url(), chrome::FAVICON); + favicon_base::FaviconID favicon_id = + GetFavicon(last_row.url(), favicon_base::FAVICON); EXPECT_TRUE(HasFavicon(favicon_id)); // TODO(sky): fix this, see comment in HasThumbnail. // EXPECT_TRUE(HasThumbnail(url_ids[2])); @@ -420,7 +421,7 @@ TEST_F(ExpireHistoryTest, DISABLED_DeleteURLAndFavicon) { // All the normal data + the favicon should be gone. EnsureURLInfoGone(last_row); - EXPECT_FALSE(GetFavicon(last_row.url(), chrome::FAVICON)); + EXPECT_FALSE(GetFavicon(last_row.url(), favicon_base::FAVICON)); EXPECT_FALSE(HasFavicon(favicon_id)); } @@ -434,7 +435,8 @@ TEST_F(ExpireHistoryTest, DeleteURLWithoutFavicon) { // Verify things are the way we expect with a URL row, favicon, thumbnail. URLRow last_row; ASSERT_TRUE(main_db_->GetURLRow(url_ids[1], &last_row)); - chrome::FaviconID favicon_id = GetFavicon(last_row.url(), chrome::FAVICON); + favicon_base::FaviconID favicon_id = + GetFavicon(last_row.url(), favicon_base::FAVICON); EXPECT_TRUE(HasFavicon(favicon_id)); // TODO(sky): fix this, see comment in HasThumbnail. // EXPECT_TRUE(HasThumbnail(url_ids[1])); @@ -471,7 +473,8 @@ TEST_F(ExpireHistoryTest, DontDeleteStarredURL) { ASSERT_TRUE(main_db_->GetRowForURL(url, &url_row)); // And the favicon should exist. - chrome::FaviconID favicon_id = GetFavicon(url_row.url(), chrome::FAVICON); + favicon_base::FaviconID favicon_id = + GetFavicon(url_row.url(), favicon_base::FAVICON); EXPECT_TRUE(HasFavicon(favicon_id)); // And no visits. @@ -501,13 +504,13 @@ TEST_F(ExpireHistoryTest, DeleteURLs) { // Verify things are the way we expect with URL rows, favicons, // thumbnails. URLRow rows[3]; - chrome::FaviconID favicon_ids[3]; + favicon_base::FaviconID favicon_ids[3]; std::vector<GURL> urls; // Push back a bogus URL (which shouldn't change anything). urls.push_back(GURL()); for (size_t i = 0; i < arraysize(rows); ++i) { ASSERT_TRUE(main_db_->GetURLRow(url_ids[i], &rows[i])); - favicon_ids[i] = GetFavicon(rows[i].url(), chrome::FAVICON); + favicon_ids[i] = GetFavicon(rows[i].url(), favicon_base::FAVICON); EXPECT_TRUE(HasFavicon(favicon_ids[i])); // TODO(sky): fix this, see comment in HasThumbnail. // EXPECT_TRUE(HasThumbnail(url_ids[i])); @@ -564,13 +567,15 @@ TEST_F(ExpireHistoryTest, FlushRecentURLsUnstarred) { EXPECT_EQ(0, temp_row.typed_count()); // Verify that the middle URL's favicon and thumbnail is still there. - chrome::FaviconID favicon_id = GetFavicon(url_row1.url(), chrome::FAVICON); + favicon_base::FaviconID favicon_id = + GetFavicon(url_row1.url(), favicon_base::FAVICON); EXPECT_TRUE(HasFavicon(favicon_id)); // TODO(sky): fix this, see comment in HasThumbnail. // EXPECT_TRUE(HasThumbnail(url_row1.id())); // Verify that the last URL was deleted. - chrome::FaviconID favicon_id2 = GetFavicon(url_row2.url(), chrome::FAVICON); + favicon_base::FaviconID favicon_id2 = + GetFavicon(url_row2.url(), favicon_base::FAVICON); EnsureURLInfoGone(url_row2); EXPECT_FALSE(HasFavicon(favicon_id2)); } @@ -611,13 +616,15 @@ TEST_F(ExpireHistoryTest, FlushURLsForTimes) { EXPECT_EQ(0, temp_row.typed_count()); // Verify that the middle URL's favicon and thumbnail is still there. - chrome::FaviconID favicon_id = GetFavicon(url_row1.url(), chrome::FAVICON); + favicon_base::FaviconID favicon_id = + GetFavicon(url_row1.url(), favicon_base::FAVICON); EXPECT_TRUE(HasFavicon(favicon_id)); // TODO(sky): fix this, see comment in HasThumbnail. // EXPECT_TRUE(HasThumbnail(url_row1.id())); // Verify that the last URL was deleted. - chrome::FaviconID favicon_id2 = GetFavicon(url_row2.url(), chrome::FAVICON); + favicon_base::FaviconID favicon_id2 = + GetFavicon(url_row2.url(), favicon_base::FAVICON); EnsureURLInfoGone(url_row2); EXPECT_FALSE(HasFavicon(favicon_id2)); } @@ -659,7 +666,8 @@ TEST_F(ExpireHistoryTest, FlushRecentURLsUnstarredRestricted) { EXPECT_EQ(0, temp_row.typed_count()); // Verify that the middle URL's favicon and thumbnail is still there. - chrome::FaviconID favicon_id = GetFavicon(url_row1.url(), chrome::FAVICON); + favicon_base::FaviconID favicon_id = + GetFavicon(url_row1.url(), favicon_base::FAVICON); EXPECT_TRUE(HasFavicon(favicon_id)); // TODO(sky): fix this, see comment in HasThumbnail. // EXPECT_TRUE(HasThumbnail(url_row1.id())); @@ -708,11 +716,12 @@ TEST_F(ExpireHistoryTest, FlushRecentURLsStarred) { // that may have been updated since the time threshold. Since the URL still // exists in history, this should not be a privacy problem, we only update // the visit counts in this case for consistency anyway. - chrome::FaviconID favicon_id = GetFavicon(url_row1.url(), chrome::FAVICON); + favicon_base::FaviconID favicon_id = + GetFavicon(url_row1.url(), favicon_base::FAVICON); EXPECT_TRUE(HasFavicon(favicon_id)); // TODO(sky): fix this, see comment in HasThumbnail. // EXPECT_TRUE(HasThumbnail(new_url_row1.id())); - favicon_id = GetFavicon(url_row1.url(), chrome::FAVICON); + favicon_id = GetFavicon(url_row1.url(), favicon_base::FAVICON); EXPECT_TRUE(HasFavicon(favicon_id)); // TODO(sky): fix this, see comment in HasThumbnail. // EXPECT_TRUE(HasThumbnail(new_url_row2.id())); diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc index fe465df..7548fc9 100644 --- a/chrome/browser/history/history_backend.cc +++ b/chrome/browser/history/history_backend.cc @@ -1651,17 +1651,17 @@ void HistoryBackend::GetFavicons( int icon_types, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<chrome::FaviconBitmapResult>* bitmap_results) { + std::vector<favicon_base::FaviconBitmapResult>* bitmap_results) { UpdateFaviconMappingsAndFetchImpl(NULL, icon_urls, icon_types, desired_size_in_dip, desired_scale_factors, bitmap_results); } void HistoryBackend::GetLargestFaviconForURL( - const GURL& page_url, - const std::vector<int>& icon_types, - int minimum_size_in_pixels, - chrome::FaviconBitmapResult* favicon_bitmap_result) { + const GURL& page_url, + const std::vector<int>& icon_types, + int minimum_size_in_pixels, + favicon_base::FaviconBitmapResult* favicon_bitmap_result) { DCHECK(favicon_bitmap_result); if (!db_ || !thumbnail_db_) @@ -1682,7 +1682,7 @@ void HistoryBackend::GetLargestFaviconForURL( // Find the largest bitmap for each IconType placing in // |largest_favicon_bitmaps|. - std::map<chrome::IconType, FaviconBitmap> largest_favicon_bitmaps; + std::map<favicon_base::IconType, FaviconBitmap> largest_favicon_bitmaps; for (std::vector<IconMapping>::const_iterator i = icon_mappings.begin(); i != icon_mappings.end(); ++i) { if (!(i->icon_type & required_icon_types)) @@ -1709,9 +1709,10 @@ void HistoryBackend::GetLargestFaviconForURL( FaviconBitmap largest_icon; for (std::vector<int>::const_iterator t = icon_types.begin(); t != icon_types.end(); ++t) { - for (std::map<chrome::IconType, FaviconBitmap>::const_iterator f = - largest_favicon_bitmaps.begin(); f != largest_favicon_bitmaps.end(); - ++f) { + for (std::map<favicon_base::IconType, FaviconBitmap>::const_iterator f = + largest_favicon_bitmaps.begin(); + f != largest_favicon_bitmaps.end(); + ++f) { if (f->first & *t && (largest_icon.bitmap_id == 0 || (largest_icon.pixel_size.height() < f->second.pixel_size.height() && @@ -1725,14 +1726,14 @@ void HistoryBackend::GetLargestFaviconForURL( } GURL icon_url; - chrome::IconType icon_type; + favicon_base::IconType icon_type; if (!thumbnail_db_->GetFaviconHeader(largest_icon.icon_id, &icon_url, &icon_type)) { return; } base::Time last_updated; - chrome::FaviconBitmapResult bitmap_result; + favicon_base::FaviconBitmapResult bitmap_result; bitmap_result.icon_url = icon_url; bitmap_result.icon_type = icon_type; if (!thumbnail_db_->GetFaviconBitmap(largest_icon.bitmap_id, @@ -1756,18 +1757,18 @@ void HistoryBackend::GetFaviconsForURL( int icon_types, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<chrome::FaviconBitmapResult>* bitmap_results) { + std::vector<favicon_base::FaviconBitmapResult>* bitmap_results) { DCHECK(bitmap_results); GetFaviconsFromDB(page_url, icon_types, desired_size_in_dip, desired_scale_factors, bitmap_results); } void HistoryBackend::GetFaviconForID( - chrome::FaviconID favicon_id, + favicon_base::FaviconID favicon_id, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, - std::vector<chrome::FaviconBitmapResult>* bitmap_results) { - std::vector<chrome::FaviconID> favicon_ids; + std::vector<favicon_base::FaviconBitmapResult>* bitmap_results) { + std::vector<favicon_base::FaviconID> favicon_ids; favicon_ids.push_back(favicon_id); std::vector<ui::ScaleFactor> desired_scale_factors; desired_scale_factors.push_back(desired_scale_factor); @@ -1785,7 +1786,7 @@ void HistoryBackend::UpdateFaviconMappingsAndFetch( int icon_types, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<chrome::FaviconBitmapResult>* bitmap_results) { + std::vector<favicon_base::FaviconBitmapResult>* bitmap_results) { UpdateFaviconMappingsAndFetchImpl(&page_url, icon_urls, icon_types, desired_size_in_dip, desired_scale_factors, bitmap_results); @@ -1794,13 +1795,13 @@ void HistoryBackend::UpdateFaviconMappingsAndFetch( void HistoryBackend::MergeFavicon( const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, scoped_refptr<base::RefCountedMemory> bitmap_data, const gfx::Size& pixel_size) { if (!thumbnail_db_ || !db_) return; - chrome::FaviconID favicon_id = + favicon_base::FaviconID favicon_id = thumbnail_db_->GetFaviconIDForFaviconURL(icon_url, icon_type, NULL); if (!favicon_id) { @@ -1921,7 +1922,7 @@ void HistoryBackend::MergeFavicon( // |page_url|. bool mapping_changed = false; if (icon_mappings.size() != 1 || icon_mappings[0].icon_url != icon_url) { - std::vector<chrome::FaviconID> favicon_ids; + std::vector<favicon_base::FaviconID> favicon_ids; favicon_ids.push_back(favicon_id); SetFaviconMappingsForPageAndRedirects(page_url, icon_type, favicon_ids); mapping_changed = true; @@ -1934,15 +1935,15 @@ void HistoryBackend::MergeFavicon( void HistoryBackend::SetFavicons( const GURL& page_url, - chrome::IconType icon_type, - const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data) { + favicon_base::IconType icon_type, + const std::vector<favicon_base::FaviconBitmapData>& favicon_bitmap_data) { if (!thumbnail_db_ || !db_) return; DCHECK(ValidateSetFaviconsParams(favicon_bitmap_data)); // Build map of FaviconBitmapData for each icon url. - typedef std::map<GURL, std::vector<chrome::FaviconBitmapData> > + typedef std::map<GURL, std::vector<favicon_base::FaviconBitmapData> > BitmapDataByIconURL; BitmapDataByIconURL grouped_by_icon_url; for (size_t i = 0; i < favicon_bitmap_data.size(); ++i) { @@ -1954,11 +1955,11 @@ void HistoryBackend::SetFavicons( // or icon mappings. bool data_modified = false; - std::vector<chrome::FaviconID> icon_ids; + std::vector<favicon_base::FaviconID> icon_ids; for (BitmapDataByIconURL::const_iterator it = grouped_by_icon_url.begin(); it != grouped_by_icon_url.end(); ++it) { const GURL& icon_url = it->first; - chrome::FaviconID icon_id = + favicon_base::FaviconID icon_id = thumbnail_db_->GetFaviconIDForFaviconURL(icon_url, icon_type, NULL); if (!icon_id) { @@ -2025,14 +2026,15 @@ void HistoryBackend::SetImportedFavicons( std::set<GURL> favicons_changed; for (size_t i = 0; i < favicon_usage.size(); i++) { - chrome::FaviconID favicon_id = thumbnail_db_->GetFaviconIDForFaviconURL( - favicon_usage[i].favicon_url, chrome::FAVICON, NULL); + favicon_base::FaviconID favicon_id = + thumbnail_db_->GetFaviconIDForFaviconURL( + favicon_usage[i].favicon_url, favicon_base::FAVICON, NULL); if (!favicon_id) { // This favicon doesn't exist yet, so we create it using the given data. // TODO(pkotwicz): Pass in real pixel size. favicon_id = thumbnail_db_->AddFavicon( favicon_usage[i].favicon_url, - chrome::FAVICON, + favicon_base::FAVICON, new base::RefCountedBytes(favicon_usage[i].png_data), now, gfx::Size()); @@ -2061,7 +2063,7 @@ void HistoryBackend::SetImportedFavicons( } } else { if (!thumbnail_db_->GetIconMappingsForPageURL( - *url, chrome::FAVICON, NULL)) { + *url, favicon_base::FAVICON, NULL)) { // URL is present in history, update the favicon *only* if it is not // set already. thumbnail_db_->AddIconMapping(*url, favicon_id); @@ -2087,30 +2089,30 @@ void HistoryBackend::UpdateFaviconMappingsAndFetchImpl( int icon_types, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<chrome::FaviconBitmapResult>* bitmap_results) { + std::vector<favicon_base::FaviconBitmapResult>* bitmap_results) { // If |page_url| is specified, |icon_types| must be either a single icon // type or icon types which are equivalent. - DCHECK(!page_url || - icon_types == chrome::FAVICON || - icon_types == chrome::TOUCH_ICON || - icon_types == chrome::TOUCH_PRECOMPOSED_ICON || - icon_types == (chrome::TOUCH_ICON | chrome::TOUCH_PRECOMPOSED_ICON)); + DCHECK(!page_url || icon_types == favicon_base::FAVICON || + icon_types == favicon_base::TOUCH_ICON || + icon_types == favicon_base::TOUCH_PRECOMPOSED_ICON || + icon_types == + (favicon_base::TOUCH_ICON | favicon_base::TOUCH_PRECOMPOSED_ICON)); bitmap_results->clear(); if (!thumbnail_db_) { return; } - std::vector<chrome::FaviconID> favicon_ids; + std::vector<favicon_base::FaviconID> favicon_ids; // The icon type for which the mappings will the updated and data will be // returned. - chrome::IconType selected_icon_type = chrome::INVALID_ICON; + favicon_base::IconType selected_icon_type = favicon_base::INVALID_ICON; for (size_t i = 0; i < icon_urls.size(); ++i) { const GURL& icon_url = icon_urls[i]; - chrome::IconType icon_type_out; - const chrome::FaviconID favicon_id = + favicon_base::IconType icon_type_out; + const favicon_base::FaviconID favicon_id = thumbnail_db_->GetFaviconIDForFaviconURL( icon_url, icon_types, &icon_type_out); @@ -2142,8 +2144,8 @@ void HistoryBackend::UpdateFaviconMappingsAndFetchImpl( } void HistoryBackend::SetFaviconBitmaps( - chrome::FaviconID icon_id, - const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data, + favicon_base::FaviconID icon_id, + const std::vector<favicon_base::FaviconBitmapData>& favicon_bitmap_data, bool* favicon_bitmaps_changed) { if (favicon_bitmaps_changed) *favicon_bitmaps_changed = false; @@ -2151,13 +2153,16 @@ void HistoryBackend::SetFaviconBitmaps( std::vector<FaviconBitmapIDSize> bitmap_id_sizes; thumbnail_db_->GetFaviconBitmapIDSizes(icon_id, &bitmap_id_sizes); - std::vector<chrome::FaviconBitmapData> to_add = favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> to_add = favicon_bitmap_data; for (size_t i = 0; i < bitmap_id_sizes.size(); ++i) { const gfx::Size& pixel_size = bitmap_id_sizes[i].pixel_size; - std::vector<chrome::FaviconBitmapData>::iterator match_it = to_add.end(); - for (std::vector<chrome::FaviconBitmapData>::iterator it = to_add.begin(); - it != to_add.end(); ++it) { + std::vector<favicon_base::FaviconBitmapData>::iterator match_it = + to_add.end(); + for (std::vector<favicon_base::FaviconBitmapData>::iterator it = + to_add.begin(); + it != to_add.end(); + ++it) { if (it->pixel_size == pixel_size) { match_it = it; break; @@ -2196,8 +2201,8 @@ void HistoryBackend::SetFaviconBitmaps( } } -bool HistoryBackend::ValidateSetFaviconsParams( - const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data) const { +bool HistoryBackend::ValidateSetFaviconsParams(const std::vector< + favicon_base::FaviconBitmapData>& favicon_bitmap_data) const { typedef std::map<GURL, size_t> BitmapsPerIconURL; BitmapsPerIconURL num_bitmaps_per_icon_url; for (size_t i = 0; i < favicon_bitmap_data.size(); ++i) { @@ -2241,7 +2246,7 @@ bool HistoryBackend::GetFaviconsFromDB( int icon_types, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results) { + std::vector<favicon_base::FaviconBitmapResult>* favicon_bitmap_results) { DCHECK(favicon_bitmap_results); favicon_bitmap_results->clear(); @@ -2255,7 +2260,7 @@ bool HistoryBackend::GetFaviconsFromDB( std::vector<IconMapping> icon_mappings; thumbnail_db_->GetIconMappingsForPageURL(page_url, icon_types, &icon_mappings); - std::vector<chrome::FaviconID> favicon_ids; + std::vector<favicon_base::FaviconID> favicon_ids; for (size_t i = 0; i < icon_mappings.size(); ++i) favicon_ids.push_back(icon_mappings[i].icon_id); @@ -2268,10 +2273,10 @@ bool HistoryBackend::GetFaviconsFromDB( } bool HistoryBackend::GetFaviconBitmapResultsForBestMatch( - const std::vector<chrome::FaviconID>& candidate_favicon_ids, + const std::vector<favicon_base::FaviconID>& candidate_favicon_ids, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results) { + std::vector<favicon_base::FaviconBitmapResult>* favicon_bitmap_results) { favicon_bitmap_results->clear(); if (candidate_favicon_ids.empty()) @@ -2281,7 +2286,7 @@ bool HistoryBackend::GetFaviconBitmapResultsForBestMatch( // |desired_size_in_dip| and |desired_scale_factors|. // TODO(pkotwicz): Select bitmap results from multiple favicons once // content::FaviconStatus supports multiple icon URLs. - chrome::FaviconID best_favicon_id = 0; + favicon_base::FaviconID best_favicon_id = 0; std::vector<FaviconBitmapID> best_bitmap_ids; float highest_score = kSelectFaviconFramesInvalidScore; for (size_t i = 0; i < candidate_favicon_ids.size(); ++i) { @@ -2316,7 +2321,7 @@ bool HistoryBackend::GetFaviconBitmapResultsForBestMatch( // Construct FaviconBitmapResults from |best_favicon_id| and // |best_bitmap_ids|. GURL icon_url; - chrome::IconType icon_type; + favicon_base::IconType icon_type; if (!thumbnail_db_->GetFaviconHeader(best_favicon_id, &icon_url, &icon_type)) { return false; @@ -2324,7 +2329,7 @@ bool HistoryBackend::GetFaviconBitmapResultsForBestMatch( for (size_t i = 0; i < best_bitmap_ids.size(); ++i) { base::Time last_updated; - chrome::FaviconBitmapResult bitmap_result; + favicon_base::FaviconBitmapResult bitmap_result; bitmap_result.icon_url = icon_url; bitmap_result.icon_type = icon_type; if (!thumbnail_db_->GetFaviconBitmap(best_bitmap_ids[i], @@ -2344,8 +2349,8 @@ bool HistoryBackend::GetFaviconBitmapResultsForBestMatch( bool HistoryBackend::SetFaviconMappingsForPageAndRedirects( const GURL& page_url, - chrome::IconType icon_type, - const std::vector<chrome::FaviconID>& icon_ids) { + favicon_base::IconType icon_type, + const std::vector<favicon_base::FaviconID>& icon_ids) { if (!thumbnail_db_) return false; @@ -2366,8 +2371,8 @@ bool HistoryBackend::SetFaviconMappingsForPageAndRedirects( bool HistoryBackend::SetFaviconMappingsForPage( const GURL& page_url, - chrome::IconType icon_type, - const std::vector<chrome::FaviconID>& icon_ids) { + favicon_base::IconType icon_type, + const std::vector<favicon_base::FaviconID>& icon_ids) { DCHECK_LE(icon_ids.size(), kMaxFaviconsPerPage); bool mappings_changed = false; @@ -2381,14 +2386,14 @@ bool HistoryBackend::SetFaviconMappingsForPage( // Remove any favicons which are orphaned as a result of the removal of the // icon mappings. - std::vector<chrome::FaviconID> unmapped_icon_ids = icon_ids; + std::vector<favicon_base::FaviconID> unmapped_icon_ids = icon_ids; std::vector<IconMapping> icon_mappings; thumbnail_db_->GetIconMappingsForPageURL(page_url, &icon_mappings); for (std::vector<IconMapping>::iterator m = icon_mappings.begin(); m != icon_mappings.end(); ++m) { - std::vector<chrome::FaviconID>::iterator icon_id_it = std::find( + std::vector<favicon_base::FaviconID>::iterator icon_id_it = std::find( unmapped_icon_ids.begin(), unmapped_icon_ids.end(), m->icon_id); // If the icon mapping already exists, avoid removing it and adding it back. @@ -2397,10 +2402,11 @@ bool HistoryBackend::SetFaviconMappingsForPage( continue; } - if ((icon_type == chrome::TOUCH_ICON && - m->icon_type == chrome::TOUCH_PRECOMPOSED_ICON) || - (icon_type == chrome::TOUCH_PRECOMPOSED_ICON && - m->icon_type == chrome::TOUCH_ICON) || (icon_type == m->icon_type)) { + if ((icon_type == favicon_base::TOUCH_ICON && + m->icon_type == favicon_base::TOUCH_PRECOMPOSED_ICON) || + (icon_type == favicon_base::TOUCH_PRECOMPOSED_ICON && + m->icon_type == favicon_base::TOUCH_ICON) || + (icon_type == m->icon_type)) { thumbnail_db_->DeleteIconMapping(m->mapping_id); // Removing the icon mapping may have orphaned the associated favicon so diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h index f312b1c..595681d 100644 --- a/chrome/browser/history/history_backend.h +++ b/chrome/browser/history/history_backend.h @@ -220,30 +220,31 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, // Favicon ------------------------------------------------------------------- - void GetFavicons(const std::vector<GURL>& icon_urls, - int icon_types, - int desired_size_in_dip, - const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<chrome::FaviconBitmapResult>* bitmap_results); + void GetFavicons( + const std::vector<GURL>& icon_urls, + int icon_types, + int desired_size_in_dip, + const std::vector<ui::ScaleFactor>& desired_scale_factors, + std::vector<favicon_base::FaviconBitmapResult>* bitmap_results); void GetLargestFaviconForURL( const GURL& page_url, const std::vector<int>& icon_types, int minimum_size_in_pixels, - chrome::FaviconBitmapResult* bitmap_result); + favicon_base::FaviconBitmapResult* bitmap_result); void GetFaviconsForURL( const GURL& page_url, int icon_types, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<chrome::FaviconBitmapResult>* bitmap_results); + std::vector<favicon_base::FaviconBitmapResult>* bitmap_results); void GetFaviconForID( - chrome::FaviconID favicon_id, + favicon_base::FaviconID favicon_id, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, - std::vector<chrome::FaviconBitmapResult>* bitmap_results); + std::vector<favicon_base::FaviconBitmapResult>* bitmap_results); void UpdateFaviconMappingsAndFetch( const GURL& page_url, @@ -251,18 +252,18 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, int icon_types, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<chrome::FaviconBitmapResult>* bitmap_results); + std::vector<favicon_base::FaviconBitmapResult>* bitmap_results); void MergeFavicon(const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, scoped_refptr<base::RefCountedMemory> bitmap_data, const gfx::Size& pixel_size); void SetFavicons( const GURL& page_url, - chrome::IconType icon_type, - const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data); + favicon_base::IconType icon_type, + const std::vector<favicon_base::FaviconBitmapData>& favicon_bitmap_data); void SetFaviconsOutOfDateForPage(const GURL& page_url); @@ -661,7 +662,7 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, int icon_types, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<chrome::FaviconBitmapResult>* results); + std::vector<favicon_base::FaviconBitmapResult>* results); // Set the favicon bitmaps for |icon_id|. // For each entry in |favicon_bitmap_data|, if a favicon bitmap already @@ -674,8 +675,8 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, // Computing |favicon_bitmaps_changed| requires additional database queries // so should be avoided if unnecessary. void SetFaviconBitmaps( - chrome::FaviconID icon_id, - const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data, + favicon_base::FaviconID icon_id, + const std::vector<favicon_base::FaviconBitmapData>& favicon_bitmap_data, bool* favicon_bitmaps_changed); // Returns true if |favicon_bitmap_data| passed to SetFavicons() is valid. @@ -684,8 +685,8 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, // kMaxFaviconsPerPage unique icon URLs. // kMaxFaviconBitmapsPerIconURL favicon bitmaps for each icon URL. // 2) FaviconBitmapData::bitmap_data contains non NULL bitmap data. - bool ValidateSetFaviconsParams( - const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data) const; + bool ValidateSetFaviconsParams(const std::vector< + favicon_base::FaviconBitmapData>& favicon_bitmap_data) const; // Returns true if the bitmap data at |bitmap_id| equals |new_bitmap_data|. bool IsFaviconBitmapDataEqual( @@ -708,7 +709,7 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, int icon_types, const int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results); + std::vector<favicon_base::FaviconBitmapResult>* favicon_bitmap_results); // Returns the favicon bitmaps which most closely match |desired_size_in_dip| // and |desired_scale_factors| in |favicon_bitmap_results|. If @@ -720,10 +721,10 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, // favicon bitmap is the best result for multiple scale factors. // Returns true if there were no errors. bool GetFaviconBitmapResultsForBestMatch( - const std::vector<chrome::FaviconID>& candidate_favicon_ids, + const std::vector<favicon_base::FaviconID>& candidate_favicon_ids, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results); + std::vector<favicon_base::FaviconBitmapResult>* favicon_bitmap_results); // Maps the favicon ids in |icon_ids| to |page_url| (and all redirects) // for |icon_type|. @@ -731,15 +732,15 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, // changed. bool SetFaviconMappingsForPageAndRedirects( const GURL& page_url, - chrome::IconType icon_type, - const std::vector<chrome::FaviconID>& icon_ids); + favicon_base::IconType icon_type, + const std::vector<favicon_base::FaviconID>& icon_ids); // Maps the favicon ids in |icon_ids| to |page_url| for |icon_type|. // Returns true if the function changed some of |page_url|'s mappings. bool SetFaviconMappingsForPage( const GURL& page_url, - chrome::IconType icon_type, - const std::vector<chrome::FaviconID>& icon_ids); + favicon_base::IconType icon_type, + const std::vector<favicon_base::FaviconID>& icon_ids); // Returns all the page URLs in the redirect chain for |page_url|. If there // are no known redirects for |page_url|, returns a vector with |page_url|. diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc index fc5ea50..e343591 100644 --- a/chrome/browser/history/history_backend_unittest.cc +++ b/chrome/browser/history/history_backend_unittest.cc @@ -261,7 +261,7 @@ class HistoryBackendTest : public testing::Test { // Returns the number of icon mappings of |icon_type| to |page_url|. size_t NumIconMappingsForPageURL(const GURL& page_url, - chrome::IconType icon_type) { + favicon_base::IconType icon_type) { std::vector<IconMapping> icon_mappings; backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url, icon_type, &icon_mappings); @@ -285,7 +285,7 @@ class HistoryBackendTest : public testing::Test { // Returns the favicon bitmaps for |icon_id| sorted by pixel size in // ascending order. Returns true if there is at least one favicon bitmap. - bool GetSortedFaviconBitmaps(chrome::FaviconID icon_id, + bool GetSortedFaviconBitmaps(favicon_base::FaviconID icon_id, std::vector<FaviconBitmap>* favicon_bitmaps) { if (!backend_->thumbnail_db_->GetFaviconBitmaps(icon_id, favicon_bitmaps)) return false; @@ -296,7 +296,7 @@ class HistoryBackendTest : public testing::Test { // Returns true if there is exactly one favicon bitmap associated to // |favicon_id|. If true, returns favicon bitmap in output parameter. - bool GetOnlyFaviconBitmap(const chrome::FaviconID icon_id, + bool GetOnlyFaviconBitmap(const favicon_base::FaviconID icon_id, FaviconBitmap* favicon_bitmap) { std::vector<FaviconBitmap> favicon_bitmaps; if (!backend_->thumbnail_db_->GetFaviconBitmaps(icon_id, &favicon_bitmaps)) @@ -313,7 +313,7 @@ class HistoryBackendTest : public testing::Test { void GenerateFaviconBitmapData( const GURL& icon_url1, const std::vector<gfx::Size>& icon_url1_sizes, - std::vector<chrome::FaviconBitmapData>* favicon_bitmap_data) { + std::vector<favicon_base::FaviconBitmapData>* favicon_bitmap_data) { GenerateFaviconBitmapData(icon_url1, icon_url1_sizes, GURL(), std::vector<gfx::Size>(), favicon_bitmap_data); } @@ -323,14 +323,14 @@ class HistoryBackendTest : public testing::Test { const std::vector<gfx::Size>& icon_url1_sizes, const GURL& icon_url2, const std::vector<gfx::Size>& icon_url2_sizes, - std::vector<chrome::FaviconBitmapData>* favicon_bitmap_data) { + std::vector<favicon_base::FaviconBitmapData>* favicon_bitmap_data) { favicon_bitmap_data->clear(); char bitmap_char = 'a'; for (size_t i = 0; i < icon_url1_sizes.size(); ++i) { std::vector<unsigned char> data; data.push_back(bitmap_char); - chrome::FaviconBitmapData bitmap_data_element; + favicon_base::FaviconBitmapData bitmap_data_element; bitmap_data_element.bitmap_data = base::RefCountedBytes::TakeVector(&data); bitmap_data_element.pixel_size = icon_url1_sizes[i]; @@ -343,7 +343,7 @@ class HistoryBackendTest : public testing::Test { for (size_t i = 0; i < icon_url2_sizes.size(); ++i) { std::vector<unsigned char> data; data.push_back(bitmap_char); - chrome::FaviconBitmapData bitmap_data_element; + favicon_base::FaviconBitmapData bitmap_data_element; bitmap_data_element.bitmap_data = base::RefCountedBytes::TakeVector(&data); bitmap_data_element.pixel_size = icon_url2_sizes[i]; @@ -449,10 +449,10 @@ TEST_F(HistoryBackendTest, DeleteAll) { // we can test that updating works properly. GURL favicon_url1("http://www.google.com/favicon.ico"); GURL favicon_url2("http://news.google.com/favicon.ico"); - chrome::FaviconID favicon2 = backend_->thumbnail_db_->AddFavicon(favicon_url2, - chrome::FAVICON); - chrome::FaviconID favicon1 = backend_->thumbnail_db_->AddFavicon(favicon_url1, - chrome::FAVICON); + favicon_base::FaviconID favicon2 = + backend_->thumbnail_db_->AddFavicon(favicon_url2, favicon_base::FAVICON); + favicon_base::FaviconID favicon1 = + backend_->thumbnail_db_->AddFavicon(favicon_url1, favicon_base::FAVICON); std::vector<unsigned char> data; data.push_back('a'); @@ -529,8 +529,9 @@ TEST_F(HistoryBackendTest, DeleteAll) { // We should have a favicon and favicon bitmaps for the first URL only. We // look them up by favicon URL since the IDs may have changed. - chrome::FaviconID out_favicon1 = backend_->thumbnail_db_-> - GetFaviconIDForFaviconURL(favicon_url1, chrome::FAVICON, NULL); + favicon_base::FaviconID out_favicon1 = + backend_->thumbnail_db_->GetFaviconIDForFaviconURL( + favicon_url1, favicon_base::FAVICON, NULL); EXPECT_TRUE(out_favicon1); std::vector<FaviconBitmap> favicon_bitmaps; @@ -554,15 +555,16 @@ TEST_F(HistoryBackendTest, DeleteAll) { EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmap2.bitmap_data)); EXPECT_EQ(kLargeSize, favicon_bitmap2.pixel_size); - chrome::FaviconID out_favicon2 = backend_->thumbnail_db_-> - GetFaviconIDForFaviconURL(favicon_url2, chrome::FAVICON, NULL); + favicon_base::FaviconID out_favicon2 = + backend_->thumbnail_db_->GetFaviconIDForFaviconURL( + favicon_url2, favicon_base::FAVICON, NULL); EXPECT_FALSE(out_favicon2) << "Favicon not deleted"; // The remaining URL should still reference the same favicon, even if its // ID has changed. std::vector<IconMapping> mappings; EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( - outrow1.url(), chrome::FAVICON, &mappings)); + outrow1.url(), favicon_base::FAVICON, &mappings)); EXPECT_EQ(1u, mappings.size()); EXPECT_EQ(out_favicon1, mappings[0].icon_id); @@ -620,20 +622,20 @@ TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) { std::vector<unsigned char> data; data.push_back('1'); - chrome::FaviconID favicon1 = backend_->thumbnail_db_->AddFavicon( - favicon_url1, - chrome::FAVICON, - new base::RefCountedBytes(data), - Time::Now(), - gfx::Size()); + favicon_base::FaviconID favicon1 = + backend_->thumbnail_db_->AddFavicon(favicon_url1, + favicon_base::FAVICON, + new base::RefCountedBytes(data), + Time::Now(), + gfx::Size()); data[0] = '2'; - chrome::FaviconID favicon2 = backend_->thumbnail_db_->AddFavicon( - favicon_url2, - chrome::FAVICON, - new base::RefCountedBytes(data), - Time::Now(), - gfx::Size()); + favicon_base::FaviconID favicon2 = + backend_->thumbnail_db_->AddFavicon(favicon_url2, + favicon_base::FAVICON, + new base::RefCountedBytes(data), + Time::Now(), + gfx::Size()); // First visit two URLs. URLRow row1(GURL("http://www.google.com/")); @@ -673,9 +675,8 @@ TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) { EXPECT_EQ(0U, visits.size()); // The favicon should still be valid. EXPECT_EQ(favicon2, - backend_->thumbnail_db_->GetFaviconIDForFaviconURL(favicon_url2, - chrome::FAVICON, - NULL)); + backend_->thumbnail_db_->GetFaviconIDForFaviconURL( + favicon_url2, favicon_base::FAVICON, NULL)); // Unstar row2. bookmark_utils::RemoveAllBookmarks(&bookmark_model_, row2.url()); @@ -690,9 +691,8 @@ TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) { EXPECT_FALSE(backend_->db_->GetRowForURL(row2.url(), &tmp_url_row)); // And the favicon should be deleted. EXPECT_EQ(0, - backend_->thumbnail_db_->GetFaviconIDForFaviconURL(favicon_url2, - chrome::FAVICON, - NULL)); + backend_->thumbnail_db_->GetFaviconIDForFaviconURL( + favicon_url2, favicon_base::FAVICON, NULL)); // Unstar row 1. bookmark_utils::RemoveAllBookmarks(&bookmark_model_, row1.url()); @@ -712,9 +712,8 @@ TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) { // The favicon should still be valid. EXPECT_EQ(favicon1, - backend_->thumbnail_db_->GetFaviconIDForFaviconURL(favicon_url1, - chrome::FAVICON, - NULL)); + backend_->thumbnail_db_->GetFaviconIDForFaviconURL( + favicon_url1, favicon_base::FAVICON, NULL)); } // Tests a handful of assertions for a navigation with a type of @@ -861,9 +860,9 @@ TEST_F(HistoryBackendTest, ImportedFaviconsTest) { GURL favicon_url1("http://www.google.com/favicon.ico"); std::vector<unsigned char> data; data.push_back('1'); - chrome::FaviconID favicon1 = backend_->thumbnail_db_->AddFavicon( + favicon_base::FaviconID favicon1 = backend_->thumbnail_db_->AddFavicon( favicon_url1, - chrome::FAVICON, + favicon_base::FAVICON, base::RefCountedBytes::TakeVector(&data), Time::Now(), gfx::Size()); @@ -882,8 +881,8 @@ TEST_F(HistoryBackendTest, ImportedFaviconsTest) { URLRow url_row1, url_row2; EXPECT_FALSE(backend_->db_->GetRowForURL(row1.url(), &url_row1) == 0); EXPECT_FALSE(backend_->db_->GetRowForURL(row2.url(), &url_row2) == 0); - EXPECT_EQ(1u, NumIconMappingsForPageURL(row1.url(), chrome::FAVICON)); - EXPECT_EQ(0u, NumIconMappingsForPageURL(row2.url(), chrome::FAVICON)); + EXPECT_EQ(1u, NumIconMappingsForPageURL(row1.url(), favicon_base::FAVICON)); + EXPECT_EQ(0u, NumIconMappingsForPageURL(row2.url(), favicon_base::FAVICON)); // Now provide one imported favicon for both URLs already in the registry. // The new favicon should only be used with the URL that doesn't already have @@ -901,14 +900,14 @@ TEST_F(HistoryBackendTest, ImportedFaviconsTest) { std::vector<IconMapping> mappings; EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( - row1.url(), chrome::FAVICON, &mappings)); + row1.url(), favicon_base::FAVICON, &mappings)); EXPECT_EQ(1u, mappings.size()); EXPECT_EQ(favicon1, mappings[0].icon_id); EXPECT_EQ(favicon_url1, mappings[0].icon_url); mappings.clear(); EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( - row2.url(), chrome::FAVICON, &mappings)); + row2.url(), favicon_base::FAVICON, &mappings)); EXPECT_EQ(1u, mappings.size()); EXPECT_EQ(favicon.favicon_url, mappings[0].icon_url); @@ -1331,55 +1330,60 @@ TEST_F(HistoryBackendTest, SetFaviconMappingsForPageAndRedirects) { const GURL icon_url2("http://www.google.com/icon2"); // Generate bitmap data for a page with two favicons. - std::vector<chrome::FaviconBitmapData> two_favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> two_favicon_bitmap_data; GenerateFaviconBitmapData(icon_url1, GetSizesSmallAndLarge(), icon_url2, GetSizesSmallAndLarge(), &two_favicon_bitmap_data); // Generate bitmap data for a page with a single favicon. - std::vector<chrome::FaviconBitmapData> one_favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> one_favicon_bitmap_data; GenerateFaviconBitmapData(icon_url1, GetSizesSmallAndLarge(), &one_favicon_bitmap_data); // Add two favicons - backend_->SetFavicons(url1, chrome::FAVICON, two_favicon_bitmap_data); - EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, chrome::FAVICON)); - EXPECT_EQ(2u, NumIconMappingsForPageURL(url2, chrome::FAVICON)); + backend_->SetFavicons(url1, favicon_base::FAVICON, two_favicon_bitmap_data); + EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON)); + EXPECT_EQ(2u, NumIconMappingsForPageURL(url2, favicon_base::FAVICON)); // Add one touch_icon - backend_->SetFavicons(url1, chrome::TOUCH_ICON, one_favicon_bitmap_data); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, chrome::TOUCH_ICON)); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url2, chrome::TOUCH_ICON)); - EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, chrome::FAVICON)); + backend_->SetFavicons( + url1, favicon_base::TOUCH_ICON, one_favicon_bitmap_data); + EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::TOUCH_ICON)); + EXPECT_EQ(1u, NumIconMappingsForPageURL(url2, favicon_base::TOUCH_ICON)); + EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON)); // Add one TOUCH_PRECOMPOSED_ICON backend_->SetFavicons( - url1, chrome::TOUCH_PRECOMPOSED_ICON, one_favicon_bitmap_data); + url1, favicon_base::TOUCH_PRECOMPOSED_ICON, one_favicon_bitmap_data); // The touch_icon was replaced. - EXPECT_EQ(0u, NumIconMappingsForPageURL(url1, chrome::TOUCH_ICON)); - EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, chrome::FAVICON)); - EXPECT_EQ(1u, - NumIconMappingsForPageURL(url1, chrome::TOUCH_PRECOMPOSED_ICON)); - EXPECT_EQ(1u, - NumIconMappingsForPageURL(url2, chrome::TOUCH_PRECOMPOSED_ICON)); + EXPECT_EQ(0u, NumIconMappingsForPageURL(url1, favicon_base::TOUCH_ICON)); + EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON)); + EXPECT_EQ( + 1u, + NumIconMappingsForPageURL(url1, favicon_base::TOUCH_PRECOMPOSED_ICON)); + EXPECT_EQ( + 1u, + NumIconMappingsForPageURL(url2, favicon_base::TOUCH_PRECOMPOSED_ICON)); // Add a touch_icon. - backend_->SetFavicons(url1, chrome::TOUCH_ICON, one_favicon_bitmap_data); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, chrome::TOUCH_ICON)); - EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, chrome::FAVICON)); + backend_->SetFavicons( + url1, favicon_base::TOUCH_ICON, one_favicon_bitmap_data); + EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::TOUCH_ICON)); + EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON)); // The TOUCH_PRECOMPOSED_ICON was replaced. - EXPECT_EQ(0u, - NumIconMappingsForPageURL(url1, chrome::TOUCH_PRECOMPOSED_ICON)); + EXPECT_EQ( + 0u, + NumIconMappingsForPageURL(url1, favicon_base::TOUCH_PRECOMPOSED_ICON)); // Add a single favicon. - backend_->SetFavicons(url1, chrome::FAVICON, one_favicon_bitmap_data); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, chrome::TOUCH_ICON)); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, chrome::FAVICON)); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url2, chrome::FAVICON)); + backend_->SetFavicons(url1, favicon_base::FAVICON, one_favicon_bitmap_data); + EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::TOUCH_ICON)); + EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON)); + EXPECT_EQ(1u, NumIconMappingsForPageURL(url2, favicon_base::FAVICON)); // Add two favicons. - backend_->SetFavicons(url1, chrome::FAVICON, two_favicon_bitmap_data); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, chrome::TOUCH_ICON)); - EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, chrome::FAVICON)); + backend_->SetFavicons(url1, favicon_base::FAVICON, two_favicon_bitmap_data); + EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, favicon_base::TOUCH_ICON)); + EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, favicon_base::FAVICON)); } // Test that there is no churn in icon mappings from calling @@ -1388,23 +1392,23 @@ TEST_F(HistoryBackendTest, SetFaviconMappingsForPageDuplicates) { const GURL url("http://www.google.com/"); const GURL icon_url("http://www.google.com/icon"); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesSmallAndLarge(), &favicon_bitmap_data); - backend_->SetFavicons(url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(url, favicon_base::FAVICON, favicon_bitmap_data); std::vector<IconMapping> icon_mappings; EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( - url, chrome::FAVICON, &icon_mappings)); + url, favicon_base::FAVICON, &icon_mappings)); EXPECT_EQ(1u, icon_mappings.size()); IconMappingID mapping_id = icon_mappings[0].mapping_id; - backend_->SetFavicons(url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(url, favicon_base::FAVICON, favicon_bitmap_data); icon_mappings.clear(); EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( - url, chrome::FAVICON, &icon_mappings)); + url, favicon_base::FAVICON, &icon_mappings)); EXPECT_EQ(1u, icon_mappings.size()); // The same row in the icon_mapping table should be used for the mapping as @@ -1419,18 +1423,18 @@ TEST_F(HistoryBackendTest, SetFaviconsDeleteBitmaps) { const GURL page_url("http://www.google.com/"); const GURL icon_url("http://www.google.com/icon"); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesSmallAndLarge(), &favicon_bitmap_data); - backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); // Test initial state. std::vector<IconMapping> icon_mappings; EXPECT_TRUE(GetSortedIconMappingsForPageURL(page_url, &icon_mappings)); EXPECT_EQ(1u, icon_mappings.size()); EXPECT_EQ(icon_url, icon_mappings[0].icon_url); - EXPECT_EQ(chrome::FAVICON, icon_mappings[0].icon_type); - chrome::FaviconID favicon_id = icon_mappings[0].icon_id; + EXPECT_EQ(favicon_base::FAVICON, icon_mappings[0].icon_type); + favicon_base::FaviconID favicon_id = icon_mappings[0].icon_id; std::vector<FaviconBitmap> favicon_bitmaps; EXPECT_TRUE(GetSortedFaviconBitmaps(favicon_id, &favicon_bitmaps)); @@ -1447,7 +1451,7 @@ TEST_F(HistoryBackendTest, SetFaviconsDeleteBitmaps) { // Call SetFavicons() with bitmap data for only the large bitmap. Check that // the small bitmap is in fact deleted. GenerateFaviconBitmapData(icon_url, GetSizesLarge(), &favicon_bitmap_data); - backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); scoped_refptr<base::RefCountedMemory> bitmap_data_out; gfx::Size pixel_size_out; @@ -1467,7 +1471,7 @@ TEST_F(HistoryBackendTest, SetFaviconsDeleteBitmaps) { // Call SetFavicons() with no bitmap data. Check that the bitmaps and icon // mappings are deleted. favicon_bitmap_data.clear(); - backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); EXPECT_FALSE(backend_->thumbnail_db_->GetFaviconBitmap(large_bitmap_id, NULL, NULL, NULL)); @@ -1487,20 +1491,20 @@ TEST_F(HistoryBackendTest, SetFaviconsReplaceBitmapData) { std::vector<unsigned char> data_initial; data_initial.push_back('a'); - chrome::FaviconBitmapData bitmap_data_element; + favicon_base::FaviconBitmapData bitmap_data_element; bitmap_data_element.bitmap_data = base::RefCountedBytes::TakeVector(&data_initial); bitmap_data_element.pixel_size = kSmallSize; bitmap_data_element.icon_url = icon_url; - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; favicon_bitmap_data.push_back(bitmap_data_element); // Add bitmap to the database. - backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); - chrome::FaviconID original_favicon_id = + favicon_base::FaviconID original_favicon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( - icon_url, chrome::FAVICON, NULL); + icon_url, favicon_base::FAVICON, NULL); EXPECT_NE(0, original_favicon_id); FaviconBitmap original_favicon_bitmap; EXPECT_TRUE( @@ -1513,11 +1517,11 @@ TEST_F(HistoryBackendTest, SetFaviconsReplaceBitmapData) { std::vector<unsigned char> updated_data; updated_data.push_back('a'); favicon_bitmap_data[0].bitmap_data = new base::RefCountedBytes(updated_data); - backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); - chrome::FaviconID updated_favicon_id = + favicon_base::FaviconID updated_favicon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( - icon_url, chrome::FAVICON, NULL); + icon_url, favicon_base::FAVICON, NULL); EXPECT_NE(0, updated_favicon_id); FaviconBitmap updated_favicon_bitmap; EXPECT_TRUE( @@ -1531,11 +1535,10 @@ TEST_F(HistoryBackendTest, SetFaviconsReplaceBitmapData) { // Call SetFavicons() with identical data but a different bitmap. updated_data[0] = 'b'; favicon_bitmap_data[0].bitmap_data = new base::RefCountedBytes(updated_data); - backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); - updated_favicon_id = - backend_->thumbnail_db_->GetFaviconIDForFaviconURL( - icon_url, chrome::FAVICON, NULL); + updated_favicon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( + icon_url, favicon_base::FAVICON, NULL); EXPECT_NE(0, updated_favicon_id); EXPECT_TRUE( GetOnlyFaviconBitmap(updated_favicon_id, &updated_favicon_bitmap)); @@ -1560,26 +1563,29 @@ TEST_F(HistoryBackendTest, SetFaviconsSameFaviconURLForTwoPages) { GURL page_url1("http://www.google.com"); GURL page_url2("http://www.google.ca"); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesSmallAndLarge(), &favicon_bitmap_data); - backend_->SetFavicons(page_url1, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url1, favicon_base::FAVICON, favicon_bitmap_data); std::vector<GURL> icon_urls; icon_urls.push_back(icon_url); - std::vector<chrome::FaviconBitmapResult> bitmap_results; - backend_->UpdateFaviconMappingsAndFetch( - page_url2, icon_urls, chrome::FAVICON, kSmallSize.width(), - GetScaleFactors1x2x(), &bitmap_results); + std::vector<favicon_base::FaviconBitmapResult> bitmap_results; + backend_->UpdateFaviconMappingsAndFetch(page_url2, + icon_urls, + favicon_base::FAVICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results); // Check that the same FaviconID is mapped to both page URLs. std::vector<IconMapping> icon_mappings; EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( page_url1, &icon_mappings)); EXPECT_EQ(1u, icon_mappings.size()); - chrome::FaviconID favicon_id = icon_mappings[0].icon_id; + favicon_base::FaviconID favicon_id = icon_mappings[0].icon_id; EXPECT_NE(0, favicon_id); icon_mappings.clear(); @@ -1591,7 +1597,7 @@ TEST_F(HistoryBackendTest, SetFaviconsSameFaviconURLForTwoPages) { // Change the icon URL that |page_url1| is mapped to. GenerateFaviconBitmapData(icon_url_new, GetSizesSmall(), &favicon_bitmap_data); - backend_->SetFavicons(page_url1, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url1, favicon_base::FAVICON, favicon_bitmap_data); // |page_url1| should map to a new FaviconID and have valid bitmap data. icon_mappings.clear(); @@ -1630,27 +1636,31 @@ TEST_F(HistoryBackendTest, SetFaviconsSameFaviconURLForTwoPages) { TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchNoChange) { GURL page_url("http://www.google.com"); GURL icon_url("http://www.google.com/favicon.ico"); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesSmall(), &favicon_bitmap_data); - backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); - chrome::FaviconID icon_id = - backend_->thumbnail_db_->GetFaviconIDForFaviconURL( - icon_url, chrome::FAVICON, NULL); + favicon_base::FaviconID icon_id = + backend_->thumbnail_db_->GetFaviconIDForFaviconURL( + icon_url, favicon_base::FAVICON, NULL); EXPECT_NE(0, icon_id); EXPECT_EQ(1, num_broadcasted_notifications()); std::vector<GURL> icon_urls; icon_urls.push_back(icon_url); - std::vector<chrome::FaviconBitmapResult> bitmap_results; - backend_->UpdateFaviconMappingsAndFetch( - page_url, icon_urls, chrome::FAVICON, kSmallSize.width(), - GetScaleFactors1x2x(), &bitmap_results); + std::vector<favicon_base::FaviconBitmapResult> bitmap_results; + backend_->UpdateFaviconMappingsAndFetch(page_url, + icon_urls, + favicon_base::FAVICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results); - EXPECT_EQ(icon_id, backend_->thumbnail_db_->GetFaviconIDForFaviconURL( - icon_url, chrome::FAVICON, NULL)); + EXPECT_EQ(icon_id, + backend_->thumbnail_db_->GetFaviconIDForFaviconURL( + icon_url, favicon_base::FAVICON, NULL)); // No notification should have been broadcast as no icon mapping, favicon, // or favicon bitmap was updated, added or removed. @@ -1669,7 +1679,7 @@ TEST_F(HistoryBackendTest, MergeFaviconPageURLNotInDB) { new base::RefCountedBytes(data)); backend_->MergeFavicon( - page_url, icon_url, chrome::FAVICON, bitmap_data, kSmallSize); + page_url, icon_url, favicon_base::FAVICON, bitmap_data, kSmallSize); // |page_url| should now be mapped to |icon_url| and the favicon bitmap should // not be expired. @@ -1688,7 +1698,7 @@ TEST_F(HistoryBackendTest, MergeFaviconPageURLNotInDB) { data[0] = 'b'; bitmap_data = new base::RefCountedBytes(data); backend_->MergeFavicon( - page_url, icon_url, chrome::FAVICON, bitmap_data, kSmallSize); + page_url, icon_url, favicon_base::FAVICON, bitmap_data, kSmallSize); // |page_url| should still have a single favicon bitmap. The bitmap data // should be updated. @@ -1710,11 +1720,11 @@ TEST_F(HistoryBackendTest, MergeFaviconPageURLInDB) { GURL icon_url1("http:/www.google.com/favicon.ico"); GURL icon_url2("http://www.google.com/favicon2.ico"); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url1, GetSizesSmall(), &favicon_bitmap_data); - backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); // Test initial state. std::vector<IconMapping> icon_mappings; @@ -1737,7 +1747,7 @@ TEST_F(HistoryBackendTest, MergeFaviconPageURLInDB) { scoped_refptr<base::RefCountedBytes> bitmap_data( new base::RefCountedBytes(data)); backend_->MergeFavicon( - page_url, icon_url1, chrome::FAVICON, bitmap_data, kSmallSize); + page_url, icon_url1, favicon_base::FAVICON, bitmap_data, kSmallSize); // All the data should stay the same and no notifications should have been // sent. @@ -1758,7 +1768,7 @@ TEST_F(HistoryBackendTest, MergeFaviconPageURLInDB) { data[0] = 'b'; bitmap_data = new base::RefCountedBytes(data); backend_->MergeFavicon( - page_url, icon_url1, chrome::FAVICON, bitmap_data, kSmallSize); + page_url, icon_url1, favicon_base::FAVICON, bitmap_data, kSmallSize); // The small favicon bitmap at |icon_url1| should be overwritten. icon_mappings.clear(); @@ -1777,7 +1787,7 @@ TEST_F(HistoryBackendTest, MergeFaviconPageURLInDB) { data[0] = 'c'; bitmap_data = new base::RefCountedBytes(data); backend_->MergeFavicon( - page_url, icon_url1, chrome::FAVICON, bitmap_data, kTinySize); + page_url, icon_url1, favicon_base::FAVICON, bitmap_data, kTinySize); // A new favicon bitmap should be created and the preexisting favicon bitmap // ('b') should be expired. @@ -1802,7 +1812,7 @@ TEST_F(HistoryBackendTest, MergeFaviconPageURLInDB) { data[0] = 'd'; bitmap_data = new base::RefCountedBytes(data); backend_->MergeFavicon( - page_url, icon_url2, chrome::FAVICON, bitmap_data, kSmallSize); + page_url, icon_url2, favicon_base::FAVICON, bitmap_data, kSmallSize); // The existing favicon bitmaps should be copied over to the newly created // favicon at |icon_url2|. |page_url| should solely be mapped to |icon_url2|. @@ -1837,11 +1847,11 @@ TEST_F(HistoryBackendTest, MergeFaviconIconURLMappedToDifferentPageURL) { GURL page_url3("http://maps.google.com"); GURL icon_url("http:/www.google.com/favicon.ico"); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesSmall(), &favicon_bitmap_data); - backend_->SetFavicons(page_url1, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url1, favicon_base::FAVICON, favicon_bitmap_data); // Test initial state. std::vector<IconMapping> icon_mappings; @@ -1863,11 +1873,11 @@ TEST_F(HistoryBackendTest, MergeFaviconIconURLMappedToDifferentPageURL) { new base::RefCountedBytes(data)); backend_->MergeFavicon( - page_url2, icon_url, chrome::FAVICON, bitmap_data, kSmallSize); + page_url2, icon_url, favicon_base::FAVICON, bitmap_data, kSmallSize); - chrome::FaviconID favicon_id = - backend_->thumbnail_db_->GetFaviconIDForFaviconURL( - icon_url, chrome::FAVICON, NULL); + favicon_base::FaviconID favicon_id = + backend_->thumbnail_db_->GetFaviconIDForFaviconURL( + icon_url, favicon_base::FAVICON, NULL); EXPECT_NE(0, favicon_id); EXPECT_TRUE(GetOnlyFaviconBitmap(favicon_id, &favicon_bitmap)); @@ -1879,10 +1889,10 @@ TEST_F(HistoryBackendTest, MergeFaviconIconURLMappedToDifferentPageURL) { // URL should overwrite the small favicon bitmap at |icon_url|. bitmap_data->data()[0] = 'b'; backend_->MergeFavicon( - page_url3, icon_url, chrome::FAVICON, bitmap_data, kSmallSize); + page_url3, icon_url, favicon_base::FAVICON, bitmap_data, kSmallSize); favicon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( - icon_url, chrome::FAVICON, NULL); + icon_url, favicon_base::FAVICON, NULL); EXPECT_NE(0, favicon_id); EXPECT_TRUE(GetOnlyFaviconBitmap(favicon_id, &favicon_bitmap)); @@ -1931,7 +1941,10 @@ TEST_F(HistoryBackendTest, MergeFaviconMaxFaviconBitmapsPerIconURL) { icon_url_string[replace_index] = '0' + i; GURL icon_url(icon_url_string); - backend_->MergeFavicon(page_url, icon_url, chrome::FAVICON, bitmap_data, + backend_->MergeFavicon(page_url, + icon_url, + favicon_base::FAVICON, + bitmap_data, gfx::Size(pixel_size, pixel_size)); ++pixel_size; } @@ -1955,30 +1968,36 @@ TEST_F(HistoryBackendTest, MergeFaviconShowsUpInGetFaviconsForURLResult) { GURL icon_url("http://www.google.com/favicon.ico"); GURL merged_icon_url("http://wwww.google.com/favicon2.ico"); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesSmallAndLarge(), &favicon_bitmap_data); // Set some preexisting favicons for |page_url|. - backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); // Merge small favicon. std::vector<unsigned char> data; data.push_back('c'); scoped_refptr<base::RefCountedBytes> bitmap_data( new base::RefCountedBytes(data)); - backend_->MergeFavicon( - page_url, merged_icon_url, chrome::FAVICON, bitmap_data, kSmallSize); + backend_->MergeFavicon(page_url, + merged_icon_url, + favicon_base::FAVICON, + bitmap_data, + kSmallSize); // Request favicon bitmaps for both 1x and 2x to simulate request done by // BookmarkModel::GetFavicon(). - std::vector<chrome::FaviconBitmapResult> bitmap_results; - backend_->GetFaviconsForURL(page_url, chrome::FAVICON, kSmallSize.width(), - GetScaleFactors1x2x(), &bitmap_results); + std::vector<favicon_base::FaviconBitmapResult> bitmap_results; + backend_->GetFaviconsForURL(page_url, + favicon_base::FAVICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results); EXPECT_EQ(2u, bitmap_results.size()); - const chrome::FaviconBitmapResult& first_result = bitmap_results[0]; - const chrome::FaviconBitmapResult& result = + const favicon_base::FaviconBitmapResult& first_result = bitmap_results[0]; + const favicon_base::FaviconBitmapResult& result = (first_result.pixel_size == kSmallSize) ? first_result : bitmap_results[1]; EXPECT_TRUE(BitmapDataEqual('c', result.bitmap_data)); @@ -1990,38 +2009,39 @@ TEST_F(HistoryBackendTest, TestGetFaviconsForURLWithIconTypesPriority) { GURL icon_url("http://www.google.com/favicon.ico"); GURL touch_icon_url("http://wwww.google.com/touch_icon.ico"); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; std::vector<gfx::Size> favicon_size; favicon_size.push_back(gfx::Size(16, 16)); favicon_size.push_back(gfx::Size(32, 32)); GenerateFaviconBitmapData(icon_url, favicon_size, &favicon_bitmap_data); ASSERT_EQ(2u, favicon_bitmap_data.size()); - std::vector<chrome::FaviconBitmapData> touch_icon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> touch_icon_bitmap_data; std::vector<gfx::Size> touch_icon_size; touch_icon_size.push_back(gfx::Size(64, 64)); GenerateFaviconBitmapData(icon_url, touch_icon_size, &touch_icon_bitmap_data); ASSERT_EQ(1u, touch_icon_bitmap_data.size()); // Set some preexisting favicons for |page_url|. - backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); - backend_->SetFavicons(page_url, chrome::TOUCH_ICON, touch_icon_bitmap_data); + backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); + backend_->SetFavicons( + page_url, favicon_base::TOUCH_ICON, touch_icon_bitmap_data); - chrome::FaviconBitmapResult result; + favicon_base::FaviconBitmapResult result; std::vector<int> icon_types; - icon_types.push_back(chrome::FAVICON); - icon_types.push_back(chrome::TOUCH_ICON); + icon_types.push_back(favicon_base::FAVICON); + icon_types.push_back(favicon_base::TOUCH_ICON); backend_->GetLargestFaviconForURL(page_url, icon_types, 16, &result); // Verify the result icon is 32x32 favicon. EXPECT_EQ(gfx::Size(32, 32), result.pixel_size); - EXPECT_EQ(chrome::FAVICON, result.icon_type); + EXPECT_EQ(favicon_base::FAVICON, result.icon_type); // Change Minimal size to 32x32 and verify the 64x64 touch icon returned. backend_->GetLargestFaviconForURL(page_url, icon_types, 32, &result); EXPECT_EQ(gfx::Size(64, 64), result.pixel_size); - EXPECT_EQ(chrome::TOUCH_ICON, result.icon_type); + EXPECT_EQ(favicon_base::TOUCH_ICON, result.icon_type); } // Test the the first types of icon is returned if its size equal to the @@ -2031,39 +2051,40 @@ TEST_F(HistoryBackendTest, TestGetFaviconsForURLReturnFavicon) { GURL icon_url("http://www.google.com/favicon.ico"); GURL touch_icon_url("http://wwww.google.com/touch_icon.ico"); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; std::vector<gfx::Size> favicon_size; favicon_size.push_back(gfx::Size(16, 16)); favicon_size.push_back(gfx::Size(32, 32)); GenerateFaviconBitmapData(icon_url, favicon_size, &favicon_bitmap_data); ASSERT_EQ(2u, favicon_bitmap_data.size()); - std::vector<chrome::FaviconBitmapData> touch_icon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> touch_icon_bitmap_data; std::vector<gfx::Size> touch_icon_size; touch_icon_size.push_back(gfx::Size(32, 32)); GenerateFaviconBitmapData(icon_url, touch_icon_size, &touch_icon_bitmap_data); ASSERT_EQ(1u, touch_icon_bitmap_data.size()); // Set some preexisting favicons for |page_url|. - backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); - backend_->SetFavicons(page_url, chrome::TOUCH_ICON, touch_icon_bitmap_data); + backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); + backend_->SetFavicons( + page_url, favicon_base::TOUCH_ICON, touch_icon_bitmap_data); - chrome::FaviconBitmapResult result; + favicon_base::FaviconBitmapResult result; std::vector<int> icon_types; - icon_types.push_back(chrome::FAVICON); - icon_types.push_back(chrome::TOUCH_ICON); + icon_types.push_back(favicon_base::FAVICON); + icon_types.push_back(favicon_base::TOUCH_ICON); backend_->GetLargestFaviconForURL(page_url, icon_types, 16, &result); // Verify the result icon is 32x32 favicon. EXPECT_EQ(gfx::Size(32, 32), result.pixel_size); - EXPECT_EQ(chrome::FAVICON, result.icon_type); + EXPECT_EQ(favicon_base::FAVICON, result.icon_type); // Change minimal size to 32x32 and verify the 32x32 favicon returned. - chrome::FaviconBitmapResult result1; + favicon_base::FaviconBitmapResult result1; backend_->GetLargestFaviconForURL(page_url, icon_types, 32, &result1); EXPECT_EQ(gfx::Size(32, 32), result1.pixel_size); - EXPECT_EQ(chrome::FAVICON, result1.icon_type); + EXPECT_EQ(favicon_base::FAVICON, result1.icon_type); } // Test the favicon is returned if its size is smaller than minimal size, @@ -2072,25 +2093,25 @@ TEST_F(HistoryBackendTest, TestGetFaviconsForURLReturnFaviconEvenItSmaller) { GURL page_url("http://www.google.com"); GURL icon_url("http://www.google.com/favicon.ico"); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; std::vector<gfx::Size> favicon_size; favicon_size.push_back(gfx::Size(16, 16)); GenerateFaviconBitmapData(icon_url, favicon_size, &favicon_bitmap_data); ASSERT_EQ(1u, favicon_bitmap_data.size()); // Set preexisting favicons for |page_url|. - backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); - chrome::FaviconBitmapResult result; + favicon_base::FaviconBitmapResult result; std::vector<int> icon_types; - icon_types.push_back(chrome::FAVICON); - icon_types.push_back(chrome::TOUCH_ICON); + icon_types.push_back(favicon_base::FAVICON); + icon_types.push_back(favicon_base::TOUCH_ICON); backend_->GetLargestFaviconForURL(page_url, icon_types, 32, &result); // Verify 16x16 icon is returned, even it small than minimal_size. EXPECT_EQ(gfx::Size(16, 16), result.pixel_size); - EXPECT_EQ(chrome::FAVICON, result.icon_type); + EXPECT_EQ(favicon_base::FAVICON, result.icon_type); } // Test UpdateFaviconMapingsAndFetch() when multiple icon types are passed in. @@ -2103,27 +2124,28 @@ TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchMultipleIconTypes) { GURL icon_urlc("http://www.google.com/favicon3.ico"); // |page_url1| is mapped to |icon_urla| which if of type TOUCH_ICON. - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_urla, GetSizesSmall(), &favicon_bitmap_data); - backend_->SetFavicons(page_url1, chrome::TOUCH_ICON, favicon_bitmap_data); + backend_->SetFavicons( + page_url1, favicon_base::TOUCH_ICON, favicon_bitmap_data); // |page_url2| is mapped to |icon_urlb| and |icon_urlc| which are of type // TOUCH_PRECOMPOSED_ICON. GenerateFaviconBitmapData(icon_urlb, GetSizesSmall(), icon_urlc, GetSizesSmall(), &favicon_bitmap_data); backend_->SetFavicons( - page_url2, chrome::TOUCH_PRECOMPOSED_ICON, favicon_bitmap_data); + page_url2, favicon_base::TOUCH_PRECOMPOSED_ICON, favicon_bitmap_data); std::vector<GURL> icon_urls; icon_urls.push_back(icon_urla); icon_urls.push_back(icon_urlb); icon_urls.push_back(icon_urlc); - std::vector<chrome::FaviconBitmapResult> bitmap_results; + std::vector<favicon_base::FaviconBitmapResult> bitmap_results; backend_->UpdateFaviconMappingsAndFetch( page_url3, icon_urls, - (chrome::TOUCH_ICON | chrome::TOUCH_PRECOMPOSED_ICON), + (favicon_base::TOUCH_ICON | favicon_base::TOUCH_PRECOMPOSED_ICON), kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results); @@ -2134,15 +2156,15 @@ TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchMultipleIconTypes) { &icon_mappings)); EXPECT_EQ(1u, icon_mappings.size()); EXPECT_EQ(icon_urla, icon_mappings[0].icon_url); - EXPECT_EQ(chrome::TOUCH_ICON, icon_mappings[0].icon_type); + EXPECT_EQ(favicon_base::TOUCH_ICON, icon_mappings[0].icon_type); icon_mappings.clear(); EXPECT_TRUE(GetSortedIconMappingsForPageURL(page_url2, &icon_mappings)); EXPECT_EQ(2u, icon_mappings.size()); EXPECT_EQ(icon_urlb, icon_mappings[0].icon_url); - EXPECT_EQ(chrome::TOUCH_PRECOMPOSED_ICON, icon_mappings[0].icon_type); + EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, icon_mappings[0].icon_type); EXPECT_EQ(icon_urlc, icon_mappings[1].icon_url); - EXPECT_EQ(chrome::TOUCH_PRECOMPOSED_ICON, icon_mappings[1].icon_type); + EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, icon_mappings[1].icon_type); // |page_url3| should be mapped only to |icon_urlb| and |icon_urlc| as // TOUCH_PRECOMPOSED_ICON is the largest IconType. @@ -2150,9 +2172,9 @@ TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchMultipleIconTypes) { EXPECT_TRUE(GetSortedIconMappingsForPageURL(page_url3, &icon_mappings)); EXPECT_EQ(2u, icon_mappings.size()); EXPECT_EQ(icon_urlb, icon_mappings[0].icon_url); - EXPECT_EQ(chrome::TOUCH_PRECOMPOSED_ICON, icon_mappings[0].icon_type); + EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, icon_mappings[0].icon_type); EXPECT_EQ(icon_urlc, icon_mappings[1].icon_url); - EXPECT_EQ(chrome::TOUCH_PRECOMPOSED_ICON, icon_mappings[1].icon_type); + EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, icon_mappings[1].icon_type); } // Test the results of GetFaviconsFromDB() when there are no found @@ -2160,9 +2182,12 @@ TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchMultipleIconTypes) { TEST_F(HistoryBackendTest, GetFaviconsFromDBEmpty) { const GURL page_url("http://www.google.com/"); - std::vector<chrome::FaviconBitmapResult> bitmap_results; - EXPECT_FALSE(backend_->GetFaviconsFromDB(page_url, chrome::FAVICON, - kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results)); + std::vector<favicon_base::FaviconBitmapResult> bitmap_results; + EXPECT_FALSE(backend_->GetFaviconsFromDB(page_url, + favicon_base::FAVICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results)); EXPECT_TRUE(bitmap_results.empty()); } @@ -2172,14 +2197,17 @@ TEST_F(HistoryBackendTest, GetFaviconsFromDBNoFaviconBitmaps) { const GURL page_url("http://www.google.com/"); const GURL icon_url("http://www.google.com/icon1"); - chrome::FaviconID icon_id = backend_->thumbnail_db_->AddFavicon( - icon_url, chrome::FAVICON); + favicon_base::FaviconID icon_id = + backend_->thumbnail_db_->AddFavicon(icon_url, favicon_base::FAVICON); EXPECT_NE(0, icon_id); EXPECT_NE(0, backend_->thumbnail_db_->AddIconMapping(page_url, icon_id)); - std::vector<chrome::FaviconBitmapResult> bitmap_results_out; - EXPECT_FALSE(backend_->GetFaviconsFromDB(page_url, chrome::FAVICON, - kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); + std::vector<favicon_base::FaviconBitmapResult> bitmap_results_out; + EXPECT_FALSE(backend_->GetFaviconsFromDB(page_url, + favicon_base::FAVICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results_out)); EXPECT_TRUE(bitmap_results_out.empty()); } @@ -2189,15 +2217,15 @@ TEST_F(HistoryBackendTest, GetFaviconsFromDBSelectClosestMatch) { const GURL page_url("http://www.google.com/"); const GURL icon_url("http://www.google.com/icon1"); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesTinySmallAndLarge(), &favicon_bitmap_data); - backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); - std::vector<chrome::FaviconBitmapResult> bitmap_results_out; + std::vector<favicon_base::FaviconBitmapResult> bitmap_results_out; EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, - chrome::FAVICON, + favicon_base::FAVICON, kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); @@ -2207,7 +2235,7 @@ TEST_F(HistoryBackendTest, GetFaviconsFromDBSelectClosestMatch) { EXPECT_EQ(2u, bitmap_results_out.size()); // No required order for results. if (bitmap_results_out[0].pixel_size == kLargeSize) { - chrome::FaviconBitmapResult tmp_result = bitmap_results_out[0]; + favicon_base::FaviconBitmapResult tmp_result = bitmap_results_out[0]; bitmap_results_out[0] = bitmap_results_out[1]; bitmap_results_out[1] = tmp_result; } @@ -2216,13 +2244,13 @@ TEST_F(HistoryBackendTest, GetFaviconsFromDBSelectClosestMatch) { EXPECT_TRUE(BitmapDataEqual('b', bitmap_results_out[0].bitmap_data)); EXPECT_EQ(kSmallSize, bitmap_results_out[0].pixel_size); EXPECT_EQ(icon_url, bitmap_results_out[0].icon_url); - EXPECT_EQ(chrome::FAVICON, bitmap_results_out[0].icon_type); + EXPECT_EQ(favicon_base::FAVICON, bitmap_results_out[0].icon_type); EXPECT_FALSE(bitmap_results_out[1].expired); EXPECT_TRUE(BitmapDataEqual('c', bitmap_results_out[1].bitmap_data)); EXPECT_EQ(kLargeSize, bitmap_results_out[1].pixel_size); EXPECT_EQ(icon_url, bitmap_results_out[1].icon_url); - EXPECT_EQ(chrome::FAVICON, bitmap_results_out[1].icon_type); + EXPECT_EQ(favicon_base::FAVICON, bitmap_results_out[1].icon_type); } // Test that GetFaviconsFromDB() returns results from the icon URL whose @@ -2233,15 +2261,15 @@ TEST_F(HistoryBackendTest, GetFaviconsFromDBSingleIconURL) { const GURL icon_url1("http://www.google.com/icon1"); const GURL icon_url2("http://www.google.com/icon2"); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url1, GetSizesSmall(), icon_url2, GetSizesLarge(), &favicon_bitmap_data); - backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); - std::vector<chrome::FaviconBitmapResult> bitmap_results_out; + std::vector<favicon_base::FaviconBitmapResult> bitmap_results_out; EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, - chrome::FAVICON, + favicon_base::FAVICON, kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); @@ -2260,27 +2288,34 @@ TEST_F(HistoryBackendTest, GetFaviconsFromDBIconType) { const GURL icon_url1("http://www.google.com/icon1.png"); const GURL icon_url2("http://www.google.com/icon2.png"); - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url1, GetSizesSmall(), &favicon_bitmap_data); - backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, favicon_base::FAVICON, favicon_bitmap_data); GenerateFaviconBitmapData(icon_url2, GetSizesSmall(), &favicon_bitmap_data); - backend_->SetFavicons(page_url, chrome::TOUCH_ICON, favicon_bitmap_data); + backend_->SetFavicons( + page_url, favicon_base::TOUCH_ICON, favicon_bitmap_data); - std::vector<chrome::FaviconBitmapResult> bitmap_results_out; - EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, chrome::FAVICON, - kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); + std::vector<favicon_base::FaviconBitmapResult> bitmap_results_out; + EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, + favicon_base::FAVICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results_out)); EXPECT_EQ(1u, bitmap_results_out.size()); - EXPECT_EQ(chrome::FAVICON, bitmap_results_out[0].icon_type); + EXPECT_EQ(favicon_base::FAVICON, bitmap_results_out[0].icon_type); EXPECT_EQ(icon_url1, bitmap_results_out[0].icon_url); bitmap_results_out.clear(); - EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, chrome::TOUCH_ICON, - kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); + EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, + favicon_base::TOUCH_ICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results_out)); EXPECT_EQ(1u, bitmap_results_out.size()); - EXPECT_EQ(chrome::TOUCH_ICON, bitmap_results_out[0].icon_type); + EXPECT_EQ(favicon_base::TOUCH_ICON, bitmap_results_out[0].icon_type); EXPECT_EQ(icon_url2, bitmap_results_out[0].icon_url); } @@ -2295,18 +2330,17 @@ TEST_F(HistoryBackendTest, GetFaviconsFromDBExpired) { scoped_refptr<base::RefCountedBytes> bitmap_data( base::RefCountedBytes::TakeVector(&data)); base::Time last_updated = base::Time::FromTimeT(0); - chrome::FaviconID icon_id = - backend_->thumbnail_db_->AddFavicon(icon_url, - chrome::FAVICON, - bitmap_data, - last_updated, - kSmallSize); + favicon_base::FaviconID icon_id = backend_->thumbnail_db_->AddFavicon( + icon_url, favicon_base::FAVICON, bitmap_data, last_updated, kSmallSize); EXPECT_NE(0, icon_id); EXPECT_NE(0, backend_->thumbnail_db_->AddIconMapping(page_url, icon_id)); - std::vector<chrome::FaviconBitmapResult> bitmap_results_out; - EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, chrome::FAVICON, - kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); + std::vector<favicon_base::FaviconBitmapResult> bitmap_results_out; + EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, + favicon_base::FAVICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results_out)); EXPECT_EQ(1u, bitmap_results_out.size()); EXPECT_TRUE(bitmap_results_out[0].expired); @@ -2318,11 +2352,14 @@ TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchNoDB) { // Make the thumbnail database invalid. backend_->thumbnail_db_.reset(); - std::vector<chrome::FaviconBitmapResult> bitmap_results; + std::vector<favicon_base::FaviconBitmapResult> bitmap_results; - backend_->UpdateFaviconMappingsAndFetch( - GURL(), std::vector<GURL>(), chrome::FAVICON, kSmallSize.width(), - GetScaleFactors1x2x(), &bitmap_results); + backend_->UpdateFaviconMappingsAndFetch(GURL(), + std::vector<GURL>(), + favicon_base::FAVICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results); EXPECT_TRUE(bitmap_results.empty()); } @@ -2334,30 +2371,45 @@ TEST_F(HistoryBackendTest, CloneFaviconIsRestrictedToSameDomain) { const GURL icon_url("http://www.google.com/icon.png"); // Add a favicon - std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; + std::vector<favicon_base::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesSmall(), &favicon_bitmap_data); - backend_->SetFavicons(url, chrome::FAVICON, favicon_bitmap_data); + backend_->SetFavicons(url, favicon_base::FAVICON, favicon_bitmap_data); EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( - url, chrome::FAVICON, NULL)); + url, favicon_base::FAVICON, NULL)); // Validate starting state. - std::vector<chrome::FaviconBitmapResult> bitmap_results_out; - EXPECT_TRUE(backend_->GetFaviconsFromDB(url, chrome::FAVICON, - kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); - EXPECT_FALSE(backend_->GetFaviconsFromDB(same_domain_url, chrome::FAVICON, - kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); - EXPECT_FALSE(backend_->GetFaviconsFromDB(foreign_domain_url, chrome::FAVICON, - kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); + std::vector<favicon_base::FaviconBitmapResult> bitmap_results_out; + EXPECT_TRUE(backend_->GetFaviconsFromDB(url, + favicon_base::FAVICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results_out)); + EXPECT_FALSE(backend_->GetFaviconsFromDB(same_domain_url, + favicon_base::FAVICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results_out)); + EXPECT_FALSE(backend_->GetFaviconsFromDB(foreign_domain_url, + favicon_base::FAVICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results_out)); // Same-domain cloning should work. backend_->CloneFavicons(url, same_domain_url); - EXPECT_TRUE(backend_->GetFaviconsFromDB(same_domain_url, chrome::FAVICON, - kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); + EXPECT_TRUE(backend_->GetFaviconsFromDB(same_domain_url, + favicon_base::FAVICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results_out)); // Foreign-domain cloning is forbidden. backend_->CloneFavicons(url, foreign_domain_url); - EXPECT_FALSE(backend_->GetFaviconsFromDB(foreign_domain_url, chrome::FAVICON, - kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); + EXPECT_FALSE(backend_->GetFaviconsFromDB(foreign_domain_url, + favicon_base::FAVICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results_out)); } TEST_F(HistoryBackendTest, QueryFilteredURLs) { diff --git a/chrome/browser/history/history_service.cc b/chrome/browser/history/history_service.cc index dc77627..53d3f82 100644 --- a/chrome/browser/history/history_service.cc +++ b/chrome/browser/history/history_service.cc @@ -75,13 +75,12 @@ static const char* kHistoryThreadName = "Chrome_HistoryThread"; void RunWithFaviconResults( const FaviconService::FaviconResultsCallback& callback, - std::vector<chrome::FaviconBitmapResult>* bitmap_results) { + std::vector<favicon_base::FaviconBitmapResult>* bitmap_results) { callback.Run(*bitmap_results); } -void RunWithFaviconResult( - const FaviconService::FaviconRawCallback& callback, - chrome::FaviconBitmapResult* bitmap_result) { +void RunWithFaviconResult(const FaviconService::FaviconRawCallback& callback, + favicon_base::FaviconBitmapResult* bitmap_result) { callback.Run(*bitmap_result); } @@ -564,8 +563,8 @@ base::CancelableTaskTracker::TaskId HistoryService::GetFavicons( base::CancelableTaskTracker* tracker) { DCHECK(thread_checker_.CalledOnValidThread()); - std::vector<chrome::FaviconBitmapResult>* results = - new std::vector<chrome::FaviconBitmapResult>(); + std::vector<favicon_base::FaviconBitmapResult>* results = + new std::vector<favicon_base::FaviconBitmapResult>(); return tracker->PostTaskAndReply( thread_->message_loop_proxy().get(), FROM_HERE, @@ -588,8 +587,8 @@ base::CancelableTaskTracker::TaskId HistoryService::GetFaviconsForURL( base::CancelableTaskTracker* tracker) { DCHECK(thread_checker_.CalledOnValidThread()); - std::vector<chrome::FaviconBitmapResult>* results = - new std::vector<chrome::FaviconBitmapResult>(); + std::vector<favicon_base::FaviconBitmapResult>* results = + new std::vector<favicon_base::FaviconBitmapResult>(); return tracker->PostTaskAndReply( thread_->message_loop_proxy().get(), FROM_HERE, @@ -611,7 +610,8 @@ base::CancelableTaskTracker::TaskId HistoryService::GetLargestFaviconForURL( base::CancelableTaskTracker* tracker) { DCHECK(thread_checker_.CalledOnValidThread()); - chrome::FaviconBitmapResult* result = new chrome::FaviconBitmapResult(); + favicon_base::FaviconBitmapResult* result = + new favicon_base::FaviconBitmapResult(); return tracker->PostTaskAndReply( thread_->message_loop_proxy().get(), FROM_HERE, @@ -625,15 +625,15 @@ base::CancelableTaskTracker::TaskId HistoryService::GetLargestFaviconForURL( } base::CancelableTaskTracker::TaskId HistoryService::GetFaviconForID( - chrome::FaviconID favicon_id, + favicon_base::FaviconID favicon_id, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, const FaviconService::FaviconResultsCallback& callback, base::CancelableTaskTracker* tracker) { DCHECK(thread_checker_.CalledOnValidThread()); - std::vector<chrome::FaviconBitmapResult>* results = - new std::vector<chrome::FaviconBitmapResult>(); + std::vector<favicon_base::FaviconBitmapResult>* results = + new std::vector<favicon_base::FaviconBitmapResult>(); return tracker->PostTaskAndReply( thread_->message_loop_proxy().get(), FROM_HERE, @@ -657,8 +657,8 @@ HistoryService::UpdateFaviconMappingsAndFetch( base::CancelableTaskTracker* tracker) { DCHECK(thread_checker_.CalledOnValidThread()); - std::vector<chrome::FaviconBitmapResult>* results = - new std::vector<chrome::FaviconBitmapResult>(); + std::vector<favicon_base::FaviconBitmapResult>* results = + new std::vector<favicon_base::FaviconBitmapResult>(); return tracker->PostTaskAndReply( thread_->message_loop_proxy().get(), FROM_HERE, @@ -676,7 +676,7 @@ HistoryService::UpdateFaviconMappingsAndFetch( void HistoryService::MergeFavicon( const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, scoped_refptr<base::RefCountedMemory> bitmap_data, const gfx::Size& pixel_size) { DCHECK(thread_checker_.CalledOnValidThread()); @@ -689,8 +689,8 @@ void HistoryService::MergeFavicon( void HistoryService::SetFavicons( const GURL& page_url, - chrome::IconType icon_type, - const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data) { + favicon_base::IconType icon_type, + const std::vector<favicon_base::FaviconBitmapData>& favicon_bitmap_data) { DCHECK(thread_checker_.CalledOnValidThread()); if (!CanAddURL(page_url)) return; diff --git a/chrome/browser/history/history_service.h b/chrome/browser/history/history_service.h index fec0c64..aaedce4 100644 --- a/chrome/browser/history/history_service.h +++ b/chrome/browser/history/history_service.h @@ -706,7 +706,7 @@ class HistoryService : public CancelableRequestProvider, // with |favicon_id| from the history backend. If |desired_size_in_dip| is 0, // the largest favicon bitmap for |favicon_id| is returned. base::CancelableTaskTracker::TaskId GetFaviconForID( - chrome::FaviconID favicon_id, + favicon_base::FaviconID favicon_id, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, const FaviconService::FaviconResultsCallback& callback, @@ -762,7 +762,7 @@ class HistoryService : public CancelableRequestProvider, // TODO(pkotwicz): Remove once no longer required by sync. void MergeFavicon(const GURL& page_url, const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, scoped_refptr<base::RefCountedMemory> bitmap_data, const gfx::Size& pixel_size); @@ -779,8 +779,8 @@ class HistoryService : public CancelableRequestProvider, // criteria for |favicon_bitmap_data| to be valid. void SetFavicons( const GURL& page_url, - chrome::IconType icon_type, - const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data); + favicon_base::IconType icon_type, + const std::vector<favicon_base::FaviconBitmapData>& favicon_bitmap_data); // Used by the FaviconService to mark the favicon for the page as being out // of date. diff --git a/chrome/browser/history/history_types.cc b/chrome/browser/history/history_types.cc index 8dcbfc0..7136720 100644 --- a/chrome/browser/history/history_types.cc +++ b/chrome/browser/history/history_types.cc @@ -392,10 +392,7 @@ bool RowQualifiesAsSignificant(const URLRow& row, // IconMapping ---------------------------------------------------------------- IconMapping::IconMapping() - : mapping_id(0), - icon_id(0), - icon_type(chrome::INVALID_ICON) { -} + : mapping_id(0), icon_id(0), icon_type(favicon_base::INVALID_ICON) {} IconMapping::~IconMapping() {} diff --git a/chrome/browser/history/history_types.h b/chrome/browser/history/history_types.h index 4fe5b57..a7eb39e 100644 --- a/chrome/browser/history/history_types.h +++ b/chrome/browser/history/history_types.h @@ -18,9 +18,9 @@ #include "base/strings/string16.h" #include "base/time/time.h" #include "chrome/browser/search_engines/template_url_id.h" -#include "chrome/common/favicon/favicon_types.h" #include "chrome/common/ref_counted_util.h" #include "chrome/common/thumbnail_score.h" +#include "components/favicon_base/favicon_types.h" #include "components/query_parser/snippet.h" #include "content/public/common/page_transition_types.h" #include "ui/gfx/image/image.h" @@ -685,13 +685,13 @@ struct IconMapping { GURL page_url; // The unique id of the icon. - chrome::FaviconID icon_id; + favicon_base::FaviconID icon_id; // The url of the icon. GURL icon_url; // The type of icon. - chrome::IconType icon_type; + favicon_base::IconType icon_type; }; // Defines a favicon bitmap and its associated pixel size. @@ -715,7 +715,7 @@ struct FaviconBitmap { FaviconBitmapID bitmap_id; // The id of the favicon to which the bitmap belongs to. - chrome::FaviconID icon_id; + favicon_base::FaviconID icon_id; // Time at which |bitmap_data| was last updated. base::Time last_updated; diff --git a/chrome/browser/history/thumbnail_database.cc b/chrome/browser/history/thumbnail_database.cc index 11d9162..80f4559 100644 --- a/chrome/browser/history/thumbnail_database.cc +++ b/chrome/browser/history/thumbnail_database.cc @@ -94,7 +94,7 @@ void FillIconMapping(const sql::Statement& statement, icon_mapping->mapping_id = statement.ColumnInt64(0); icon_mapping->icon_id = statement.ColumnInt64(1); icon_mapping->icon_type = - static_cast<chrome::IconType>(statement.ColumnInt(2)); + static_cast<favicon_base::IconType>(statement.ColumnInt(2)); icon_mapping->icon_url = GURL(statement.ColumnString(3)); icon_mapping->page_url = page_url; } @@ -646,7 +646,7 @@ void ThumbnailDatabase::TrimMemory(bool aggressively) { } bool ThumbnailDatabase::GetFaviconBitmapIDSizes( - chrome::FaviconID icon_id, + favicon_base::FaviconID icon_id, std::vector<FaviconBitmapIDSize>* bitmap_id_sizes) { DCHECK(icon_id); sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, @@ -669,7 +669,7 @@ bool ThumbnailDatabase::GetFaviconBitmapIDSizes( } bool ThumbnailDatabase::GetFaviconBitmaps( - chrome::FaviconID icon_id, + favicon_base::FaviconID icon_id, std::vector<FaviconBitmap>* favicon_bitmaps) { DCHECK(icon_id); sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, @@ -731,7 +731,7 @@ bool ThumbnailDatabase::GetFaviconBitmap( } FaviconBitmapID ThumbnailDatabase::AddFaviconBitmap( - chrome::FaviconID icon_id, + favicon_base::FaviconID icon_id, const scoped_refptr<base::RefCountedMemory>& icon_data, base::Time time, const gfx::Size& pixel_size) { @@ -792,7 +792,7 @@ bool ThumbnailDatabase::DeleteFaviconBitmap(FaviconBitmapID bitmap_id) { return statement.Run(); } -bool ThumbnailDatabase::SetFaviconOutOfDate(chrome::FaviconID icon_id) { +bool ThumbnailDatabase::SetFaviconOutOfDate(favicon_base::FaviconID icon_id) { sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, "UPDATE favicon_bitmaps SET last_updated=? WHERE icon_id=?")); statement.BindInt64(0, 0); @@ -801,10 +801,10 @@ bool ThumbnailDatabase::SetFaviconOutOfDate(chrome::FaviconID icon_id) { return statement.Run(); } -chrome::FaviconID ThumbnailDatabase::GetFaviconIDForFaviconURL( +favicon_base::FaviconID ThumbnailDatabase::GetFaviconIDForFaviconURL( const GURL& icon_url, int required_icon_type, - chrome::IconType* icon_type) { + favicon_base::IconType* icon_type) { sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, "SELECT id, icon_type FROM favicons WHERE url=? AND (icon_type & ? > 0) " "ORDER BY icon_type DESC")); @@ -815,13 +815,13 @@ chrome::FaviconID ThumbnailDatabase::GetFaviconIDForFaviconURL( return 0; // not cached if (icon_type) - *icon_type = static_cast<chrome::IconType>(statement.ColumnInt(1)); + *icon_type = static_cast<favicon_base::IconType>(statement.ColumnInt(1)); return statement.ColumnInt64(0); } -bool ThumbnailDatabase::GetFaviconHeader(chrome::FaviconID icon_id, +bool ThumbnailDatabase::GetFaviconHeader(favicon_base::FaviconID icon_id, GURL* icon_url, - chrome::IconType* icon_type) { + favicon_base::IconType* icon_type) { DCHECK(icon_id); sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, @@ -834,14 +834,14 @@ bool ThumbnailDatabase::GetFaviconHeader(chrome::FaviconID icon_id, if (icon_url) *icon_url = GURL(statement.ColumnString(0)); if (icon_type) - *icon_type = static_cast<chrome::IconType>(statement.ColumnInt(1)); + *icon_type = static_cast<favicon_base::IconType>(statement.ColumnInt(1)); return true; } -chrome::FaviconID ThumbnailDatabase::AddFavicon( +favicon_base::FaviconID ThumbnailDatabase::AddFavicon( const GURL& icon_url, - chrome::IconType icon_type) { + favicon_base::IconType icon_type) { sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, "INSERT INTO favicons (url, icon_type) VALUES (?, ?)")); @@ -853,20 +853,20 @@ chrome::FaviconID ThumbnailDatabase::AddFavicon( return db_.GetLastInsertRowId(); } -chrome::FaviconID ThumbnailDatabase::AddFavicon( +favicon_base::FaviconID ThumbnailDatabase::AddFavicon( const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, const scoped_refptr<base::RefCountedMemory>& icon_data, base::Time time, const gfx::Size& pixel_size) { - chrome::FaviconID icon_id = AddFavicon(icon_url, icon_type); + favicon_base::FaviconID icon_id = AddFavicon(icon_url, icon_type); if (!icon_id || !AddFaviconBitmap(icon_id, icon_data, time, pixel_size)) return 0; return icon_id; } -bool ThumbnailDatabase::DeleteFavicon(chrome::FaviconID id) { +bool ThumbnailDatabase::DeleteFavicon(favicon_base::FaviconID id) { sql::Statement statement; statement.Assign(db_.GetCachedStatement(SQL_FROM_HERE, "DELETE FROM favicons WHERE id = ?")); @@ -933,8 +933,9 @@ bool ThumbnailDatabase::GetIconMappingsForPageURL( return result; } -IconMappingID ThumbnailDatabase::AddIconMapping(const GURL& page_url, - chrome::FaviconID icon_id) { +IconMappingID ThumbnailDatabase::AddIconMapping( + const GURL& page_url, + favicon_base::FaviconID icon_id) { const char kSql[] = "INSERT INTO icon_mapping (page_url, icon_id) VALUES (?, ?)"; sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, kSql)); @@ -948,7 +949,7 @@ IconMappingID ThumbnailDatabase::AddIconMapping(const GURL& page_url, } bool ThumbnailDatabase::UpdateIconMapping(IconMappingID mapping_id, - chrome::FaviconID icon_id) { + favicon_base::FaviconID icon_id) { sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, "UPDATE icon_mapping SET icon_id=? WHERE id=?")); statement.BindInt64(0, icon_id); @@ -973,7 +974,7 @@ bool ThumbnailDatabase::DeleteIconMapping(IconMappingID mapping_id) { return statement.Run(); } -bool ThumbnailDatabase::HasMappingFor(chrome::FaviconID id) { +bool ThumbnailDatabase::HasMappingFor(favicon_base::FaviconID id) { sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, "SELECT id FROM icon_mapping " "WHERE icon_id=?")); @@ -1006,7 +1007,7 @@ bool ThumbnailDatabase::CloneIconMappings(const GURL& old_page_url, } bool ThumbnailDatabase::InitIconMappingEnumerator( - chrome::IconType type, + favicon_base::IconType type, IconMappingEnumerator* enumerator) { DCHECK(!enumerator->statement_.is_valid()); enumerator->statement_.Assign(db_.GetCachedStatement( diff --git a/chrome/browser/history/thumbnail_database.h b/chrome/browser/history/thumbnail_database.h index f5e9fd2..cc6324f 100644 --- a/chrome/browser/history/thumbnail_database.h +++ b/chrome/browser/history/thumbnail_database.h @@ -68,12 +68,12 @@ class ThumbnailDatabase { // favicon_bitmaps table. The pixel sizes are a subset of the sizes in the // 'sizes' field of the favicons table for |icon_id|. bool GetFaviconBitmapIDSizes( - chrome::FaviconID icon_id, + favicon_base::FaviconID icon_id, std::vector<FaviconBitmapIDSize>* bitmap_id_sizes); // Returns true if there are any matched bitmaps for the given |icon_id|. All // matched results are returned if |favicon_bitmaps| is not NULL. - bool GetFaviconBitmaps(chrome::FaviconID icon_id, + bool GetFaviconBitmaps(favicon_base::FaviconID icon_id, std::vector<FaviconBitmap>* favicon_bitmaps); // Gets the last updated time, bitmap data, and pixel size of the favicon @@ -92,7 +92,7 @@ class ThumbnailDatabase { // |pixel_size| is the pixel dimensions of |icon_data|. // Returns the id of the added bitmap or 0 if unsuccessful. FaviconBitmapID AddFaviconBitmap( - chrome::FaviconID icon_id, + favicon_base::FaviconID icon_id, const scoped_refptr<base::RefCountedMemory>& icon_data, base::Time time, const gfx::Size& pixel_size); @@ -117,7 +117,7 @@ class ThumbnailDatabase { // Sets the the favicon as out of date. This will set |last_updated| for all // of the bitmaps for |icon_id| to be out of date. - bool SetFaviconOutOfDate(chrome::FaviconID icon_id); + bool SetFaviconOutOfDate(favicon_base::FaviconID icon_id); // Returns the id of the entry in the favicon database with the specified url // and icon type. If |required_icon_type| contains multiple icon types and @@ -126,31 +126,32 @@ class ThumbnailDatabase { // FAVICON, and the icon type is returned in icon_type parameter if it is not // NULL. // Returns 0 if no entry exists for the specified url. - chrome::FaviconID GetFaviconIDForFaviconURL(const GURL& icon_url, - int required_icon_type, - chrome::IconType* icon_type); + favicon_base::FaviconID GetFaviconIDForFaviconURL( + const GURL& icon_url, + int required_icon_type, + favicon_base::IconType* icon_type); // Gets the icon_url, icon_type and sizes for the specified |icon_id|. - bool GetFaviconHeader(chrome::FaviconID icon_id, + bool GetFaviconHeader(favicon_base::FaviconID icon_id, GURL* icon_url, - chrome::IconType* icon_type); + favicon_base::IconType* icon_type); // Adds favicon with |icon_url|, |icon_type| and |favicon_sizes| to the // favicon db, returning its id. - chrome::FaviconID AddFavicon(const GURL& icon_url, - chrome::IconType icon_type); + favicon_base::FaviconID AddFavicon(const GURL& icon_url, + favicon_base::IconType icon_type); // Adds a favicon with a single bitmap. This call is equivalent to calling // AddFavicon and AddFaviconBitmap. - chrome::FaviconID AddFavicon( + favicon_base::FaviconID AddFavicon( const GURL& icon_url, - chrome::IconType icon_type, + favicon_base::IconType icon_type, const scoped_refptr<base::RefCountedMemory>& icon_data, base::Time time, const gfx::Size& pixel_size); // Delete the favicon with the provided id. Returns false on failure - bool DeleteFavicon(chrome::FaviconID id); + bool DeleteFavicon(favicon_base::FaviconID id); // Icon Mapping -------------------------------------------------------------- // @@ -178,12 +179,14 @@ class ThumbnailDatabase { // Adds a mapping between the given page_url and icon_id. // Returns the new mapping id if the adding succeeds, otherwise 0 is returned. - IconMappingID AddIconMapping(const GURL& page_url, chrome::FaviconID icon_id); + IconMappingID AddIconMapping(const GURL& page_url, + favicon_base::FaviconID icon_id); // Updates the page and icon mapping for the given mapping_id with the given // icon_id. // Returns true if the update succeeded. - bool UpdateIconMapping(IconMappingID mapping_id, chrome::FaviconID icon_id); + bool UpdateIconMapping(IconMappingID mapping_id, + favicon_base::FaviconID icon_id); // Deletes the icon mapping entries for the given page url. // Returns true if the deletion succeeded. @@ -194,7 +197,7 @@ class ThumbnailDatabase { bool DeleteIconMapping(IconMappingID mapping_id); // Checks whether a favicon is used by any URLs in the database. - bool HasMappingFor(chrome::FaviconID id); + bool HasMappingFor(favicon_base::FaviconID id); // Clones the existing mappings from |old_page_url| if |new_page_url| has no // mappings. Otherwise, will leave mappings alone. @@ -221,7 +224,7 @@ class ThumbnailDatabase { }; // Return all icon mappings of the given |icon_type|. - bool InitIconMappingEnumerator(chrome::IconType type, + bool InitIconMappingEnumerator(favicon_base::IconType type, IconMappingEnumerator* enumerator); // Remove all data except that associated with the passed page urls. diff --git a/chrome/browser/history/thumbnail_database_unittest.cc b/chrome/browser/history/thumbnail_database_unittest.cc index 9146110..99a3e53 100644 --- a/chrome/browser/history/thumbnail_database_unittest.cc +++ b/chrome/browser/history/thumbnail_database_unittest.cc @@ -99,7 +99,7 @@ void VerifyDatabaseEmpty(sql::Connection* db) { WARN_UNUSED_RESULT bool CheckPageHasIcon( ThumbnailDatabase* db, const GURL& page_url, - chrome::IconType expected_icon_type, + favicon_base::IconType expected_icon_type, const GURL& expected_icon_url, const gfx::Size& expected_icon_size, size_t expected_icon_contents_size, @@ -202,11 +202,8 @@ TEST_F(ThumbnailDatabaseTest, AddIconMapping) { GURL url("http://google.com"); base::Time time = base::Time::Now(); - chrome::FaviconID id = db.AddFavicon(url, - chrome::TOUCH_ICON, - favicon, - time, - gfx::Size()); + favicon_base::FaviconID id = + db.AddFavicon(url, favicon_base::TOUCH_ICON, favicon, time, gfx::Size()); EXPECT_NE(0, id); EXPECT_NE(0, db.AddIconMapping(url, id)); @@ -223,8 +220,7 @@ TEST_F(ThumbnailDatabaseTest, UpdateIconMapping) { db.BeginTransaction(); GURL url("http://google.com"); - chrome::FaviconID id = - db.AddFavicon(url, chrome::TOUCH_ICON); + favicon_base::FaviconID id = db.AddFavicon(url, favicon_base::TOUCH_ICON); EXPECT_LT(0, db.AddIconMapping(url, id)); std::vector<IconMapping> icon_mapping; @@ -234,8 +230,8 @@ TEST_F(ThumbnailDatabaseTest, UpdateIconMapping) { EXPECT_EQ(id, icon_mapping.front().icon_id); GURL url1("http://www.google.com/"); - chrome::FaviconID new_id = - db.AddFavicon(url1, chrome::TOUCH_ICON); + favicon_base::FaviconID new_id = + db.AddFavicon(url1, favicon_base::TOUCH_ICON); EXPECT_TRUE(db.UpdateIconMapping(icon_mapping.front().mapping_id, new_id)); icon_mapping.clear(); @@ -255,27 +251,25 @@ TEST_F(ThumbnailDatabaseTest, DeleteIconMappings) { scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); GURL url("http://google.com"); - chrome::FaviconID id = - db.AddFavicon(url, chrome::TOUCH_ICON); + favicon_base::FaviconID id = db.AddFavicon(url, favicon_base::TOUCH_ICON); base::Time time = base::Time::Now(); db.AddFaviconBitmap(id, favicon, time, gfx::Size()); EXPECT_LT(0, db.AddIconMapping(url, id)); - chrome::FaviconID id2 = - db.AddFavicon(url, chrome::FAVICON); + favicon_base::FaviconID id2 = db.AddFavicon(url, favicon_base::FAVICON); EXPECT_LT(0, db.AddIconMapping(url, id2)); ASSERT_NE(id, id2); std::vector<IconMapping> icon_mapping; EXPECT_TRUE(db.GetIconMappingsForPageURL(url, &icon_mapping)); ASSERT_EQ(2u, icon_mapping.size()); - EXPECT_EQ(icon_mapping.front().icon_type, chrome::TOUCH_ICON); - EXPECT_TRUE(db.GetIconMappingsForPageURL(url, chrome::FAVICON, NULL)); + EXPECT_EQ(icon_mapping.front().icon_type, favicon_base::TOUCH_ICON); + EXPECT_TRUE(db.GetIconMappingsForPageURL(url, favicon_base::FAVICON, NULL)); db.DeleteIconMappings(url); EXPECT_FALSE(db.GetIconMappingsForPageURL(url, NULL)); - EXPECT_FALSE(db.GetIconMappingsForPageURL(url, chrome::FAVICON, NULL)); + EXPECT_FALSE(db.GetIconMappingsForPageURL(url, favicon_base::FAVICON, NULL)); } TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURL) { @@ -288,13 +282,13 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURL) { GURL url("http://google.com"); - chrome::FaviconID id1 = db.AddFavicon(url, chrome::TOUCH_ICON); + favicon_base::FaviconID id1 = db.AddFavicon(url, favicon_base::TOUCH_ICON); base::Time time = base::Time::Now(); db.AddFaviconBitmap(id1, favicon, time, kSmallSize); db.AddFaviconBitmap(id1, favicon, time, kLargeSize); EXPECT_LT(0, db.AddIconMapping(url, id1)); - chrome::FaviconID id2 = db.AddFavicon(url, chrome::FAVICON); + favicon_base::FaviconID id2 = db.AddFavicon(url, favicon_base::FAVICON); EXPECT_NE(id1, id2); db.AddFaviconBitmap(id2, favicon, time, kSmallSize); EXPECT_LT(0, db.AddIconMapping(url, id2)); @@ -325,16 +319,19 @@ TEST_F(ThumbnailDatabaseTest, RetainDataForPageUrls) { scoped_refptr<base::RefCountedStaticMemory> favicon2( new base::RefCountedStaticMemory(kBlob2, sizeof(kBlob2))); - chrome::FaviconID kept_id1 = db.AddFavicon(kIconUrl1, chrome::FAVICON); + favicon_base::FaviconID kept_id1 = + db.AddFavicon(kIconUrl1, favicon_base::FAVICON); db.AddFaviconBitmap(kept_id1, favicon1, base::Time::Now(), kLargeSize); db.AddIconMapping(kPageUrl1, kept_id1); db.AddIconMapping(kPageUrl3, kept_id1); - chrome::FaviconID unkept_id = db.AddFavicon(kIconUrl2, chrome::FAVICON); + favicon_base::FaviconID unkept_id = + db.AddFavicon(kIconUrl2, favicon_base::FAVICON); db.AddFaviconBitmap(unkept_id, favicon1, base::Time::Now(), kLargeSize); db.AddIconMapping(kPageUrl2, unkept_id); - chrome::FaviconID kept_id2 = db.AddFavicon(kIconUrl5, chrome::FAVICON); + favicon_base::FaviconID kept_id2 = + db.AddFavicon(kIconUrl5, favicon_base::FAVICON); db.AddFaviconBitmap(kept_id2, favicon2, base::Time::Now(), kLargeSize); db.AddIconMapping(kPageUrl5, kept_id2); @@ -349,12 +346,27 @@ TEST_F(ThumbnailDatabaseTest, RetainDataForPageUrls) { EXPECT_TRUE(db.RetainDataForPageUrls(pages_to_keep)); // Mappings from the retained urls should be left. - EXPECT_TRUE(CheckPageHasIcon(&db, kPageUrl1, chrome::FAVICON, - kIconUrl1, kLargeSize, sizeof(kBlob1), kBlob1)); - EXPECT_TRUE(CheckPageHasIcon(&db, kPageUrl3, chrome::FAVICON, - kIconUrl1, kLargeSize, sizeof(kBlob1), kBlob1)); - EXPECT_TRUE(CheckPageHasIcon(&db, kPageUrl5, chrome::FAVICON, - kIconUrl5, kLargeSize, sizeof(kBlob2), kBlob2)); + EXPECT_TRUE(CheckPageHasIcon(&db, + kPageUrl1, + favicon_base::FAVICON, + kIconUrl1, + kLargeSize, + sizeof(kBlob1), + kBlob1)); + EXPECT_TRUE(CheckPageHasIcon(&db, + kPageUrl3, + favicon_base::FAVICON, + kIconUrl1, + kLargeSize, + sizeof(kBlob1), + kBlob1)); + EXPECT_TRUE(CheckPageHasIcon(&db, + kPageUrl5, + favicon_base::FAVICON, + kIconUrl5, + kLargeSize, + sizeof(kBlob2), + kBlob2)); // The one not retained should be missing. EXPECT_FALSE(db.GetFaviconIDForFaviconURL(kPageUrl2, false, NULL)); @@ -378,7 +390,7 @@ TEST_F(ThumbnailDatabaseTest, DeleteFavicon) { new base::RefCountedBytes(data2)); GURL url("http://google.com"); - chrome::FaviconID id = db.AddFavicon(url, chrome::FAVICON); + favicon_base::FaviconID id = db.AddFavicon(url, favicon_base::FAVICON); base::Time last_updated = base::Time::Now(); db.AddFaviconBitmap(id, favicon1, last_updated, kSmallSize); db.AddFaviconBitmap(id, favicon2, last_updated, kLargeSize); @@ -402,18 +414,15 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLForReturnOrder) { GURL icon_url("http://google.com/favicon.ico"); base::Time time = base::Time::Now(); - chrome::FaviconID id = db.AddFavicon(icon_url, - chrome::FAVICON, - favicon, - time, - gfx::Size()); + favicon_base::FaviconID id = db.AddFavicon( + icon_url, favicon_base::FAVICON, favicon, time, gfx::Size()); EXPECT_NE(0, db.AddIconMapping(page_url, id)); std::vector<IconMapping> icon_mappings; EXPECT_TRUE(db.GetIconMappingsForPageURL(page_url, &icon_mappings)); EXPECT_EQ(page_url, icon_mappings.front().page_url); EXPECT_EQ(id, icon_mappings.front().icon_id); - EXPECT_EQ(chrome::FAVICON, icon_mappings.front().icon_type); + EXPECT_EQ(favicon_base::FAVICON, icon_mappings.front().icon_type); EXPECT_EQ(icon_url, icon_mappings.front().icon_url); // Add a touch icon @@ -421,11 +430,8 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLForReturnOrder) { scoped_refptr<base::RefCountedBytes> favicon2 = new base::RefCountedBytes(data); - chrome::FaviconID id2 = db.AddFavicon(icon_url, - chrome::TOUCH_ICON, - favicon2, - time, - gfx::Size()); + favicon_base::FaviconID id2 = db.AddFavicon( + icon_url, favicon_base::TOUCH_ICON, favicon2, time, gfx::Size()); EXPECT_NE(0, db.AddIconMapping(page_url, id2)); icon_mappings.clear(); @@ -433,18 +439,19 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLForReturnOrder) { EXPECT_EQ(page_url, icon_mappings.front().page_url); EXPECT_EQ(id2, icon_mappings.front().icon_id); - EXPECT_EQ(chrome::TOUCH_ICON, icon_mappings.front().icon_type); + EXPECT_EQ(favicon_base::TOUCH_ICON, icon_mappings.front().icon_type); EXPECT_EQ(icon_url, icon_mappings.front().icon_url); // Add a touch precomposed icon scoped_refptr<base::RefCountedBytes> favicon3 = new base::RefCountedBytes(data2); - chrome::FaviconID id3 = db.AddFavicon(icon_url, - chrome::TOUCH_PRECOMPOSED_ICON, - favicon3, - time, - gfx::Size()); + favicon_base::FaviconID id3 = + db.AddFavicon(icon_url, + favicon_base::TOUCH_PRECOMPOSED_ICON, + favicon3, + time, + gfx::Size()); EXPECT_NE(0, db.AddIconMapping(page_url, id3)); icon_mappings.clear(); @@ -452,7 +459,8 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLForReturnOrder) { EXPECT_EQ(page_url, icon_mappings.front().page_url); EXPECT_EQ(id3, icon_mappings.front().icon_id); - EXPECT_EQ(chrome::TOUCH_PRECOMPOSED_ICON, icon_mappings.front().icon_type); + EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, + icon_mappings.front().icon_type); EXPECT_EQ(icon_url, icon_mappings.front().icon_url); } @@ -467,25 +475,16 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLWithIconType) { scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); base::Time time = base::Time::Now(); - chrome::FaviconID id1 = db.AddFavicon(url, - chrome::FAVICON, - favicon, - time, - gfx::Size()); + favicon_base::FaviconID id1 = + db.AddFavicon(url, favicon_base::FAVICON, favicon, time, gfx::Size()); EXPECT_NE(0, db.AddIconMapping(url, id1)); - chrome::FaviconID id2 = db.AddFavicon(url, - chrome::TOUCH_ICON, - favicon, - time, - gfx::Size()); + favicon_base::FaviconID id2 = + db.AddFavicon(url, favicon_base::TOUCH_ICON, favicon, time, gfx::Size()); EXPECT_NE(0, db.AddIconMapping(url, id2)); - chrome::FaviconID id3 = db.AddFavicon(url, - chrome::TOUCH_ICON, - favicon, - time, - gfx::Size()); + favicon_base::FaviconID id3 = + db.AddFavicon(url, favicon_base::TOUCH_ICON, favicon, time, gfx::Size()); EXPECT_NE(0, db.AddIconMapping(url, id3)); // Only the mappings for favicons of type TOUCH_ICON should be returned as @@ -493,7 +492,8 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLWithIconType) { std::vector<IconMapping> icon_mappings; EXPECT_TRUE(db.GetIconMappingsForPageURL( url, - chrome::FAVICON | chrome::TOUCH_ICON | chrome::TOUCH_PRECOMPOSED_ICON, + favicon_base::FAVICON | favicon_base::TOUCH_ICON | + favicon_base::TOUCH_PRECOMPOSED_ICON, &icon_mappings)); EXPECT_EQ(2u, icon_mappings.size()); @@ -505,8 +505,8 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLWithIconType) { } icon_mappings.clear(); - EXPECT_TRUE( - db.GetIconMappingsForPageURL(url, chrome::TOUCH_ICON, &icon_mappings)); + EXPECT_TRUE(db.GetIconMappingsForPageURL( + url, favicon_base::TOUCH_ICON, &icon_mappings)); if (id2 == icon_mappings[0].icon_id) { EXPECT_EQ(id3, icon_mappings[1].icon_id); } else { @@ -516,7 +516,7 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLWithIconType) { icon_mappings.clear(); EXPECT_TRUE( - db.GetIconMappingsForPageURL(url, chrome::FAVICON, &icon_mappings)); + db.GetIconMappingsForPageURL(url, favicon_base::FAVICON, &icon_mappings)); EXPECT_EQ(1u, icon_mappings.size()); EXPECT_EQ(id1, icon_mappings[0].icon_id); } @@ -531,29 +531,31 @@ TEST_F(ThumbnailDatabaseTest, HasMappingFor) { // Add a favicon which will have icon_mappings base::Time time = base::Time::Now(); - chrome::FaviconID id1 = db.AddFavicon(GURL("http://google.com"), - chrome::FAVICON, - favicon, - time, - gfx::Size()); + favicon_base::FaviconID id1 = db.AddFavicon(GURL("http://google.com"), + favicon_base::FAVICON, + favicon, + time, + gfx::Size()); EXPECT_NE(id1, 0); // Add another type of favicon time = base::Time::Now(); - chrome::FaviconID id2 = db.AddFavicon(GURL("http://www.google.com/icon"), - chrome::TOUCH_ICON, - favicon, - time, - gfx::Size()); + favicon_base::FaviconID id2 = + db.AddFavicon(GURL("http://www.google.com/icon"), + favicon_base::TOUCH_ICON, + favicon, + time, + gfx::Size()); EXPECT_NE(id2, 0); // Add 3rd favicon time = base::Time::Now(); - chrome::FaviconID id3 = db.AddFavicon(GURL("http://www.google.com/icon"), - chrome::TOUCH_ICON, - favicon, - time, - gfx::Size()); + favicon_base::FaviconID id3 = + db.AddFavicon(GURL("http://www.google.com/icon"), + favicon_base::TOUCH_ICON, + favicon, + time, + gfx::Size()); EXPECT_NE(id3, 0); // Add 2 icon mapping @@ -581,22 +583,22 @@ TEST_F(ThumbnailDatabaseTest, CloneIconMappings) { scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); // Add a favicon which will have icon_mappings - chrome::FaviconID id1 = db.AddFavicon( - GURL("http://google.com"), chrome::FAVICON); + favicon_base::FaviconID id1 = + db.AddFavicon(GURL("http://google.com"), favicon_base::FAVICON); EXPECT_NE(0, id1); base::Time time = base::Time::Now(); db.AddFaviconBitmap(id1, favicon, time, gfx::Size()); // Add another type of favicon - chrome::FaviconID id2 = db.AddFavicon(GURL("http://www.google.com/icon"), - chrome::TOUCH_ICON); + favicon_base::FaviconID id2 = db.AddFavicon( + GURL("http://www.google.com/icon"), favicon_base::TOUCH_ICON); EXPECT_NE(0, id2); time = base::Time::Now(); db.AddFaviconBitmap(id2, favicon, time, gfx::Size()); // Add 3rd favicon - chrome::FaviconID id3 = db.AddFavicon(GURL("http://www.google.com/icon"), - chrome::TOUCH_ICON); + favicon_base::FaviconID id3 = db.AddFavicon( + GURL("http://www.google.com/icon"), favicon_base::TOUCH_ICON); EXPECT_NE(0, id3); time = base::Time::Now(); db.AddFaviconBitmap(id3, favicon, time, gfx::Size()); @@ -663,14 +665,34 @@ TEST_F(ThumbnailDatabaseTest, Version5) { ASSERT_TRUE(db.get() != NULL); VerifyTablesAndColumns(&db->db_); - EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl1, chrome::FAVICON, - kIconUrl1, gfx::Size(), sizeof(kBlob1), kBlob1)); - EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl2, chrome::FAVICON, - kIconUrl2, gfx::Size(), sizeof(kBlob2), kBlob2)); - EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl3, chrome::FAVICON, - kIconUrl1, gfx::Size(), sizeof(kBlob1), kBlob1)); - EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl3, chrome::TOUCH_ICON, - kIconUrl3, gfx::Size(), sizeof(kBlob2), kBlob2)); + EXPECT_TRUE(CheckPageHasIcon(db.get(), + kPageUrl1, + favicon_base::FAVICON, + kIconUrl1, + gfx::Size(), + sizeof(kBlob1), + kBlob1)); + EXPECT_TRUE(CheckPageHasIcon(db.get(), + kPageUrl2, + favicon_base::FAVICON, + kIconUrl2, + gfx::Size(), + sizeof(kBlob2), + kBlob2)); + EXPECT_TRUE(CheckPageHasIcon(db.get(), + kPageUrl3, + favicon_base::FAVICON, + kIconUrl1, + gfx::Size(), + sizeof(kBlob1), + kBlob1)); + EXPECT_TRUE(CheckPageHasIcon(db.get(), + kPageUrl3, + favicon_base::TOUCH_ICON, + kIconUrl3, + gfx::Size(), + sizeof(kBlob2), + kBlob2)); } // Test loading version 6 database. @@ -679,14 +701,34 @@ TEST_F(ThumbnailDatabaseTest, Version6) { ASSERT_TRUE(db.get() != NULL); VerifyTablesAndColumns(&db->db_); - EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl1, chrome::FAVICON, - kIconUrl1, kLargeSize, sizeof(kBlob1), kBlob1)); - EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl2, chrome::FAVICON, - kIconUrl2, kLargeSize, sizeof(kBlob2), kBlob2)); - EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl3, chrome::FAVICON, - kIconUrl1, kLargeSize, sizeof(kBlob1), kBlob1)); - EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl3, chrome::TOUCH_ICON, - kIconUrl3, kLargeSize, sizeof(kBlob2), kBlob2)); + EXPECT_TRUE(CheckPageHasIcon(db.get(), + kPageUrl1, + favicon_base::FAVICON, + kIconUrl1, + kLargeSize, + sizeof(kBlob1), + kBlob1)); + EXPECT_TRUE(CheckPageHasIcon(db.get(), + kPageUrl2, + favicon_base::FAVICON, + kIconUrl2, + kLargeSize, + sizeof(kBlob2), + kBlob2)); + EXPECT_TRUE(CheckPageHasIcon(db.get(), + kPageUrl3, + favicon_base::FAVICON, + kIconUrl1, + kLargeSize, + sizeof(kBlob1), + kBlob1)); + EXPECT_TRUE(CheckPageHasIcon(db.get(), + kPageUrl3, + favicon_base::TOUCH_ICON, + kIconUrl3, + kLargeSize, + sizeof(kBlob2), + kBlob2)); } // Test loading version 7 database. @@ -695,14 +737,34 @@ TEST_F(ThumbnailDatabaseTest, Version7) { ASSERT_TRUE(db.get() != NULL); VerifyTablesAndColumns(&db->db_); - EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl1, chrome::FAVICON, - kIconUrl1, kLargeSize, sizeof(kBlob1), kBlob1)); - EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl2, chrome::FAVICON, - kIconUrl2, kLargeSize, sizeof(kBlob2), kBlob2)); - EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl3, chrome::FAVICON, - kIconUrl1, kLargeSize, sizeof(kBlob1), kBlob1)); - EXPECT_TRUE(CheckPageHasIcon(db.get(), kPageUrl3, chrome::TOUCH_ICON, - kIconUrl3, kLargeSize, sizeof(kBlob2), kBlob2)); + EXPECT_TRUE(CheckPageHasIcon(db.get(), + kPageUrl1, + favicon_base::FAVICON, + kIconUrl1, + kLargeSize, + sizeof(kBlob1), + kBlob1)); + EXPECT_TRUE(CheckPageHasIcon(db.get(), + kPageUrl2, + favicon_base::FAVICON, + kIconUrl2, + kLargeSize, + sizeof(kBlob2), + kBlob2)); + EXPECT_TRUE(CheckPageHasIcon(db.get(), + kPageUrl3, + favicon_base::FAVICON, + kIconUrl1, + kLargeSize, + sizeof(kBlob1), + kBlob1)); + EXPECT_TRUE(CheckPageHasIcon(db.get(), + kPageUrl3, + favicon_base::TOUCH_ICON, + kIconUrl3, + kLargeSize, + sizeof(kBlob2), + kBlob2)); } TEST_F(ThumbnailDatabaseTest, Recovery) { @@ -729,12 +791,20 @@ TEST_F(ThumbnailDatabaseTest, Recovery) { ThumbnailDatabase db; ASSERT_EQ(sql::INIT_OK, db.Init(file_name_)); - EXPECT_TRUE( - CheckPageHasIcon(&db, kPageUrl1, chrome::FAVICON, - kIconUrl1, kLargeSize, sizeof(kBlob1), kBlob1)); - EXPECT_TRUE( - CheckPageHasIcon(&db, kPageUrl2, chrome::FAVICON, - kIconUrl2, kLargeSize, sizeof(kBlob2), kBlob2)); + EXPECT_TRUE(CheckPageHasIcon(&db, + kPageUrl1, + favicon_base::FAVICON, + kIconUrl1, + kLargeSize, + sizeof(kBlob1), + kBlob1)); + EXPECT_TRUE(CheckPageHasIcon(&db, + kPageUrl2, + favicon_base::FAVICON, + kIconUrl2, + kLargeSize, + sizeof(kBlob2), + kBlob2)); } // Corrupt the |icon_mapping.page_url| index by deleting an element @@ -792,9 +862,13 @@ TEST_F(ThumbnailDatabaseTest, Recovery) { EXPECT_FALSE(db.GetIconMappingsForPageURL(kPageUrl2, NULL)); // Other data was retained by recovery. - EXPECT_TRUE( - CheckPageHasIcon(&db, kPageUrl1, chrome::FAVICON, - kIconUrl1, kLargeSize, sizeof(kBlob1), kBlob1)); + EXPECT_TRUE(CheckPageHasIcon(&db, + kPageUrl1, + favicon_base::FAVICON, + kIconUrl1, + kLargeSize, + sizeof(kBlob1), + kBlob1)); } // Corrupt the database again by adjusting the header. @@ -818,9 +892,13 @@ TEST_F(ThumbnailDatabaseTest, Recovery) { ASSERT_EQ(sql::INIT_OK, db.Init(file_name_)); EXPECT_FALSE(db.GetIconMappingsForPageURL(kPageUrl2, NULL)); - EXPECT_TRUE( - CheckPageHasIcon(&db, kPageUrl1, chrome::FAVICON, - kIconUrl1, kLargeSize, sizeof(kBlob1), kBlob1)); + EXPECT_TRUE(CheckPageHasIcon(&db, + kPageUrl1, + favicon_base::FAVICON, + kIconUrl1, + kLargeSize, + sizeof(kBlob1), + kBlob1)); ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); } diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc index a627120..58cab80 100644 --- a/chrome/browser/jumplist_win.cc +++ b/chrome/browser/jumplist_win.cc @@ -25,8 +25,8 @@ #include "chrome/browser/shell_integration.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/favicon/favicon_types.h" #include "chrome/common/url_constants.h" +#include "components/favicon_base/favicon_types.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_source.h" #include "grit/chromium_strings.h" @@ -398,16 +398,14 @@ void JumpList::StartLoadingFavicon() { FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); task_id_ = favicon_service->GetFaviconImageForURL( - FaviconService::FaviconForURLParams(url, - chrome::FAVICON, - gfx::kFaviconSize), - base::Bind(&JumpList::OnFaviconDataAvailable, - base::Unretained(this)), + FaviconService::FaviconForURLParams( + url, favicon_base::FAVICON, gfx::kFaviconSize), + base::Bind(&JumpList::OnFaviconDataAvailable, base::Unretained(this)), &cancelable_task_tracker_); } void JumpList::OnFaviconDataAvailable( - const chrome::FaviconImageResult& image_result) { + const favicon_base::FaviconImageResult& image_result) { // If there is currently a favicon request in progress, it is now outdated, // as we have received another, so nullify the handle from the old request. task_id_ = base::CancelableTaskTracker::kBadTaskId; diff --git a/chrome/browser/jumplist_win.h b/chrome/browser/jumplist_win.h index 82f75dd..26be82c4 100644 --- a/chrome/browser/jumplist_win.h +++ b/chrome/browser/jumplist_win.h @@ -120,7 +120,8 @@ class JumpList : public TabRestoreServiceObserver, // is available. // To avoid file operations, this function just attaches the given data to // a ShellLinkItem object. - void OnFaviconDataAvailable(const chrome::FaviconImageResult& image_result); + void OnFaviconDataAvailable( + const favicon_base::FaviconImageResult& image_result); // Callback for TopSites that notifies when the "Most // Visited" list is available. This function updates the ShellLinkItemList diff --git a/chrome/browser/notifications/message_center_settings_controller.cc b/chrome/browser/notifications/message_center_settings_controller.cc index c0a6022..9f1e26f 100644 --- a/chrome/browser/notifications/message_center_settings_controller.cc +++ b/chrome/browser/notifications/message_center_settings_controller.cc @@ -28,7 +28,7 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/common/extensions/api/notifications.h" #include "chrome/common/extensions/extension_constants.h" -#include "chrome/common/favicon/favicon_types.h" +#include "components/favicon_base/favicon_types.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" #include "extensions/browser/event_router.h" @@ -286,7 +286,7 @@ void MessageCenterSettingsController::GetNotifierList( patterns_[name] = iter->primary_pattern; FaviconService::FaviconForURLParams favicon_params( url, - chrome::FAVICON | chrome::TOUCH_ICON, + favicon_base::FAVICON | favicon_base::TOUCH_ICON, message_center::kSettingsIconSize); // Note that favicon service obtains the favicon from history. This means // that it will fail to obtain the image if there are no history data for @@ -422,7 +422,7 @@ void MessageCenterSettingsController::OnNotifierAdvancedSettingsRequested( void MessageCenterSettingsController::OnFaviconLoaded( const GURL& url, - const chrome::FaviconImageResult& favicon_result) { + const favicon_base::FaviconImageResult& favicon_result) { FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, observers_, UpdateIconImage(NotifierId(url), favicon_result.image)); diff --git a/chrome/browser/notifications/message_center_settings_controller.h b/chrome/browser/notifications/message_center_settings_controller.h index 7f2bc19..e8135b4 100644 --- a/chrome/browser/notifications/message_center_settings_controller.h +++ b/chrome/browser/notifications/message_center_settings_controller.h @@ -15,6 +15,7 @@ #include "base/observer_list.h" #include "chrome/browser/extensions/app_icon_loader.h" #include "chrome/common/content_settings.h" +#include "components/favicon_base/favicon_types.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" @@ -32,7 +33,7 @@ namespace base { class CancelableTaskTracker; } -namespace chrome { +namespace favicon_base { struct FaviconImageResult; } @@ -93,7 +94,7 @@ class MessageCenterSettingsController const content::NotificationDetails& details) OVERRIDE; void OnFaviconLoaded(const GURL& url, - const chrome::FaviconImageResult& favicon_result); + const favicon_base::FaviconImageResult& favicon_result); #if defined(OS_CHROMEOS) // Sets up the notifier group for the guest session. This needs to be diff --git a/chrome/browser/sync/glue/bookmark_change_processor.cc b/chrome/browser/sync/glue/bookmark_change_processor.cc index 6723c13..8f2b1c8 100644 --- a/chrome/browser/sync/glue/bookmark_change_processor.cc +++ b/chrome/browser/sync/glue/bookmark_change_processor.cc @@ -842,7 +842,7 @@ void BookmarkChangeProcessor::ApplyBookmarkFavicon( gfx::Size pixel_size(gfx::kFaviconSize, gfx::kFaviconSize); favicon_service->MergeFavicon(bookmark_node->url(), icon_url, - chrome::FAVICON, + favicon_base::FAVICON, bitmap_data, pixel_size); } diff --git a/chrome/browser/sync/glue/favicon_cache.cc b/chrome/browser/sync/glue/favicon_cache.cc index 4c8da6e..e64b240 100644 --- a/chrome/browser/sync/glue/favicon_cache.cc +++ b/chrome/browser/sync/glue/favicon_cache.cc @@ -36,7 +36,7 @@ struct SyncedFaviconInfo { // The actual favicon data. // TODO(zea): don't keep around the actual data for locally sourced // favicons (UI can access those directly). - chrome::FaviconBitmapResult bitmap_data[NUM_SIZES]; + favicon_base::FaviconBitmapResult bitmap_data[NUM_SIZES]; // The URL this favicon was loaded from. const GURL favicon_url; // Is the favicon for a bookmarked page? @@ -78,9 +78,7 @@ const int kMaxFaviconResolution = 16; // Returns a mask of the supported favicon types. // TODO(zea): Supporting other favicons types will involve some work in the // favicon service and navigation controller. See crbug.com/181068. -int SupportedFaviconTypes() { - return chrome::FAVICON; -} +int SupportedFaviconTypes() { return favicon_base::FAVICON; } // Returns the appropriate IconSize to use for a given gfx::Size pixel // dimensions. @@ -122,12 +120,12 @@ GURL GetFaviconURLFromSpecifics(const sync_pb::EntitySpecifics& specifics) { } // Convert protobuf image data into a FaviconBitmapResult. -chrome::FaviconBitmapResult GetImageDataFromSpecifics( +favicon_base::FaviconBitmapResult GetImageDataFromSpecifics( const sync_pb::FaviconData& favicon_data) { base::RefCountedString* temp_string = new base::RefCountedString(); temp_string->data() = favicon_data.favicon(); - chrome::FaviconBitmapResult bitmap_result; + favicon_base::FaviconBitmapResult bitmap_result; bitmap_result.bitmap_data = temp_string; bitmap_result.pixel_size.set_height(favicon_data.height()); bitmap_result.pixel_size.set_width(favicon_data.width()); @@ -136,7 +134,7 @@ chrome::FaviconBitmapResult GetImageDataFromSpecifics( // Convert a FaviconBitmapResult into protobuf image data. void FillSpecificsWithImageData( - const chrome::FaviconBitmapResult& bitmap_result, + const favicon_base::FaviconBitmapResult& bitmap_result, sync_pb::FaviconData* favicon_data) { if (!bitmap_result.bitmap_data.get()) return; @@ -172,7 +170,7 @@ void BuildTrackingSpecifics( // Updates |favicon_info| with the image data in |bitmap_result|. bool UpdateFaviconFromBitmapResult( - const chrome::FaviconBitmapResult& bitmap_result, + const favicon_base::FaviconBitmapResult& bitmap_result, SyncedFaviconInfo* favicon_info) { DCHECK_EQ(favicon_info->favicon_url, bitmap_result.icon_url); if (!bitmap_result.is_valid()) { @@ -619,7 +617,7 @@ bool FaviconCache::FaviconRecencyFunctor::operator()( void FaviconCache::OnFaviconDataAvailable( const GURL& page_url, - const std::vector<chrome::FaviconBitmapResult>& bitmap_results) { + const std::vector<favicon_base::FaviconBitmapResult>& bitmap_results) { PageTaskMap::iterator page_iter = page_task_map_.find(page_url); if (page_iter == page_task_map_.end()) return; @@ -635,7 +633,7 @@ void FaviconCache::OnFaviconDataAvailable( base::Time now = base::Time::Now(); std::map<GURL, LocalFaviconUpdateInfo> favicon_updates; for (size_t i = 0; i < bitmap_results.size(); ++i) { - const chrome::FaviconBitmapResult& bitmap_result = bitmap_results[i]; + const favicon_base::FaviconBitmapResult& bitmap_result = bitmap_results[i]; GURL favicon_url = bitmap_result.icon_url; if (!favicon_url.is_valid() || favicon_url.SchemeIs("data")) continue; // Can happen if the page is still loading. @@ -1041,7 +1039,7 @@ void FaviconCache::DropPartialFavicon(FaviconMap::iterator favicon_iter, << favicon_iter->second.get()->favicon_url; for (int i = 0; i < NUM_SIZES; ++i) { favicon_iter->second->bitmap_data[i] = - chrome::FaviconBitmapResult(); + favicon_base::FaviconBitmapResult(); } DCHECK(!FaviconInfoHasImages(*favicon_iter->second)); } else { diff --git a/chrome/browser/sync/glue/favicon_cache.h b/chrome/browser/sync/glue/favicon_cache.h index 7901684..cfab7ef 100644 --- a/chrome/browser/sync/glue/favicon_cache.h +++ b/chrome/browser/sync/glue/favicon_cache.h @@ -131,7 +131,7 @@ class FaviconCache : public syncer::SyncableService, // available. Does nothing if no favicon data was available. void OnFaviconDataAvailable( const GURL& page_url, - const std::vector<chrome::FaviconBitmapResult>& bitmap_result); + const std::vector<favicon_base::FaviconBitmapResult>& bitmap_result); // Helper method to update the sync state of the favicon at |icon_url|. If // either |image_change_type| or |tracking_change_type| is ACTION_INVALID, diff --git a/chrome/browser/sync/glue/favicon_cache_unittest.cc b/chrome/browser/sync/glue/favicon_cache_unittest.cc index 75c6e5a..b0af7e30 100644 --- a/chrome/browser/sync/glue/favicon_cache_unittest.cc +++ b/chrome/browser/sync/glue/favicon_cache_unittest.cc @@ -411,9 +411,9 @@ scoped_ptr<syncer::SyncErrorFactory> SyncFaviconCacheTest:: void SyncFaviconCacheTest::OnCustomFaviconDataAvailable( const TestFaviconData& test_data) { - std::vector<chrome::FaviconBitmapResult> bitmap_results; + std::vector<favicon_base::FaviconBitmapResult> bitmap_results; if (!test_data.image_16.empty()) { - chrome::FaviconBitmapResult bitmap_result; + favicon_base::FaviconBitmapResult bitmap_result; bitmap_result.icon_url = test_data.icon_url; bitmap_result.pixel_size.set_width(16); bitmap_result.pixel_size.set_height(16); @@ -423,7 +423,7 @@ void SyncFaviconCacheTest::OnCustomFaviconDataAvailable( bitmap_results.push_back(bitmap_result); } if (!test_data.image_32.empty()) { - chrome::FaviconBitmapResult bitmap_result; + favicon_base::FaviconBitmapResult bitmap_result; bitmap_result.icon_url = test_data.icon_url; bitmap_result.pixel_size.set_width(32); bitmap_result.pixel_size.set_height(32); @@ -433,7 +433,7 @@ void SyncFaviconCacheTest::OnCustomFaviconDataAvailable( bitmap_results.push_back(bitmap_result); } if (!test_data.image_64.empty()) { - chrome::FaviconBitmapResult bitmap_result; + favicon_base::FaviconBitmapResult bitmap_result; bitmap_result.icon_url = test_data.icon_url; bitmap_result.pixel_size.set_width(64); bitmap_result.pixel_size.set_height(64); diff --git a/chrome/browser/sync/test/integration/bookmarks_helper.cc b/chrome/browser/sync/test/integration/bookmarks_helper.cc index 08a6ec7e..58ae260 100644 --- a/chrome/browser/sync/test/integration/bookmarks_helper.cc +++ b/chrome/browser/sync/test/integration/bookmarks_helper.cc @@ -226,10 +226,8 @@ void SetFaviconImpl(Profile* profile, FaviconServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); if (favicon_source == bookmarks_helper::FROM_UI) { - favicon_service->SetFavicons(node->url(), - icon_url, - chrome::FAVICON, - image); + favicon_service->SetFavicons( + node->url(), icon_url, favicon_base::FAVICON, image); } else { browser_sync::BookmarkChangeProcessor::ApplyBookmarkFavicon( node, profile, icon_url, image.As1xPNGBytes()); diff --git a/chrome/browser/ui/android/navigation_popup.cc b/chrome/browser/ui/android/navigation_popup.cc index dd9dffd..7eec8a2 100644 --- a/chrome/browser/ui/android/navigation_popup.cc +++ b/chrome/browser/ui/android/navigation_popup.cc @@ -49,9 +49,8 @@ void NavigationPopup::FetchFaviconForUrl(JNIEnv* env, // TODO(tedchoc): Request higher favicons based on screen density instead of // hardcoding kFaviconSize. favicon_service->GetFaviconImageForURL( - FaviconService::FaviconForURLParams(url, - chrome::FAVICON, - gfx::kFaviconSize), + FaviconService::FaviconForURLParams( + url, favicon_base::FAVICON, gfx::kFaviconSize), base::Bind(&NavigationPopup::OnFaviconDataAvailable, base::Unretained(this), url), @@ -60,7 +59,7 @@ void NavigationPopup::FetchFaviconForUrl(JNIEnv* env, void NavigationPopup::OnFaviconDataAvailable( GURL navigation_entry_url, - const chrome::FaviconImageResult& image_result) { + const favicon_base::FaviconImageResult& image_result) { gfx::Image image(image_result.image); if (image.IsEmpty()) { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); diff --git a/chrome/browser/ui/android/navigation_popup.h b/chrome/browser/ui/android/navigation_popup.h index 816eb7a..fe18278 100644 --- a/chrome/browser/ui/android/navigation_popup.h +++ b/chrome/browser/ui/android/navigation_popup.h @@ -13,7 +13,7 @@ class GURL; -namespace chrome { +namespace favicon_base { struct FaviconImageResult; } @@ -26,8 +26,9 @@ class NavigationPopup { void Destroy(JNIEnv* env, jobject obj); void FetchFaviconForUrl(JNIEnv* env, jobject obj, jstring jurl); - void OnFaviconDataAvailable(GURL navigation_entry_url, - const chrome::FaviconImageResult& image_result); + void OnFaviconDataAvailable( + GURL navigation_entry_url, + const favicon_base::FaviconImageResult& image_result); static bool RegisterNavigationPopup(JNIEnv* env); diff --git a/chrome/browser/ui/cocoa/history_menu_bridge.h b/chrome/browser/ui/cocoa/history_menu_bridge.h index a1be69b..f90094b 100644 --- a/chrome/browser/ui/cocoa/history_menu_bridge.h +++ b/chrome/browser/ui/cocoa/history_menu_bridge.h @@ -31,7 +31,7 @@ namespace { class HistoryMenuBridgeTest; } -namespace chrome { +namespace favicon_base { struct FaviconImageResult; } @@ -195,7 +195,7 @@ class HistoryMenuBridge : public content::NotificationObserver, // sets the image on the menu. Called on the same same thread that // GetFaviconForHistoryItem() was called on (UI thread). void GotFaviconData(HistoryItem* item, - const chrome::FaviconImageResult& image_result); + const favicon_base::FaviconImageResult& image_result); // Cancels a favicon load request for a given HistoryItem, if one is in // progress. diff --git a/chrome/browser/ui/cocoa/history_menu_bridge.mm b/chrome/browser/ui/cocoa/history_menu_bridge.mm index 3bae9db..3fd89b7 100644 --- a/chrome/browser/ui/cocoa/history_menu_bridge.mm +++ b/chrome/browser/ui/cocoa/history_menu_bridge.mm @@ -20,8 +20,8 @@ #include "chrome/browser/sessions/session_types.h" #include "chrome/browser/sessions/tab_restore_service_factory.h" #import "chrome/browser/ui/cocoa/history_menu_cocoa_controller.h" -#include "chrome/common/favicon/favicon_types.h" #include "chrome/common/url_constants.h" +#include "components/favicon_base/favicon_types.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_source.h" #include "grit/generated_resources.h" @@ -458,7 +458,7 @@ void HistoryMenuBridge::GetFaviconForHistoryItem(HistoryItem* item) { FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); base::CancelableTaskTracker::TaskId task_id = service->GetFaviconImageForURL( FaviconService::FaviconForURLParams( - item->url, chrome::FAVICON, gfx::kFaviconSize), + item->url, favicon_base::FAVICON, gfx::kFaviconSize), base::Bind( &HistoryMenuBridge::GotFaviconData, base::Unretained(this), item), &cancelable_task_tracker_); @@ -468,7 +468,7 @@ void HistoryMenuBridge::GetFaviconForHistoryItem(HistoryItem* item) { void HistoryMenuBridge::GotFaviconData( HistoryItem* item, - const chrome::FaviconImageResult& image_result) { + const favicon_base::FaviconImageResult& image_result) { // Since we're going to do Cocoa-y things, make sure this is the main thread. DCHECK([NSThread isMainThread]); diff --git a/chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm b/chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm index e226f259..ead2f46 100644 --- a/chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm +++ b/chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm @@ -15,8 +15,8 @@ #include "chrome/browser/sessions/persistent_tab_restore_service.h" #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" #include "chrome/browser/ui/cocoa/history_menu_bridge.h" -#include "chrome/common/favicon/favicon_types.h" #include "chrome/test/base/testing_profile.h" +#include "components/favicon_base/favicon_types.h" #include "components/sessions/serialized_navigation_entry_test_helper.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -107,9 +107,8 @@ class HistoryMenuBridgeTest : public CocoaProfileTest { bridge_->GetFaviconForHistoryItem(item); } - void GotFaviconData( - HistoryMenuBridge::HistoryItem* item, - const chrome::FaviconImageResult& image_result) { + void GotFaviconData(HistoryMenuBridge::HistoryItem* item, + const favicon_base::FaviconImageResult& image_result) { bridge_->GotFaviconData(item, image_result); } @@ -354,7 +353,7 @@ TEST_F(HistoryMenuBridgeTest, GotFaviconData) { GetFaviconForHistoryItem(&item); // Pretend to be called back. - chrome::FaviconImageResult image_result; + favicon_base::FaviconImageResult image_result; image_result.image = gfx::Image::CreateFrom1xBitmap(bitmap); GotFaviconData(&item, image_result); diff --git a/chrome/browser/ui/search_engines/template_url_table_model.cc b/chrome/browser/ui/search_engines/template_url_table_model.cc index ae2a976..a8657d23 100644 --- a/chrome/browser/ui/search_engines/template_url_table_model.cc +++ b/chrome/browser/ui/search_engines/template_url_table_model.cc @@ -15,7 +15,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_service.h" -#include "chrome/common/favicon/favicon_types.h" +#include "components/favicon_base/favicon_types.h" #include "grit/generated_resources.h" #include "grit/ui_resources.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -96,13 +96,15 @@ class ModelEntry { } load_state_ = LOADING; favicon_service->GetFaviconImage( - favicon_url, chrome::FAVICON, gfx::kFaviconSize, - base::Bind(&ModelEntry::OnFaviconDataAvailable, - base::Unretained(this)), + favicon_url, + favicon_base::FAVICON, + gfx::kFaviconSize, + base::Bind(&ModelEntry::OnFaviconDataAvailable, base::Unretained(this)), &tracker_); } - void OnFaviconDataAvailable(const chrome::FaviconImageResult& image_result) { + void OnFaviconDataAvailable( + const favicon_base::FaviconImageResult& image_result) { load_state_ = LOADED; if (!image_result.image.IsEmpty()) { favicon_ = image_result.image.AsImageSkia(); diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model.cc b/chrome/browser/ui/toolbar/back_forward_menu_model.cc index e1648d9..2c8ec53 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model.cc +++ b/chrome/browser/ui/toolbar/back_forward_menu_model.cc @@ -15,9 +15,9 @@ #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/singleton_tabs.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/common/favicon/favicon_types.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" +#include "components/favicon_base/favicon_types.h" #include "content/public/browser/favicon_status.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" @@ -255,9 +255,8 @@ void BackForwardMenuModel::FetchFavicon(NavigationEntry* entry) { return; favicon_service->GetFaviconImageForURL( - FaviconService::FaviconForURLParams(entry->GetURL(), - chrome::FAVICON, - gfx::kFaviconSize), + FaviconService::FaviconForURLParams( + entry->GetURL(), favicon_base::FAVICON, gfx::kFaviconSize), base::Bind(&BackForwardMenuModel::OnFavIconDataAvailable, base::Unretained(this), entry->GetUniqueID()), @@ -266,7 +265,7 @@ void BackForwardMenuModel::FetchFavicon(NavigationEntry* entry) { void BackForwardMenuModel::OnFavIconDataAvailable( int navigation_entry_unique_id, - const chrome::FaviconImageResult& image_result) { + const favicon_base::FaviconImageResult& image_result) { if (!image_result.image.IsEmpty()) { // Find the current model_index for the unique id. NavigationEntry* entry = NULL; diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model.h b/chrome/browser/ui/toolbar/back_forward_menu_model.h index 66082ad..af3437e 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model.h +++ b/chrome/browser/ui/toolbar/back_forward_menu_model.h @@ -18,7 +18,7 @@ class Browser; -namespace chrome { +namespace favicon_base { struct FaviconImageResult; } @@ -102,7 +102,7 @@ class BackForwardMenuModel : public ui::MenuModel { // Callback from the favicon service. void OnFavIconDataAvailable( int navigation_entry_unique_id, - const chrome::FaviconImageResult& image_result); + const favicon_base::FaviconImageResult& image_result); // Allows the unit test to use its own dummy tab contents. void set_test_web_contents(content::WebContents* test_web_contents) { diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc index df7787a..cd333b7 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc +++ b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc @@ -524,10 +524,11 @@ TEST_F(BackFwdMenuModelTest, FaviconLoadTest) { HistoryServiceFactory::GetForProfile( profile(), Profile::EXPLICIT_ACCESS)->AddPage( url1, base::Time::Now(), history::SOURCE_BROWSED); - FaviconServiceFactory::GetForProfile( - profile(), Profile::EXPLICIT_ACCESS)->SetFavicons( - url1, url1_favicon, chrome::FAVICON, - gfx::Image::CreateFrom1xBitmap(new_icon_bitmap)); + FaviconServiceFactory::GetForProfile(profile(), Profile::EXPLICIT_ACCESS) + ->SetFavicons(url1, + url1_favicon, + favicon_base::FAVICON, + gfx::Image::CreateFrom1xBitmap(new_icon_bitmap)); // Will return the current icon (default) but start an anync call // to retrieve the favicon from the favicon service. diff --git a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc index 57f5898..27431d3 100644 --- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc +++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc @@ -25,8 +25,8 @@ #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/toolbar/wrench_menu_model.h" -#include "chrome/common/favicon/favicon_types.h" #include "chrome/common/pref_names.h" +#include "components/favicon_base/favicon_types.h" #include "grit/browser_resources.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -610,19 +610,18 @@ void RecentTabsSubMenuModel::AddTabFavicon(int command_id, const GURL& url) { return; favicon_service->GetFaviconImageForURL( - FaviconService::FaviconForURLParams(url, - chrome::FAVICON, - gfx::kFaviconSize), + FaviconService::FaviconForURLParams( + url, favicon_base::FAVICON, gfx::kFaviconSize), base::Bind(&RecentTabsSubMenuModel::OnFaviconDataAvailable, weak_ptr_factory_.GetWeakPtr(), command_id), - is_local_tab ? &local_tab_cancelable_task_tracker_ : - &other_devices_tab_cancelable_task_tracker_); + is_local_tab ? &local_tab_cancelable_task_tracker_ + : &other_devices_tab_cancelable_task_tracker_); } void RecentTabsSubMenuModel::OnFaviconDataAvailable( int command_id, - const chrome::FaviconImageResult& image_result) { + const favicon_base::FaviconImageResult& image_result) { if (image_result.image.IsEmpty()) return; int index_in_menu = GetIndexOfCommandId(command_id); diff --git a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h index 2e1b5bf..313d62b 100644 --- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h +++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h @@ -23,7 +23,7 @@ namespace browser_sync { class OpenTabsUIDelegate; } -namespace chrome { +namespace favicon_base { struct FaviconImageResult; } @@ -107,8 +107,9 @@ class RecentTabsSubMenuModel : public ui::SimpleMenuModel, // Add the favicon for a local or other devices' tab asynchronously, // OnFaviconDataAvailable() will be invoked when the favicon is ready. void AddTabFavicon(int command_id, const GURL& url); - void OnFaviconDataAvailable(int command_id, - const chrome::FaviconImageResult& image_result); + void OnFaviconDataAvailable( + int command_id, + const favicon_base::FaviconImageResult& image_result); // Clear all recently closed tabs and windows. void ClearLocalEntries(); diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc index 48fddaa..27b3e2f 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc @@ -520,7 +520,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, void RunFaviconCallbackAsync( const FaviconService::FaviconResultsCallback& callback, - const std::vector<chrome::FaviconBitmapResult>* results) { + const std::vector<favicon_base::FaviconBitmapResult>* results) { base::MessageLoopProxy::current()->PostTask( FROM_HERE, base::Bind(&FaviconService::FaviconResultsCallbackRunner, @@ -579,23 +579,23 @@ void ChromeWebUIControllerFactory::GetFaviconForURL( #if defined(ENABLE_EXTENSIONS) ExtensionWebUI::GetFaviconForURL(profile, url, callback); #else - RunFaviconCallbackAsync(callback, - new std::vector<chrome::FaviconBitmapResult>()); + RunFaviconCallbackAsync( + callback, new std::vector<favicon_base::FaviconBitmapResult>()); #endif return; } - std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results = - new std::vector<chrome::FaviconBitmapResult>(); + std::vector<favicon_base::FaviconBitmapResult>* favicon_bitmap_results = + new std::vector<favicon_base::FaviconBitmapResult>(); for (size_t i = 0; i < scale_factors.size(); ++i) { scoped_refptr<base::RefCountedMemory> bitmap(GetFaviconResourceBytes( url, scale_factors[i])); if (bitmap.get() && bitmap->size()) { - chrome::FaviconBitmapResult bitmap_result; + favicon_base::FaviconBitmapResult bitmap_result; bitmap_result.bitmap_data = bitmap; // Leave |bitmap_result|'s icon URL as the default of GURL(). - bitmap_result.icon_type = chrome::FAVICON; + bitmap_result.icon_type = favicon_base::FAVICON; favicon_bitmap_results->push_back(bitmap_result); // Assume that |bitmap| is |gfx::kFaviconSize| x |gfx::kFaviconSize| diff --git a/chrome/browser/ui/webui/extensions/extension_icon_source.cc b/chrome/browser/ui/webui/extensions/extension_icon_source.cc index ad54869..4c188ba 100644 --- a/chrome/browser/ui/webui/extensions/extension_icon_source.cc +++ b/chrome/browser/ui/webui/extensions/extension_icon_source.cc @@ -220,17 +220,18 @@ void ExtensionIconSource::LoadFaviconImage(int request_id) { GURL favicon_url = AppLaunchInfo::GetFullLaunchURL(GetData(request_id)->extension); favicon_service->GetRawFaviconForURL( - FaviconService::FaviconForURLParams(favicon_url, chrome::FAVICON, - gfx::kFaviconSize), + FaviconService::FaviconForURLParams( + favicon_url, favicon_base::FAVICON, gfx::kFaviconSize), ui::SCALE_FACTOR_100P, base::Bind(&ExtensionIconSource::OnFaviconDataAvailable, - base::Unretained(this), request_id), + base::Unretained(this), + request_id), &cancelable_task_tracker_); } void ExtensionIconSource::OnFaviconDataAvailable( int request_id, - const chrome::FaviconBitmapResult& bitmap_result) { + const favicon_base::FaviconBitmapResult& bitmap_result) { ExtensionIconRequest* request = GetData(request_id); // Fallback to the default icon if there wasn't a favicon. diff --git a/chrome/browser/ui/webui/extensions/extension_icon_source.h b/chrome/browser/ui/webui/extensions/extension_icon_source.h index d961055..2ec71bc 100644 --- a/chrome/browser/ui/webui/extensions/extension_icon_source.h +++ b/chrome/browser/ui/webui/extensions/extension_icon_source.h @@ -110,7 +110,7 @@ class ExtensionIconSource : public content::URLDataSource, // FaviconService callback void OnFaviconDataAvailable( int request_id, - const chrome::FaviconBitmapResult& bitmap_result); + const favicon_base::FaviconBitmapResult& bitmap_result); // ImageLoader callback void OnImageLoaded(int request_id, const gfx::Image& image); diff --git a/chrome/browser/ui/webui/favicon_source.cc b/chrome/browser/ui/webui/favicon_source.cc index cef2344..46cce9b 100644 --- a/chrome/browser/ui/webui/favicon_source.cc +++ b/chrome/browser/ui/webui/favicon_source.cc @@ -45,17 +45,17 @@ FaviconSource::IconRequest::~IconRequest() { FaviconSource::FaviconSource(Profile* profile, IconType type) : profile_(profile->GetOriginalProfile()), - icon_types_(type == FAVICON ? chrome::FAVICON : - chrome::TOUCH_PRECOMPOSED_ICON | chrome::TOUCH_ICON | - chrome::FAVICON) { -} + icon_types_(type == FAVICON ? favicon_base::FAVICON + : favicon_base::TOUCH_PRECOMPOSED_ICON | + favicon_base::TOUCH_ICON | + favicon_base::FAVICON) {} FaviconSource::~FaviconSource() { } std::string FaviconSource::GetSource() const { - return icon_types_ == chrome::FAVICON ? - chrome::kChromeUIFaviconHost : chrome::kChromeUITouchIconHost; + return icon_types_ == favicon_base::FAVICON ? chrome::kChromeUIFaviconHost + : chrome::kChromeUITouchIconHost; } void FaviconSource::StartDataRequest( @@ -84,15 +84,13 @@ void FaviconSource::StartDataRequest( // IconType. favicon_service->GetRawFavicon( url, - chrome::FAVICON, + favicon_base::FAVICON, parsed.size_in_dip, parsed.scale_factor, base::Bind(&FaviconSource::OnFaviconDataAvailable, base::Unretained(this), - IconRequest(callback, - url, - parsed.size_in_dip, - parsed.scale_factor)), + IconRequest( + callback, url, parsed.size_in_dip, parsed.scale_factor)), &cancelable_task_tracker_); } else { // Intercept requests for prepopulated pages. @@ -158,7 +156,7 @@ bool FaviconSource::HandleMissingResource(const IconRequest& request) { void FaviconSource::OnFaviconDataAvailable( const IconRequest& request, - const chrome::FaviconBitmapResult& bitmap_result) { + const favicon_base::FaviconBitmapResult& bitmap_result) { if (bitmap_result.is_valid()) { // Forward the data along to the networking system. request.callback.Run(bitmap_result.bitmap_data.get()); diff --git a/chrome/browser/ui/webui/favicon_source.h b/chrome/browser/ui/webui/favicon_source.h index b60b9f2..1dc7eda 100644 --- a/chrome/browser/ui/webui/favicon_source.h +++ b/chrome/browser/ui/webui/favicon_source.h @@ -120,7 +120,7 @@ class FaviconSource : public content::URLDataSource { // Called when favicon data is available from the history backend. void OnFaviconDataAvailable( const IconRequest& request, - const chrome::FaviconBitmapResult& bitmap_result); + const favicon_base::FaviconBitmapResult& bitmap_result); // Sends the 16x16 DIP 1x default favicon. void SendDefaultResponse( @@ -135,7 +135,7 @@ class FaviconSource : public content::URLDataSource { // database doesn't have a favicon for a webpage. Indexed by IconSize values. scoped_refptr<base::RefCountedMemory> default_favicons_[NUM_SIZES]; - // The chrome::IconTypes of icon that this FaviconSource handles. + // The favicon_base::IconTypes of icon that this FaviconSource handles. int icon_types_; DISALLOW_COPY_AND_ASSIGN(FaviconSource); diff --git a/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc b/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc index 40bb7b0..b9eaef4 100644 --- a/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc +++ b/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc @@ -450,11 +450,11 @@ void BookmarksHandler::HandleCreateHomeScreenBookmarkShortcut( FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( profile, Profile::EXPLICIT_ACCESS); favicon_service->GetRawFaviconForURL( - FaviconService::FaviconForURLParams( - node->url(), - chrome::TOUCH_PRECOMPOSED_ICON | chrome::TOUCH_ICON | - chrome::FAVICON, - 0), // request the largest icon. + FaviconService::FaviconForURLParams(node->url(), + favicon_base::TOUCH_PRECOMPOSED_ICON | + favicon_base::TOUCH_ICON | + favicon_base::FAVICON, + 0), // request the largest icon. ui::SCALE_FACTOR_100P, // density doesn't matter for the largest icon. base::Bind(&BookmarksHandler::OnShortcutFaviconDataAvailable, base::Unretained(this), @@ -464,7 +464,7 @@ void BookmarksHandler::HandleCreateHomeScreenBookmarkShortcut( void BookmarksHandler::OnShortcutFaviconDataAvailable( const BookmarkNode* node, - const chrome::FaviconBitmapResult& bitmap_result) { + const favicon_base::FaviconBitmapResult& bitmap_result) { if (!AreModelsLoaded()) return; diff --git a/chrome/browser/ui/webui/ntp/android/bookmarks_handler.h b/chrome/browser/ui/webui/ntp/android/bookmarks_handler.h index 978f17f..1cf2606 100644 --- a/chrome/browser/ui/webui/ntp/android/bookmarks_handler.h +++ b/chrome/browser/ui/webui/ntp/android/bookmarks_handler.h @@ -148,7 +148,7 @@ class BookmarksHandler : public content::WebUIMessageHandler, // and is available for use. void OnShortcutFaviconDataAvailable( const BookmarkNode* node, - const chrome::FaviconBitmapResult& bitmap_result); + const favicon_base::FaviconBitmapResult& bitmap_result); // Looks at an optional bookmark ID in |args| and returns the corresponding // node if found, otherwise returns NULL. diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc index c34ee9a..4d49f69 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc @@ -38,10 +38,10 @@ #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" -#include "chrome/common/favicon/favicon_types.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "chrome/common/web_application_info.h" +#include "components/favicon_base/favicon_types.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/web_ui.h" #include "content/public/common/favicon_url.h" @@ -714,9 +714,8 @@ void AppLauncherHandler::HandleGenerateAppForLink(const base::ListValue* args) { install_info->page_ordinal = page_ordinal; favicon_service->GetFaviconImageForURL( - FaviconService::FaviconForURLParams(launch_url, - chrome::FAVICON, - gfx::kFaviconSize), + FaviconService::FaviconForURLParams( + launch_url, favicon_base::FAVICON, gfx::kFaviconSize), base::Bind(&AppLauncherHandler::OnFaviconForApp, base::Unretained(this), base::Passed(&install_info)), @@ -738,7 +737,7 @@ void AppLauncherHandler::OnLearnMore(const base::ListValue* args) { void AppLauncherHandler::OnFaviconForApp( scoped_ptr<AppInstallInfo> install_info, - const chrome::FaviconImageResult& image_result) { + const favicon_base::FaviconImageResult& image_result) { scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo()); web_app->title = install_info->title; web_app->app_url = install_info->app_url; diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.h b/chrome/browser/ui/webui/ntp/app_launcher_handler.h index 4552d39..b6dc2dc 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.h +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.h @@ -27,7 +27,7 @@ class ExtensionService; class PrefChangeRegistrar; class Profile; -namespace chrome { +namespace favicon_base { struct FaviconImageResult; } @@ -136,7 +136,7 @@ class AppLauncherHandler : public content::WebUIMessageHandler, // Continuation for installing a bookmark app after favicon lookup. void OnFaviconForApp(scoped_ptr<AppInstallInfo> install_info, - const chrome::FaviconImageResult& image_result); + const favicon_base::FaviconImageResult& image_result); // Sends |highlight_app_id_| to the js. void SetAppToBeHighlighted(); diff --git a/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc b/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc index 975c716..365a793 100644 --- a/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc +++ b/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc @@ -114,9 +114,7 @@ void FaviconWebUIHandler::HandleGetFaviconDominantColor( dom_id_map_[id_] = dom_id; favicon_service->GetRawFaviconForURL( FaviconService::FaviconForURLParams( - url, - chrome::FAVICON, - gfx::kFaviconSize), + url, favicon_base::FAVICON, gfx::kFaviconSize), ui::SCALE_FACTOR_100P, base::Bind(&FaviconWebUIHandler::OnFaviconDataAvailable, base::Unretained(this), @@ -126,7 +124,7 @@ void FaviconWebUIHandler::HandleGetFaviconDominantColor( void FaviconWebUIHandler::OnFaviconDataAvailable( int id, - const chrome::FaviconBitmapResult& bitmap_result) { + const favicon_base::FaviconBitmapResult& bitmap_result) { scoped_ptr<base::StringValue> color_value; if (bitmap_result.is_valid()) diff --git a/chrome/browser/ui/webui/ntp/favicon_webui_handler.h b/chrome/browser/ui/webui/ntp/favicon_webui_handler.h index b3a3f44..dd19e17 100644 --- a/chrome/browser/ui/webui/ntp/favicon_webui_handler.h +++ b/chrome/browser/ui/webui/ntp/favicon_webui_handler.h @@ -11,7 +11,7 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/task/cancelable_task_tracker.h" -#include "chrome/common/favicon/favicon_types.h" +#include "components/favicon_base/favicon_types.h" #include "content/public/browser/web_ui_message_handler.h" class ExtensionIconColorManager; @@ -41,8 +41,9 @@ class FaviconWebUIHandler : public content::WebUIMessageHandler { private: // Called when favicon data is available from the history backend. - void OnFaviconDataAvailable(int request_handle, - const chrome::FaviconBitmapResult& bitmap_result); + void OnFaviconDataAvailable( + int request_handle, + const favicon_base::FaviconBitmapResult& bitmap_result); base::CancelableTaskTracker cancelable_task_tracker_; |