diff options
Diffstat (limited to 'chrome/browser')
75 files changed, 941 insertions, 777 deletions
diff --git a/chrome/browser/android/provider/chrome_browser_provider.cc b/chrome/browser/android/provider/chrome_browser_provider.cc index 2ccca8f..0216dd8 100644 --- a/chrome/browser/android/provider/chrome_browser_provider.cc +++ b/chrome/browser/android/provider/chrome_browser_provider.cc @@ -667,14 +667,14 @@ class BookmarkIconFetchTask : public FaviconServiceTask { : FaviconServiceTask(favicon_service, profile, cancelable_consumer, cancelable_tracker) {} - history::FaviconBitmapResult Run(const GURL& url) { + chrome::FaviconBitmapResult Run(const GURL& url) { RunAsyncRequestOnUIThreadBlocking( base::Bind(&FaviconService::GetRawFaviconForURL, base::Unretained(service()), FaviconService::FaviconForURLParams( profile(), url, - history::FAVICON | history::TOUCH_ICON, + chrome::FAVICON | chrome::TOUCH_ICON, gfx::kFaviconSize), ui::GetMaxScaleFactor(), base::Bind( @@ -685,12 +685,12 @@ class BookmarkIconFetchTask : public FaviconServiceTask { } private: - void OnFaviconRetrieved(const history::FaviconBitmapResult& bitmap_result) { + void OnFaviconRetrieved(const chrome::FaviconBitmapResult& bitmap_result) { result_ = bitmap_result; RequestCompleted(); } - history::FaviconBitmapResult result_; + chrome::FaviconBitmapResult result_; DISALLOW_COPY_AND_ASSIGN(BookmarkIconFetchTask); }; @@ -1549,7 +1549,7 @@ ScopedJavaLocalRef<jbyteArray> ChromeBrowserProvider::GetFaviconOrTouchIcon( profile_, &favicon_consumer_, &cancelable_task_tracker_); - history::FaviconBitmapResult bitmap_result = favicon_task.Run(url); + chrome::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/bookmarks/DEPS b/chrome/browser/bookmarks/DEPS index b847f57..9039e2c 100644 --- a/chrome/browser/bookmarks/DEPS +++ b/chrome/browser/bookmarks/DEPS @@ -13,7 +13,6 @@ include_rules = [ "!chrome/browser/history/history_notifications.h", "!chrome/browser/history/history_service.h", "!chrome/browser/history/history_service_factory.h", - "!chrome/browser/history/history_types.h", "!chrome/browser/history/query_parser.h", "!chrome/browser/history/snippet.h", "!chrome/browser/history/url_database.h", diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc index aeb125d..6ddd35b 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer.cc @@ -19,7 +19,7 @@ #include "chrome/browser/bookmarks/bookmark_model_factory.h" #include "chrome/browser/favicon/favicon_service.h" #include "chrome/browser/favicon/favicon_service_factory.h" -#include "chrome/browser/history/history_types.h" +#include "chrome/browser/favicon/favicon_types.h" #include "chrome/common/chrome_notification_types.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_source.h" @@ -463,7 +463,7 @@ bool BookmarkFaviconFetcher::FetchNextFavicon() { profile_, Profile::EXPLICIT_ACCESS); favicon_service->GetRawFaviconForURL( FaviconService::FaviconForURLParams( - profile_, GURL(url), history::FAVICON, gfx::kFaviconSize), + profile_, GURL(url), chrome::FAVICON, gfx::kFaviconSize), ui::SCALE_FACTOR_100P, base::Bind(&BookmarkFaviconFetcher::OnFaviconDataAvailable, base::Unretained(this)), @@ -477,7 +477,7 @@ bool BookmarkFaviconFetcher::FetchNextFavicon() { } void BookmarkFaviconFetcher::OnFaviconDataAvailable( - const history::FaviconBitmapResult& bitmap_result) { + const chrome::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 5f588ae..de1ea3b 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer.h +++ b/chrome/browser/bookmarks/bookmark_html_writer.h @@ -19,7 +19,7 @@ class BookmarkNode; class Profile; -namespace history { +namespace chrome { struct FaviconBitmapResult; } @@ -69,8 +69,7 @@ class BookmarkFaviconFetcher: public content::NotificationObserver { // Favicon fetch callback. After all favicons are fetched executes // html output on the file thread. - void OnFaviconDataAvailable( - const history::FaviconBitmapResult& bitmap_result); + void OnFaviconDataAvailable(const chrome::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 826b3f3..66cfc3d 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc @@ -207,7 +207,7 @@ TEST_F(BookmarkHTMLWriterTest, Test) { AddPage(url1, base::Time::Now(), history::SOURCE_BROWSED); FaviconServiceFactory::GetForProfile( &profile, Profile::EXPLICIT_ACCESS)->SetFavicons( - url1, url1_favicon, history::FAVICON, + url1, url1_favicon, chrome::FAVICON, gfx::Image::CreateFrom1xBitmap(bitmap)); message_loop.RunUntilIdle(); const BookmarkNode* f2 = model->AddFolder(f1, 1, f2_title); @@ -234,7 +234,7 @@ TEST_F(BookmarkHTMLWriterTest, Test) { // Clear favicon so that it would be read from file. FaviconServiceFactory::GetForProfile( &profile, Profile::EXPLICIT_ACCESS)->SetFavicons( - url1, url1_favicon, history::FAVICON, gfx::Image()); + url1, url1_favicon, chrome::FAVICON, gfx::Image()); message_loop.RunUntilIdle(); // Read the bookmarks back in. diff --git a/chrome/browser/bookmarks/bookmark_model.cc b/chrome/browser/bookmarks/bookmark_model.cc index 8983c01..6adf04a 100644 --- a/chrome/browser/bookmarks/bookmark_model.cc +++ b/chrome/browser/bookmarks/bookmark_model.cc @@ -23,6 +23,7 @@ #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/favicon/favicon_service.h" #include "chrome/browser/favicon/favicon_service_factory.h" +#include "chrome/browser/favicon/favicon_types.h" #include "chrome/browser/history/history_notifications.h" #include "chrome/browser/history/history_service.h" #include "chrome/browser/history/history_service_factory.h" @@ -904,7 +905,7 @@ BookmarkPermanentNode* BookmarkModel::CreatePermanentNode( void BookmarkModel::OnFaviconDataAvailable( BookmarkNode* node, - const history::FaviconImageResult& image_result) { + const chrome::FaviconImageResult& image_result) { DCHECK(node); node->set_favicon_load_task_id(CancelableTaskTracker::kBadTaskId); node->set_favicon_state(BookmarkNode::LOADED_FAVICON); @@ -927,7 +928,7 @@ void BookmarkModel::LoadFavicon(BookmarkNode* node) { FaviconService::Handle handle = favicon_service->GetFaviconImageForURL( FaviconService::FaviconForURLParams(profile_, node->url(), - history::FAVICON, + chrome::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 dbb82e9..95191d5 100644 --- a/chrome/browser/bookmarks/bookmark_model.h +++ b/chrome/browser/bookmarks/bookmark_model.h @@ -41,7 +41,7 @@ namespace bookmark_utils { struct TitleMatch; } -namespace history { +namespace chrome { struct FaviconImageResult; } @@ -473,7 +473,7 @@ 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 history::FaviconImageResult& image_result); + const chrome::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 7c7c95f..95a1bb4 100644 --- a/chrome/browser/extensions/extension_web_ui.cc +++ b/chrome/browser/extensions/extension_web_ui.cc @@ -86,8 +86,8 @@ void UnregisterAndReplaceOverrideForWebContents( void RunFaviconCallbackAsync( const FaviconService::FaviconResultsCallback& callback, const gfx::Image& image) { - std::vector<history::FaviconBitmapResult>* favicon_bitmap_results = - new std::vector<history::FaviconBitmapResult>(); + std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results = + new std::vector<chrome::FaviconBitmapResult>(); const std::vector<gfx::ImageSkiaRep>& image_reps = image.AsImageSkia().image_reps(); @@ -98,12 +98,12 @@ void RunFaviconCallbackAsync( if (gfx::PNGCodec::EncodeBGRASkBitmap(image_rep.sk_bitmap(), false, &bitmap_data->data())) { - history::FaviconBitmapResult bitmap_result; + chrome::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 = history::FAVICON; + bitmap_result.icon_type = chrome::FAVICON; favicon_bitmap_results->push_back(bitmap_result); } else { diff --git a/chrome/browser/favicon/DEPS b/chrome/browser/favicon/DEPS index a609c84..a5fc921 100644 --- a/chrome/browser/favicon/DEPS +++ b/chrome/browser/favicon/DEPS @@ -20,7 +20,6 @@ "!chrome/browser/history/history_backend.h", "!chrome/browser/history/history_service.h", "!chrome/browser/history/history_service_factory.h", - "!chrome/browser/history/history_types.h", "!chrome/browser/history/select_favicon_frames.h", "!chrome/browser/profiles/profile.h", "!chrome/browser/profiles/profile_dependency_manager.h", @@ -36,6 +35,7 @@ specific_include_rules = { 'favicon_util\.(h|cc)': [ "-chrome", "-chrome/browser", + "+chrome/browser/favicon/favicon_types.h", "+chrome/browser/favicon/favicon_util.h", "+chrome/common/icon_messages.h", "!chrome/browser/history/history_types.h", diff --git a/chrome/browser/favicon/favicon_handler.cc b/chrome/browser/favicon/favicon_handler.cc index c9f3af3..4771790 100644 --- a/chrome/browser/favicon/favicon_handler.cc +++ b/chrome/browser/favicon/favicon_handler.cc @@ -30,26 +30,26 @@ using content::NavigationEntry; namespace { -// Returns history::IconType the given icon_type corresponds to. -history::IconType ToHistoryIconType(FaviconURL::IconType icon_type) { +// Returns chrome::IconType the given icon_type corresponds to. +chrome::IconType ToHistoryIconType(FaviconURL::IconType icon_type) { switch (icon_type) { case FaviconURL::FAVICON: - return history::FAVICON; + return chrome::FAVICON; case FaviconURL::TOUCH_ICON: - return history::TOUCH_ICON; + return chrome::TOUCH_ICON; case FaviconURL::TOUCH_PRECOMPOSED_ICON: - return history::TOUCH_PRECOMPOSED_ICON; + return chrome::TOUCH_PRECOMPOSED_ICON; case FaviconURL::INVALID_ICON: - return history::INVALID_ICON; + return chrome::INVALID_ICON; } NOTREACHED(); // Shouldn't reach here, just make compiler happy. - return history::INVALID_ICON; + return chrome::INVALID_ICON; } bool DoUrlAndIconMatch(const FaviconURL& favicon_url, const GURL& url, - history::IconType icon_type) { + chrome::IconType icon_type) { return favicon_url.icon_url == url && favicon_url.icon_type == static_cast<FaviconURL::IconType>(icon_type); } @@ -59,11 +59,11 @@ bool DoUrlAndIconMatch(const FaviconURL& favicon_url, // Returns false if |bitmap_results| is empty. bool DoUrlsAndIconsMatch( const FaviconURL& favicon_url, - const std::vector<history::FaviconBitmapResult>& bitmap_results) { + const std::vector<chrome::FaviconBitmapResult>& bitmap_results) { if (bitmap_results.empty()) return false; - history::IconType icon_type = ToHistoryIconType(favicon_url.icon_type); + chrome::IconType icon_type = ToHistoryIconType(favicon_url.icon_type); for (size_t i = 0; i < bitmap_results.size(); ++i) { if (favicon_url.icon_url != bitmap_results[i].icon_url || @@ -85,12 +85,12 @@ bool UrlMatches(const GURL& gurl_a, const GURL& gurl_b) { } // Return true if |bitmap_result| is expired. -bool IsExpired(const history::FaviconBitmapResult& bitmap_result) { +bool IsExpired(const chrome::FaviconBitmapResult& bitmap_result) { return bitmap_result.expired; } // Return true if |bitmap_result| is valid. -bool IsValid(const history::FaviconBitmapResult& bitmap_result) { +bool IsValid(const chrome::FaviconBitmapResult& bitmap_result) { return bitmap_result.is_valid(); } @@ -99,9 +99,9 @@ bool IsValid(const history::FaviconBitmapResult& bitmap_result) { // the scale factors in FaviconUtil::GetFaviconScaleFactors(). bool HasExpiredOrIncompleteResult( int desired_size_in_dip, - const std::vector<history::FaviconBitmapResult>& bitmap_results) { + const std::vector<chrome::FaviconBitmapResult>& bitmap_results) { // Check if at least one of the bitmaps is expired. - std::vector<history::FaviconBitmapResult>::const_iterator it = + std::vector<chrome::FaviconBitmapResult>::const_iterator it = std::find_if(bitmap_results.begin(), bitmap_results.end(), IsExpired); if (it != bitmap_results.end()) return true; @@ -136,8 +136,8 @@ bool HasExpiredOrIncompleteResult( // Returns true if at least one of |bitmap_results| is valid. bool HasValidResult( - const std::vector<history::FaviconBitmapResult>& bitmap_results) { - std::vector<history::FaviconBitmapResult>::const_iterator it = + const std::vector<chrome::FaviconBitmapResult>& bitmap_results) { + std::vector<chrome::FaviconBitmapResult>::const_iterator it = std::find_if(bitmap_results.begin(), bitmap_results.end(), IsValid); return it != bitmap_results.end(); } @@ -147,7 +147,7 @@ bool HasValidResult( //////////////////////////////////////////////////////////////////////////////// FaviconHandler::DownloadRequest::DownloadRequest() - : icon_type(history::INVALID_ICON) { + : icon_type(chrome::INVALID_ICON) { } FaviconHandler::DownloadRequest::~DownloadRequest() { @@ -156,7 +156,7 @@ FaviconHandler::DownloadRequest::~DownloadRequest() { FaviconHandler::DownloadRequest::DownloadRequest( const GURL& url, const GURL& image_url, - history::IconType icon_type) + chrome::IconType icon_type) : url(url), image_url(image_url), icon_type(icon_type) { @@ -166,7 +166,7 @@ FaviconHandler::DownloadRequest::DownloadRequest( FaviconHandler::FaviconCandidate::FaviconCandidate() : score(0), - icon_type(history::INVALID_ICON) { + icon_type(chrome::INVALID_ICON) { } FaviconHandler::FaviconCandidate::~FaviconCandidate() { @@ -177,7 +177,7 @@ FaviconHandler::FaviconCandidate::FaviconCandidate( const GURL& image_url, const gfx::Image& image, float score, - history::IconType icon_type) + chrome::IconType icon_type) : url(url), image_url(image_url), image(image), @@ -192,8 +192,8 @@ FaviconHandler::FaviconHandler(Profile* profile, Type icon_type) : got_favicon_from_history_(false), favicon_expired_or_incomplete_(false), - icon_types_(icon_type == FAVICON ? history::FAVICON : - history::TOUCH_ICON | history::TOUCH_PRECOMPOSED_ICON), + icon_types_(icon_type == FAVICON ? chrome::FAVICON : + chrome::TOUCH_ICON | chrome::TOUCH_PRECOMPOSED_ICON), profile_(profile), delegate_(delegate) { DCHECK(profile_); @@ -233,14 +233,14 @@ bool FaviconHandler::UpdateFaviconCandidate(const GURL& url, const GURL& image_url, const gfx::Image& image, float score, - history::IconType icon_type) { + chrome::IconType icon_type) { bool update_candidate = false; bool exact_match = score == 1; if (preferred_icon_size() == 0) { // No preferred size, use this icon. update_candidate = true; exact_match = true; - } else if (favicon_candidate_.icon_type == history::INVALID_ICON) { + } else if (favicon_candidate_.icon_type == chrome::INVALID_ICON) { // No current candidate, use this. update_candidate = true; } else { @@ -264,11 +264,11 @@ void FaviconHandler::SetFavicon( const GURL& url, const GURL& icon_url, const gfx::Image& image, - history::IconType icon_type) { + chrome::IconType icon_type) { if (GetFaviconService() && ShouldSaveFavicon(url)) SetHistoryFavicons(url, icon_url, icon_type, image); - if (UrlMatches(url, url_) && icon_type == history::FAVICON) { + if (UrlMatches(url, url_) && icon_type == chrome::FAVICON) { NavigationEntry* entry = GetEntry(); if (entry) UpdateFavicon(entry, icon_url, image); @@ -276,7 +276,7 @@ void FaviconHandler::SetFavicon( } void FaviconHandler::UpdateFavicon(NavigationEntry* entry, - const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results) { + const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results) { gfx::Image resized_image = FaviconUtil::SelectFaviconFramesFromPNGs( favicon_bitmap_results, FaviconUtil::GetFaviconScaleFactors(), @@ -338,7 +338,7 @@ void FaviconHandler::ProcessCurrentUrl() { if (current_candidate()->icon_type == FaviconURL::FAVICON) { if (!favicon_expired_or_incomplete_ && entry->GetFavicon().valid && DoUrlAndIconMatch(*current_candidate(), entry->GetFavicon().url, - history::FAVICON)) + chrome::FAVICON)) return; } else if (!favicon_expired_or_incomplete_ && got_favicon_from_history_ && HasValidResult(history_results_) && @@ -382,7 +382,7 @@ void FaviconHandler::OnDidDownloadFavicon( // Remove the first member of image_urls_ and process the remaining. image_urls_.pop_front(); ProcessCurrentUrl(); - } else if (favicon_candidate_.icon_type != history::INVALID_ICON) { + } else if (favicon_candidate_.icon_type != chrome::INVALID_ICON) { // No more icons to request, set the favicon from the candidate. SetFavicon(favicon_candidate_.url, favicon_candidate_.image_url, @@ -418,7 +418,7 @@ int FaviconHandler::DownloadFavicon(const GURL& image_url, int image_size) { void FaviconHandler::UpdateFaviconMappingAndFetch( const GURL& page_url, const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, const FaviconService::FaviconResultsCallback& callback, CancelableTaskTracker* tracker) { // TODO(pkotwicz): pass in all of |image_urls_| to @@ -431,7 +431,7 @@ void FaviconHandler::UpdateFaviconMappingAndFetch( void FaviconHandler::GetFavicon( const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, const FaviconService::FaviconResultsCallback& callback, CancelableTaskTracker* tracker) { GetFaviconService()->GetFavicon( @@ -452,7 +452,7 @@ void FaviconHandler::GetFaviconForURL( void FaviconHandler::SetHistoryFavicons(const GURL& page_url, const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, const gfx::Image& image) { GetFaviconService()->SetFavicons(page_url, icon_url, icon_type, image); } @@ -468,7 +468,7 @@ bool FaviconHandler::ShouldSaveFavicon(const GURL& url) { } void FaviconHandler::OnFaviconDataForInitialURL( - const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results) { + const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results) { NavigationEntry* entry = GetEntry(); if (!entry) return; @@ -480,7 +480,7 @@ void FaviconHandler::OnFaviconDataForInitialURL( favicon_expired_or_incomplete_ = has_results && HasExpiredOrIncompleteResult( preferred_icon_size(), favicon_bitmap_results); - if (has_results && icon_types_ == history::FAVICON && + if (has_results && icon_types_ == chrome::FAVICON && !entry->GetFavicon().valid && (!current_candidate() || DoUrlsAndIconsMatch(*current_candidate(), favicon_bitmap_results))) { @@ -506,7 +506,7 @@ void FaviconHandler::OnFaviconDataForInitialURL( // already have it. DownloadFaviconOrAskHistory(entry->GetURL(), current_candidate()->icon_url, - static_cast<history::IconType>(current_candidate()->icon_type)); + static_cast<chrome::IconType>(current_candidate()->icon_type)); } } else if (current_candidate()) { // We know the official url for the favicon, by either don't have the @@ -522,7 +522,7 @@ void FaviconHandler::OnFaviconDataForInitialURL( void FaviconHandler::DownloadFaviconOrAskHistory( const GURL& page_url, const GURL& icon_url, - history::IconType icon_type) { + chrome::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, preferred_icon_size(), icon_type); @@ -551,7 +551,7 @@ void FaviconHandler::DownloadFaviconOrAskHistory( } void FaviconHandler::OnFaviconData( - const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results) { + const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results) { NavigationEntry* entry = GetEntry(); if (!entry) return; @@ -560,7 +560,7 @@ void FaviconHandler::OnFaviconData( bool has_expired_or_incomplete_result = HasExpiredOrIncompleteResult( preferred_icon_size(), favicon_bitmap_results); - if (has_results && icon_types_ == history::FAVICON) { + if (has_results && icon_types_ == chrome::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 @@ -571,7 +571,7 @@ void FaviconHandler::OnFaviconData( // The favicon is out of date. Request the current one. ScheduleDownload(entry->GetURL(), entry->GetFavicon().url, preferred_icon_size(), - history::FAVICON); + chrome::FAVICON); } } else if (current_candidate() && (!has_results || has_expired_or_incomplete_result || @@ -589,7 +589,7 @@ int FaviconHandler::ScheduleDownload( const GURL& url, const GURL& image_url, int image_size, - history::IconType icon_type) { + chrome::IconType icon_type) { const int download_id = DownloadFavicon(image_url, image_size); if (download_id) { // Download ids should be unique. diff --git a/chrome/browser/favicon/favicon_handler.h b/chrome/browser/favicon/favicon_handler.h index 23a92bb..8a044e2 100644 --- a/chrome/browser/favicon/favicon_handler.h +++ b/chrome/browser/favicon/favicon_handler.h @@ -128,13 +128,13 @@ class FaviconHandler { virtual void UpdateFaviconMappingAndFetch( const GURL& page_url, const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, const FaviconService::FaviconResultsCallback& callback, CancelableTaskTracker* tracker); virtual void GetFavicon( const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, const FaviconService::FaviconResultsCallback& callback, CancelableTaskTracker* tracker); @@ -144,11 +144,10 @@ class FaviconHandler { const FaviconService::FaviconResultsCallback& callback, CancelableTaskTracker* tracker); - virtual void SetHistoryFavicons( - const GURL& page_url, - const GURL& icon_url, - history::IconType icon_type, - const gfx::Image& image); + virtual void SetHistoryFavicons(const GURL& page_url, + const GURL& icon_url, + chrome::IconType icon_type, + const gfx::Image& image); virtual FaviconService* GetFaviconService(); @@ -164,11 +163,11 @@ class FaviconHandler { DownloadRequest(const GURL& url, const GURL& image_url, - history::IconType icon_type); + chrome::IconType icon_type); GURL url; GURL image_url; - history::IconType icon_type; + chrome::IconType icon_type; }; struct FaviconCandidate { @@ -179,54 +178,54 @@ class FaviconHandler { const GURL& image_url, const gfx::Image& image, float score, - history::IconType icon_type); + chrome::IconType icon_type); GURL url; GURL image_url; gfx::Image image; float score; - history::IconType icon_type; + chrome::IconType icon_type; }; // See description above class for details. void OnFaviconDataForInitialURL( - const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results); + const std::vector<chrome::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 DownloadFaviconOrAskHistory(const GURL& page_url, const GURL& icon_url, - history::IconType icon_type); + chrome::IconType icon_type); // See description above class for details. void OnFaviconData( - const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results); + const std::vector<chrome::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, int image_size, - history::IconType icon_type); + chrome::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, - history::IconType icon_type); + chrome::IconType icon_type); // Sets the image data for the favicon. void SetFavicon(const GURL& url, const GURL& icon_url, const gfx::Image& image, - history::IconType icon_type); + chrome::IconType icon_type); // Sets the favicon's data on the NavigationEntry. // If the WebContents has a delegate, it is invalidated (INVALIDATE_TYPE_TAB). void UpdateFavicon(content::NavigationEntry* entry, - const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results); + const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results); void UpdateFavicon(content::NavigationEntry* entry, const GURL& icon_url, const gfx::Image& image); @@ -241,7 +240,7 @@ class FaviconHandler { // Returns the preferred_icon_size according icon_types_, 0 means no // preference. int preferred_icon_size() { - return icon_types_ == history::FAVICON ? gfx::kFaviconSize : 0; + return icon_types_ == chrome::FAVICON ? gfx::kFaviconSize : 0; } // Used for FaviconService requests. @@ -270,7 +269,7 @@ class FaviconHandler { std::deque<content::FaviconURL> image_urls_; // The FaviconBitmapResults from history. - std::vector<history::FaviconBitmapResult> history_results_; + std::vector<chrome::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 ff4db52..191f502 100644 --- a/chrome/browser/favicon/favicon_handler_unittest.cc +++ b/chrome/browser/favicon/favicon_handler_unittest.cc @@ -48,12 +48,12 @@ void FillBitmap(int w, int h, std::vector<unsigned char>* output) { void SetFaviconBitmapResult( const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, bool expired, - std::vector<history::FaviconBitmapResult>* favicon_bitmap_results) { + std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results) { scoped_refptr<base::RefCountedBytes> data(new base::RefCountedBytes()); FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); - history::FaviconBitmapResult bitmap_result; + chrome::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. @@ -66,8 +66,8 @@ void SetFaviconBitmapResult( void SetFaviconBitmapResult( const GURL& icon_url, - std::vector<history::FaviconBitmapResult>* favicon_bitmap_results) { - SetFaviconBitmapResult(icon_url, history::FAVICON, false /* expired */, + std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results) { + SetFaviconBitmapResult(icon_url, chrome::FAVICON, false /* expired */, favicon_bitmap_results); } @@ -151,7 +151,7 @@ class HistoryRequestHandler { const GURL icon_url_; const int icon_type_; const std::vector<unsigned char> bitmap_data_; - std::vector<history::FaviconBitmapResult> history_results_; + std::vector<chrome::FaviconBitmapResult> history_results_; FaviconService::FaviconResultsCallback callback_; private: @@ -245,7 +245,7 @@ class TestFaviconHandler : public FaviconHandler { virtual void UpdateFaviconMappingAndFetch( const GURL& page_url, const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, const FaviconService::FaviconResultsCallback& callback, CancelableTaskTracker* tracker) OVERRIDE { history_handler_.reset(new HistoryRequestHandler(page_url, icon_url, @@ -254,7 +254,7 @@ class TestFaviconHandler : public FaviconHandler { virtual void GetFavicon( const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, const FaviconService::FaviconResultsCallback& callback, CancelableTaskTracker* tracker) OVERRIDE { history_handler_.reset(new HistoryRequestHandler(GURL(), icon_url, @@ -278,7 +278,7 @@ class TestFaviconHandler : public FaviconHandler { virtual void SetHistoryFavicons(const GURL& page_url, const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, const gfx::Image& image) OVERRIDE { scoped_refptr<base::RefCountedMemory> bytes = image.As1xPNGBytes(); std::vector<unsigned char> bitmap_data(bytes->front(), @@ -381,7 +381,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(history::FAVICON, history_handler->icon_type_); + EXPECT_EQ(chrome::FAVICON, history_handler->icon_type_); SetFaviconBitmapResult(icon_url, &history_handler->history_results_); @@ -422,10 +422,10 @@ 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(history::FAVICON, history_handler->icon_type_); + EXPECT_EQ(chrome::FAVICON, history_handler->icon_type_); // Set icon data expired - SetFaviconBitmapResult(icon_url, history::FAVICON, true /* expired */, + SetFaviconBitmapResult(icon_url, chrome::FAVICON, true /* expired */, &history_handler->history_results_); // Send history response. history_handler->InvokeCallback(); @@ -489,7 +489,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(history::FAVICON, history_handler->icon_type_); + EXPECT_EQ(chrome::FAVICON, history_handler->icon_type_); // Set valid icon data. SetFaviconBitmapResult(icon_url, &history_handler->history_results_); @@ -570,15 +570,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(history::FAVICON, history_handler->icon_type_); + EXPECT_EQ(chrome::FAVICON, history_handler->icon_type_); // Set non empty but invalid data. - history::FaviconBitmapResult bitmap_result; + chrome::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 = history::FAVICON; + bitmap_result.icon_type = chrome::FAVICON; bitmap_result.icon_url = icon_url; history_handler->history_results_.clear(); history_handler->history_results_.push_back(bitmap_result); @@ -642,7 +642,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(history::FAVICON, history_handler->icon_type_); + EXPECT_EQ(chrome::FAVICON, history_handler->icon_type_); SetFaviconBitmapResult(icon_url, &history_handler->history_results_); @@ -704,7 +704,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(history::TOUCH_PRECOMPOSED_ICON | history::TOUCH_ICON, + EXPECT_EQ(chrome::TOUCH_PRECOMPOSED_ICON | chrome::TOUCH_ICON, history_handler->icon_type_); // Icon not found. @@ -776,7 +776,7 @@ TEST_F(FaviconHandlerTest, Download2ndFaviconURLCandidate) { download_handler->Reset(); // Simulates getting a expired icon from history. - SetFaviconBitmapResult(new_icon_url, history::TOUCH_ICON, + SetFaviconBitmapResult(new_icon_url, chrome::TOUCH_ICON, true /* expired */, &history_handler->history_results_); history_handler->InvokeCallback(); @@ -816,7 +816,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(history::TOUCH_PRECOMPOSED_ICON | history::TOUCH_ICON, + EXPECT_EQ(chrome::TOUCH_PRECOMPOSED_ICON | chrome::TOUCH_ICON, history_handler->icon_type_); // Icon not found. @@ -899,8 +899,8 @@ TEST_F(FaviconHandlerTest, UpdateDuringDownloading) { // Simulates getting the icon from history. scoped_ptr<HistoryRequestHandler> handler; handler.reset(new HistoryRequestHandler(page_url, latest_icon_url, - history::TOUCH_ICON, callback)); - SetFaviconBitmapResult(latest_icon_url, history::TOUCH_ICON, + chrome::TOUCH_ICON, callback)); + SetFaviconBitmapResult(latest_icon_url, chrome::TOUCH_ICON, false /* expired */, &handler->history_results_); handler->InvokeCallback(); diff --git a/chrome/browser/favicon/favicon_service.cc b/chrome/browser/favicon/favicon_service.cc index 1c9b8ff..65facfe 100644 --- a/chrome/browser/favicon/favicon_service.cc +++ b/chrome/browser/favicon/favicon_service.cc @@ -6,6 +6,7 @@ #include "base/hash.h" #include "base/message_loop/message_loop_proxy.h" +#include "chrome/browser/favicon/favicon_types.h" #include "chrome/browser/favicon/favicon_util.h" #include "chrome/browser/favicon/imported_favicon_usage.h" #include "chrome/browser/history/history_backend.h" @@ -27,7 +28,7 @@ namespace { void CancelOrRunFaviconResultsCallback( const CancelableTaskTracker::IsCanceledCallback& is_canceled, const FaviconService::FaviconResultsCallback& callback, - const std::vector<history::FaviconBitmapResult>& results) { + const std::vector<chrome::FaviconBitmapResult>& results) { if (is_canceled.Run()) return; callback.Run(results); @@ -41,7 +42,7 @@ CancelableTaskTracker::TaskId RunWithEmptyResultAsync( return tracker->PostTask( base::MessageLoopProxy::current(), FROM_HERE, - Bind(callback, std::vector<history::FaviconBitmapResult>())); + Bind(callback, std::vector<chrome::FaviconBitmapResult>())); } } // namespace @@ -53,13 +54,13 @@ FaviconService::FaviconService(HistoryService* history_service) // static void FaviconService::FaviconResultsCallbackRunner( const FaviconResultsCallback& callback, - const std::vector<history::FaviconBitmapResult>* results) { + const std::vector<chrome::FaviconBitmapResult>* results) { callback.Run(*results); } CancelableTaskTracker::TaskId FaviconService::GetFaviconImage( const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, int desired_size_in_dip, const FaviconImageCallback& callback, CancelableTaskTracker* tracker) { @@ -79,7 +80,7 @@ CancelableTaskTracker::TaskId FaviconService::GetFaviconImage( CancelableTaskTracker::TaskId FaviconService::GetRawFavicon( const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, const FaviconRawCallback& callback, @@ -105,7 +106,7 @@ CancelableTaskTracker::TaskId FaviconService::GetRawFavicon( CancelableTaskTracker::TaskId FaviconService::GetFavicon( const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, int desired_size_in_dip, const FaviconResultsCallback& callback, CancelableTaskTracker* tracker) { @@ -179,7 +180,7 @@ CancelableTaskTracker::TaskId FaviconService::GetFaviconForURL( } CancelableTaskTracker::TaskId FaviconService::GetLargestRawFaviconForID( - history::FaviconID favicon_id, + chrome::FaviconID favicon_id, const FaviconRawCallback& callback, CancelableTaskTracker* tracker) { // Use 0 as |desired_size_in_dip| to get the largest bitmap for |favicon_id| @@ -220,7 +221,7 @@ void FaviconService::SetImportedFavicons( void FaviconService::MergeFavicon( const GURL& page_url, const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, scoped_refptr<base::RefCountedMemory> bitmap_data, const gfx::Size& pixel_size) { if (history_service_) { @@ -229,18 +230,17 @@ void FaviconService::MergeFavicon( } } -void FaviconService::SetFavicons( - const GURL& page_url, - const GURL& icon_url, - history::IconType icon_type, - const gfx::Image& image) { +void FaviconService::SetFavicons(const GURL& page_url, + const GURL& icon_url, + chrome::IconType icon_type, + const gfx::Image& image) { if (!history_service_) return; gfx::ImageSkia image_skia = image.AsImageSkia(); image_skia.EnsureRepsForSupportedScaleFactors(); const std::vector<gfx::ImageSkiaRep>& image_reps = image_skia.image_reps(); - std::vector<history::FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; for (size_t i = 0; i < image_reps.size(); ++i) { scoped_refptr<base::RefCountedBytes> bitmap_data( new base::RefCountedBytes()); @@ -249,7 +249,7 @@ void FaviconService::SetFavicons( &bitmap_data->data())) { gfx::Size pixel_size(image_reps[i].pixel_width(), image_reps[i].pixel_height()); - history::FaviconBitmapData bitmap_data_element; + chrome::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; @@ -308,8 +308,8 @@ CancelableTaskTracker::TaskId FaviconService::GetFaviconForURLImpl( void FaviconService::RunFaviconImageCallbackWithBitmapResults( const FaviconImageCallback& callback, int desired_size_in_dip, - const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results) { - history::FaviconImageResult image_result; + const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results) { + chrome::FaviconImageResult image_result; image_result.image = FaviconUtil::SelectFaviconFramesFromPNGs( favicon_bitmap_results, FaviconUtil::GetFaviconScaleFactors(), @@ -323,14 +323,14 @@ void FaviconService::RunFaviconRawCallbackWithBitmapResults( const FaviconRawCallback& callback, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, - const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results) { + const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results) { if (favicon_bitmap_results.empty() || !favicon_bitmap_results[0].is_valid()) { - callback.Run(history::FaviconBitmapResult()); + callback.Run(chrome::FaviconBitmapResult()); return; } DCHECK_EQ(1u, favicon_bitmap_results.size()); - history::FaviconBitmapResult bitmap_result = favicon_bitmap_results[0]; + chrome::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 @@ -361,7 +361,7 @@ void FaviconService::RunFaviconRawCallbackWithBitmapResults( std::vector<unsigned char> resized_bitmap_data; if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, &resized_bitmap_data)) { - callback.Run(history::FaviconBitmapResult()); + callback.Run(chrome::FaviconBitmapResult()); return; } diff --git a/chrome/browser/favicon/favicon_service.h b/chrome/browser/favicon/favicon_service.h index bc49082..c95461a 100644 --- a/chrome/browser/favicon/favicon_service.h +++ b/chrome/browser/favicon/favicon_service.h @@ -11,7 +11,7 @@ #include "base/hash_tables.h" #include "base/memory/ref_counted.h" #include "chrome/browser/common/cancelable_request.h" -#include "chrome/browser/history/history_types.h" +#include "chrome/browser/favicon/favicon_types.h" #include "chrome/browser/profiles/profile_keyed_service.h" #include "chrome/common/cancelable_task_tracker.h" #include "chrome/common/ref_counted_util.h" @@ -22,6 +22,10 @@ class HistoryService; struct ImportedFaviconUsage; class Profile; +namespace chrome { +struct FaviconImageResult; +} + // The favicon service provides methods to access favicons. It calls the history // backend behind the scenes. // @@ -60,15 +64,15 @@ class FaviconService : public CancelableRequestProvider, // |image| originate from. // TODO(pkotwicz): Enable constructing |image| from bitmaps from several // icon URLs. - typedef base::Callback<void(const history::FaviconImageResult&)> + typedef base::Callback<void(const chrome::FaviconImageResult&)> FaviconImageCallback; // Callback for GetRawFavicon() and GetRawFaviconForURL(). // FaviconBitmapResult::bitmap_data is the bitmap in the thumbnail database // for the passed in URL and icon types whose pixel size best matches the // passed in |desired_size_in_dip| and |desired_scale_factor|. Returns an - // invalid history::FaviconBitmapResult if there are no matches. - typedef base::Callback<void(const history::FaviconBitmapResult&)> + // invalid chrome::FaviconBitmapResult if there are no matches. + typedef base::Callback<void(const chrome::FaviconBitmapResult&)> FaviconRawCallback; // Callback for GetFavicon() and GetFaviconForURL(). @@ -79,14 +83,14 @@ class FaviconService : public CancelableRequestProvider, // 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<history::FaviconBitmapResult>&)> + typedef base::Callback<void(const std::vector<chrome::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<history::FaviconBitmapResult>* results); + const std::vector<chrome::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 @@ -98,14 +102,14 @@ class FaviconService : public CancelableRequestProvider, // current platform (eg MacOS) are requested for GetFaviconImage(). CancelableTaskTracker::TaskId GetFaviconImage( const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, int desired_size_in_dip, const FaviconImageCallback& callback, CancelableTaskTracker* tracker); CancelableTaskTracker::TaskId GetRawFavicon( const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, const FaviconRawCallback& callback, @@ -113,7 +117,7 @@ class FaviconService : public CancelableRequestProvider, CancelableTaskTracker::TaskId GetFavicon( const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, int desired_size_in_dip, const FaviconResultsCallback& callback, CancelableTaskTracker* tracker); @@ -178,7 +182,7 @@ class FaviconService : public CancelableRequestProvider, // multiple favicon bitmaps for |favicon_id|, the largest favicon bitmap is // returned. CancelableTaskTracker::TaskId GetLargestRawFaviconForID( - history::FaviconID favicon_id, + chrome::FaviconID favicon_id, const FaviconRawCallback& callback, CancelableTaskTracker* tracker); @@ -205,7 +209,7 @@ class FaviconService : public CancelableRequestProvider, // known. void MergeFavicon(const GURL& page_url, const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, scoped_refptr<base::RefCountedMemory> bitmap_data, const gfx::Size& pixel_size); @@ -219,11 +223,10 @@ class FaviconService : public CancelableRequestProvider, // TODO(pkotwicz): Save unresized favicon bitmaps to the database. // TODO(pkotwicz): Support adding favicons for multiple icon URLs to the // thumbnail database. - void SetFavicons( - const GURL& page_url, - const GURL& icon_url, - history::IconType icon_type, - const gfx::Image& image); + void SetFavicons(const GURL& page_url, + const GURL& icon_url, + chrome::IconType icon_type, + const gfx::Image& image); // Avoid repeated requests to download missing favicon. void UnableToDownloadFavicon(const GURL& icon_url); @@ -245,21 +248,21 @@ class FaviconService : public CancelableRequestProvider, // Intermediate callback for GetFaviconImage() and GetFaviconImageForURL() // so that history service can deal solely with FaviconResultsCallback. - // Builds history::FaviconImageResult from |favicon_bitmap_results| and runs + // Builds chrome::FaviconImageResult from |favicon_bitmap_results| and runs // |callback|. void RunFaviconImageCallbackWithBitmapResults( const FaviconImageCallback& callback, int desired_size_in_dip, - const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results); + const std::vector<chrome::FaviconBitmapResult>& favicon_bitmap_results); // Intermediate callback for GetRawFavicon() and GetRawFaviconForURL() // so that history service can deal solely with FaviconResultsCallback. - // Resizes history::FaviconBitmapResult if necessary and runs |callback|. + // Resizes chrome::FaviconBitmapResult if necessary and runs |callback|. void RunFaviconRawCallbackWithBitmapResults( const FaviconRawCallback& callback, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, - const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results); + const std::vector<chrome::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 754c6e8..7be0450 100644 --- a/chrome/browser/favicon/favicon_tab_helper.cc +++ b/chrome/browser/favicon/favicon_tab_helper.cc @@ -126,8 +126,8 @@ void FaviconTabHelper::SaveFavicon() { favicon.image.IsEmpty()) { return; } - service->SetFavicons(entry->GetURL(), favicon.url, history::FAVICON, - favicon.image); + service->SetFavicons( + entry->GetURL(), favicon.url, chrome::FAVICON, favicon.image); } NavigationEntry* FaviconTabHelper::GetActiveEntry() { diff --git a/chrome/browser/favicon/favicon_tab_helper.h b/chrome/browser/favicon/favicon_tab_helper.h index b0f17a2..6f0f4ad 100644 --- a/chrome/browser/favicon/favicon_tab_helper.h +++ b/chrome/browser/favicon/favicon_tab_helper.h @@ -10,7 +10,6 @@ #include "base/basictypes.h" #include "base/callback.h" #include "chrome/browser/favicon/favicon_handler_delegate.h" -#include "chrome/browser/history/history_types.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_user_data.h" #include "content/public/common/favicon_url.h" diff --git a/chrome/browser/favicon/favicon_types.cc b/chrome/browser/favicon/favicon_types.cc new file mode 100644 index 0000000..ca49db8 --- /dev/null +++ b/chrome/browser/favicon/favicon_types.cc @@ -0,0 +1,23 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/favicon/favicon_types.h" + +namespace chrome { + +// FaviconImageResult --------------------------------------------------------- + +FaviconImageResult::FaviconImageResult() {} + +FaviconImageResult::~FaviconImageResult() {} + +// FaviconBitmapResult -------------------------------------------------------- + +FaviconBitmapResult::FaviconBitmapResult() + : expired(false), + icon_type(INVALID_ICON) {} + +FaviconBitmapResult::~FaviconBitmapResult() {} + +} // namespace chrome diff --git a/chrome/browser/favicon/favicon_types.h b/chrome/browser/favicon/favicon_types.h new file mode 100644 index 0000000..f48ec4b --- /dev/null +++ b/chrome/browser/favicon/favicon_types.h @@ -0,0 +1,77 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_FAVICON_FAVICON_TYPES_H_ +#define CHROME_BROWSER_FAVICON_FAVICON_TYPES_H_ + +#include "base/memory/ref_counted_memory.h" +#include "googleurl/src/gurl.h" +#include "ui/gfx/image/image.h" +#include "ui/gfx/size.h" + +namespace chrome { + +typedef int64 FaviconID; + +// Defines the icon types. They are also stored in icon_type field of favicons +// table. +// The values of the IconTypes are used to select the priority in which favicon +// data is returned in HistoryBackend and ThumbnailDatabase. Data for the +// largest IconType takes priority if data for multiple IconTypes is available. +enum IconType { + INVALID_ICON = 0x0, + FAVICON = 1 << 0, + TOUCH_ICON = 1 << 1, + TOUCH_PRECOMPOSED_ICON = 1 << 2 +}; + +// Defines a gfx::Image of size desired_size_in_dip composed of image +// representations for each of the desired scale factors. +struct FaviconImageResult { + FaviconImageResult(); + ~FaviconImageResult(); + + // The resulting image. + gfx::Image image; + + // The URL of the favicon which contains all of the image representations of + // |image|. + // TODO(pkotwicz): Return multiple |icon_urls| to allow |image| to have + // representations from several favicons once content::FaviconStatus supports + // multiple URLs. + GURL icon_url; +}; + +// Defines a favicon bitmap which best matches the desired DIP size and one of +// the desired scale factors. +struct FaviconBitmapResult { + FaviconBitmapResult(); + ~FaviconBitmapResult(); + + // Returns true if |bitmap_data| contains a valid bitmap. + bool is_valid() const { return bitmap_data.get() && bitmap_data->size(); } + + // Indicates whether |bitmap_data| is expired. + bool expired; + + // The bits of the bitmap. + scoped_refptr<base::RefCountedMemory> bitmap_data; + + // The pixel dimensions of |bitmap_data|. + gfx::Size pixel_size; + + // The URL of the containing favicon. + GURL icon_url; + + // The icon type of the containing favicon. + IconType icon_type; +}; + +// Define type with same structure as FaviconBitmapResult for passing data to +// HistoryBackend::SetFavicons(). +typedef FaviconBitmapResult FaviconBitmapData; + +} // namespace chrome + +#endif // CHROME_BROWSER_FAVICON_FAVICON_TYPES_H_ diff --git a/chrome/browser/favicon/favicon_util.cc b/chrome/browser/favicon/favicon_util.cc index 50ff94e..df96a47 100644 --- a/chrome/browser/favicon/favicon_util.cc +++ b/chrome/browser/favicon/favicon_util.cc @@ -4,7 +4,7 @@ #include "chrome/browser/favicon/favicon_util.h" -#include "chrome/browser/history/history_types.h" +#include "chrome/browser/favicon/favicon_types.h" #include "chrome/browser/history/select_favicon_frames.h" #include "content/public/browser/render_view_host.h" #include "googleurl/src/gurl.h" @@ -22,7 +22,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<history::FaviconBitmapResult>& png_data, + const std::vector<chrome::FaviconBitmapResult>& png_data, const std::vector<ui::ScaleFactor>& scale_factors, int favicon_size) { std::vector<gfx::ImagePNGRep> png_reps; @@ -106,7 +106,7 @@ std::vector<ui::ScaleFactor> FaviconUtil::GetFaviconScaleFactors() { // static gfx::Image FaviconUtil::SelectFaviconFramesFromPNGs( - const std::vector<history::FaviconBitmapResult>& png_data, + const std::vector<chrome::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 diff --git a/chrome/browser/favicon/favicon_util.h b/chrome/browser/favicon/favicon_util.h index cef2f7c..32dc6e0 100644 --- a/chrome/browser/favicon/favicon_util.h +++ b/chrome/browser/favicon/favicon_util.h @@ -11,6 +11,10 @@ class GURL; +namespace chrome { +struct FaviconBitmapResult; +} + namespace content { class RenderViewHost; } @@ -19,10 +23,6 @@ namespace gfx { class Image; } -namespace history { -struct FaviconBitmapResult; -} - // Utility class for common favicon related code. class FaviconUtil { public: @@ -37,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<history::FaviconBitmapResult>& png_data, + const std::vector<chrome::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 32a6c93..52a0d40 100644 --- a/chrome/browser/history/android/android_cache_database.cc +++ b/chrome/browser/history/android/android_cache_database.cc @@ -92,7 +92,8 @@ bool AndroidCacheDatabase::MarkURLsAsBookmarked( return true; } -bool AndroidCacheDatabase::SetFaviconID(URLID url_id, FaviconID favicon_id) { +bool AndroidCacheDatabase::SetFaviconID(URLID url_id, + chrome::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 17e81f6..ac6d1c4 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, FaviconID favicon_id); + bool SetFaviconID(URLID url_id, chrome::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 fe29a4d..36ad43b 100644 --- a/chrome/browser/history/android/android_provider_backend.cc +++ b/chrome/browser/history/android/android_provider_backend.cc @@ -807,7 +807,7 @@ bool AndroidProviderBackend::UpdateFavicon() { if (!thumbnail_db_) return true; - if (!thumbnail_db_->InitIconMappingEnumerator(FAVICON, &enumerator)) + if (!thumbnail_db_->InitIconMappingEnumerator(chrome::FAVICON, &enumerator)) return false; IconMapping icon_mapping; @@ -982,7 +982,7 @@ bool AndroidProviderBackend::SimulateUpdateURL( return false; deleted_details->rows.push_back(old_url_row); - FaviconID favicon_id = statement->statement()->ColumnInt64(4); + chrome::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 3c2e6e3..f527a8a 100644 --- a/chrome/browser/history/android/android_provider_backend_unittest.cc +++ b/chrome/browser/history/android/android_provider_backend_unittest.cc @@ -47,7 +47,7 @@ struct BookmarkCacheRow { Time create_time_; Time last_visit_time_; bool bookmark_; - FaviconID favicon_id_; + chrome::FaviconID favicon_id_; }; } // namespace @@ -248,14 +248,14 @@ TEST_F(AndroidProviderBackendTest, UpdateTables) { // Set favicon to url2. std::vector<unsigned char> data; data.push_back('1'); - history::FaviconBitmapData bitmap_data_element; + chrome::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<history::FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; favicon_bitmap_data.push_back(bitmap_data_element); - history_backend->SetFavicons(url2, FAVICON, favicon_bitmap_data); + history_backend->SetFavicons(url2, chrome::FAVICON, favicon_bitmap_data); history_backend->Closing(); } @@ -398,14 +398,14 @@ TEST_F(AndroidProviderBackendTest, QueryHistoryAndBookmarks) { // Set favicon to url2. std::vector<unsigned char> data; data.push_back('1'); - history::FaviconBitmapData bitmap_data_element; + chrome::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<history::FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; favicon_bitmap_data.push_back(bitmap_data_element); - history_backend->SetFavicons(url2, FAVICON, favicon_bitmap_data); + history_backend->SetFavicons(url2, chrome::FAVICON, favicon_bitmap_data); history_backend->Closing(); } @@ -1157,8 +1157,8 @@ TEST_F(AndroidProviderBackendTest, UpdateFavicon) { delegate_.favicon_details()->urls.find(row1.url())); std::vector<IconMapping> icon_mappings; - EXPECT_TRUE(thumbnail_db_.GetIconMappingsForPageURL(row1.url(), FAVICON, - &icon_mappings)); + EXPECT_TRUE(thumbnail_db_.GetIconMappingsForPageURL( + row1.url(), chrome::FAVICON, &icon_mappings)); EXPECT_EQ(1u, icon_mappings.size()); std::vector<FaviconBitmap> favicon_bitmaps; EXPECT_TRUE(thumbnail_db_.GetFaviconBitmaps(icon_mappings[0].icon_id, @@ -1186,8 +1186,8 @@ TEST_F(AndroidProviderBackendTest, UpdateFavicon) { ASSERT_TRUE(delegate_.favicon_details()->urls.end() != delegate_.favicon_details()->urls.find(row1.url())); - EXPECT_FALSE(thumbnail_db_.GetIconMappingsForPageURL(row1.url(), FAVICON, - NULL)); + EXPECT_FALSE(thumbnail_db_.GetIconMappingsForPageURL( + row1.url(), chrome::FAVICON, NULL)); } TEST_F(AndroidProviderBackendTest, UpdateSearchTermTable) { @@ -1812,14 +1812,14 @@ TEST_F(AndroidProviderBackendTest, QueryWithoutThumbnailDB) { // Set favicon to url2. std::vector<unsigned char> data; data.push_back('1'); - history::FaviconBitmapData bitmap_data_element; + chrome::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<history::FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; favicon_bitmap_data.push_back(bitmap_data_element); - history_backend->SetFavicons(url2, FAVICON, favicon_bitmap_data); + history_backend->SetFavicons(url2, chrome::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 9fc5b9b..0028184 100644 --- a/chrome/browser/history/android/favicon_sql_handler.cc +++ b/chrome/browser/history/android/favicon_sql_handler.cc @@ -37,9 +37,9 @@ 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. - FaviconID favicon_id = thumbnail_db_->AddFavicon( + chrome::FaviconID favicon_id = thumbnail_db_->AddFavicon( GURL(), - history::FAVICON, + chrome::FAVICON, history::GetDefaultFaviconSizes(), row.favicon(), Time::Now(), @@ -48,12 +48,13 @@ bool FaviconSQLHandler::Update(const HistoryAndBookmarkRow& row, if (!favicon_id) return false; - std::vector<FaviconID> favicon_ids; + std::vector<chrome::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, FAVICON, &icon_mappings); + thumbnail_db_->GetIconMappingsForPageURL( + i->url, chrome::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 +75,7 @@ bool FaviconSQLHandler::Update(const HistoryAndBookmarkRow& row, } bool FaviconSQLHandler::Delete(const TableIDRows& ids_set) { - std::vector<FaviconID> favicon_ids; + std::vector<chrome::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,9 +107,9 @@ bool FaviconSQLHandler::Insert(HistoryAndBookmarkRow* row) { // Is it a problem to give a empty URL? // TODO(pkotwicz): Pass in real pixel size. - FaviconID id = thumbnail_db_->AddFavicon( + chrome::FaviconID id = thumbnail_db_->AddFavicon( GURL(), - history::FAVICON, + chrome::FAVICON, history::GetDefaultFaviconSizes(), row->favicon(), Time::Now(), @@ -118,8 +119,10 @@ bool FaviconSQLHandler::Insert(HistoryAndBookmarkRow* row) { return thumbnail_db_->AddIconMapping(row->url(), id); } -bool FaviconSQLHandler::DeleteUnusedFavicon(const std::vector<FaviconID>& ids) { - for (std::vector<FaviconID>::const_iterator i = ids.begin(); i != ids.end(); +bool FaviconSQLHandler::DeleteUnusedFavicon( + const std::vector<chrome::FaviconID>& ids) { + for (std::vector<chrome::FaviconID>::const_iterator i = ids.begin(); + i != ids.end(); ++i) { if (!thumbnail_db_->HasMappingFor(*i) && !thumbnail_db_->DeleteFavicon(*i)) return false; diff --git a/chrome/browser/history/android/favicon_sql_handler.h b/chrome/browser/history/android/favicon_sql_handler.h index ec916fd..f004cb6 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<FaviconID>& ids); + bool DeleteUnusedFavicon(const std::vector<chrome::FaviconID>& ids); ThumbnailDatabase* thumbnail_db_; diff --git a/chrome/browser/history/android/sqlite_cursor.cc b/chrome/browser/history/android/sqlite_cursor.cc index f6c254b..3a933c6 100644 --- a/chrome/browser/history/android/sqlite_cursor.cc +++ b/chrome/browser/history/android/sqlite_cursor.cc @@ -171,7 +171,7 @@ SQLiteCursor::~SQLiteCursor() { base::Unretained(service_), statement_)); } -bool SQLiteCursor::GetFavicon(history::FaviconID id, +bool SQLiteCursor::GetFavicon(chrome::FaviconID id, std::vector<unsigned char>* image_data) { if (id) { BrowserThread::PostTask( @@ -200,7 +200,7 @@ bool SQLiteCursor::GetFavicon(history::FaviconID id, } void SQLiteCursor::GetFaviconForIDInUIThread( - history::FaviconID id, + chrome::FaviconID id, const FaviconService::FaviconRawCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (!tracker_.get()) @@ -210,7 +210,7 @@ void SQLiteCursor::GetFaviconForIDInUIThread( void SQLiteCursor::OnFaviconData( - const history::FaviconBitmapResult& bitmap_result) { + const chrome::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 b8cb140..ebd6213 100644 --- a/chrome/browser/history/android/sqlite_cursor.h +++ b/chrome/browser/history/android/sqlite_cursor.h @@ -142,19 +142,18 @@ class SQLiteCursor { } // Get Favicon from history backend. - bool GetFavicon(history::FaviconID id, + bool GetFavicon(chrome::FaviconID id, std::vector<unsigned char>* image_data); void GetFaviconForIDInUIThread( - history::FaviconID id, + chrome::FaviconID id, const FaviconService::FaviconRawCallback& callback); // The callback function of FaviconService::GetLargestRawFaviconForID(). - void OnFaviconData(const history::FaviconBitmapResult& bitmap_result); + void OnFaviconData(const chrome::FaviconBitmapResult& bitmap_result); // The callback function of MoveTo(). - void OnMoved(AndroidHistoryProviderService::Handle handle, - int pos); + void OnMoved(AndroidHistoryProviderService::Handle handle, int pos); // Used to cancel all request on the UI thread during shutdown. void CancelAllRequests(base::WaitableEvent* finished); @@ -187,7 +186,7 @@ class SQLiteCursor { int count_; // The favicon image. - history::FaviconBitmapResult favicon_bitmap_result_; + chrome::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 319c773..c5798a9 100644 --- a/chrome/browser/history/expire_history_backend.cc +++ b/chrome/browser/history/expire_history_backend.cc @@ -166,7 +166,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<FaviconID> affected_favicons; + std::set<chrome::FaviconID> affected_favicons; // The list of all favicon urls that were actually deleted from the thumbnail // db. @@ -371,16 +371,16 @@ void ExpireHistoryBackend::StartArchivingOldStuff( } void ExpireHistoryBackend::DeleteFaviconsIfPossible( - const std::set<FaviconID>& favicon_set, + const std::set<chrome::FaviconID>& favicon_set, std::set<GURL>* expired_favicons) { if (!thumb_db_) return; - for (std::set<FaviconID>::const_iterator i = favicon_set.begin(); + for (std::set<chrome::FaviconID>::const_iterator i = favicon_set.begin(); i != favicon_set.end(); ++i) { if (!thumb_db_->HasMappingFor(*i)) { GURL icon_url; - IconType icon_type; + chrome::IconType icon_type; FaviconSizes favicon_sizes; if (thumb_db_->GetFaviconHeader(*i, &icon_url, @@ -700,9 +700,9 @@ bool ExpireHistoryBackend::ArchiveSomeOldHistory( // Create a union of all affected favicons (we don't store favicons for // archived URLs) and delete them. - std::set<FaviconID> affected_favicons( + std::set<chrome::FaviconID> affected_favicons( archived_dependencies.affected_favicons); - for (std::set<FaviconID>::const_iterator i = + for (std::set<chrome::FaviconID>::const_iterator i = deleted_dependencies.affected_favicons.begin(); i != deleted_dependencies.affected_favicons.end(); ++i) { affected_favicons.insert(*i); diff --git a/chrome/browser/history/expire_history_backend.h b/chrome/browser/history/expire_history_backend.h index 911ecb2..a7e8cdd 100644 --- a/chrome/browser/history/expire_history_backend.h +++ b/chrome/browser/history/expire_history_backend.h @@ -204,7 +204,7 @@ 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<FaviconID>& favicon_id, + void DeleteFaviconsIfPossible(const std::set<chrome::FaviconID>& favicon_id, std::set<GURL>* expired_favicons); // Enum representing what type of action resulted in the history DB deletion. diff --git a/chrome/browser/history/expire_history_backend_unittest.cc b/chrome/browser/history/expire_history_backend_unittest.cc index f92e695..98cf02c 100644 --- a/chrome/browser/history/expire_history_backend_unittest.cc +++ b/chrome/browser/history/expire_history_backend_unittest.cc @@ -71,10 +71,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(FaviconID favicon_id); + bool HasFavicon(chrome::FaviconID favicon_id); bool HasThumbnail(URLID url_id); - FaviconID GetFavicon(const GURL& page_url, IconType icon_type); + chrome::FaviconID GetFavicon(const GURL& page_url, + chrome::IconType icon_type); // Returns the number of text matches for the given URL in the example data // added by AddExampleData. @@ -192,7 +193,7 @@ class ExpireHistoryTest : public testing::Test, // (with the one in the middle) when it picks the proper threshold time. // // Each visit has indexed data, each URL has thumbnail. The first two URLs will -// share the same favicon, while the last one will have a unique favicon. The +// share the same avicon, while the last one will have a unique favicon. The // second visit for the middle URL is typed. // // The IDs of the added URLs, and the times of the four added visits will be @@ -209,10 +210,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. - FaviconID favicon1 = thumb_db_->AddFavicon(GURL("http://favicon/url1"), - FAVICON, GetDefaultFaviconSizes()); - FaviconID favicon2 = thumb_db_->AddFavicon(GURL("http://favicon/url2"), - FAVICON, GetDefaultFaviconSizes()); + chrome::FaviconID favicon1 = thumb_db_->AddFavicon( + GURL("http://favicon/url1"), chrome::FAVICON, GetDefaultFaviconSizes()); + chrome::FaviconID favicon2 = thumb_db_->AddFavicon( + GURL("http://favicon/url2"), chrome::FAVICON, GetDefaultFaviconSizes()); // Three URLs. URLRow url_row1(GURL("http://www.google.com/1")); @@ -321,14 +322,14 @@ void ExpireHistoryTest::AddExampleSourceData(const GURL& url, URLID* id) { main_db_->AddVisit(&visit_row4, SOURCE_FIREFOX_IMPORTED); } -bool ExpireHistoryTest::HasFavicon(FaviconID favicon_id) { +bool ExpireHistoryTest::HasFavicon(chrome::FaviconID favicon_id) { if (!thumb_db_.get() || favicon_id == 0) return false; return thumb_db_->GetFaviconHeader(favicon_id, NULL, NULL, NULL); } -FaviconID ExpireHistoryTest::GetFavicon(const GURL& page_url, - IconType icon_type) { +chrome::FaviconID ExpireHistoryTest::GetFavicon(const GURL& page_url, + chrome::IconType icon_type) { std::vector<IconMapping> icon_mappings; if (thumb_db_->GetIconMappingsForPageURL(page_url, icon_type, &icon_mappings)) { @@ -408,13 +409,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"); - FaviconID icon_id = thumb_db_->AddFavicon(favicon_url, FAVICON, - GetDefaultFaviconSizes()); + chrome::FaviconID icon_id = thumb_db_->AddFavicon( + favicon_url, chrome::FAVICON, GetDefaultFaviconSizes()); EXPECT_TRUE(icon_id); EXPECT_TRUE(HasFavicon(icon_id)); // The favicon should be deletable with no users. - std::set<FaviconID> favicon_set; + std::set<chrome::FaviconID> favicon_set; std::set<GURL> expired_favicons; favicon_set.insert(icon_id); expirer_.DeleteFaviconsIfPossible(favicon_set, &expired_favicons); @@ -423,8 +424,8 @@ TEST_F(ExpireHistoryTest, DeleteFaviconsIfPossible) { EXPECT_EQ(1U, expired_favicons.count(favicon_url)); // Add back the favicon. - icon_id = thumb_db_->AddFavicon(favicon_url, TOUCH_ICON, - GetDefaultFaviconSizes()); + icon_id = thumb_db_->AddFavicon( + favicon_url, chrome::TOUCH_ICON, GetDefaultFaviconSizes()); EXPECT_TRUE(icon_id); EXPECT_TRUE(HasFavicon(icon_id)); @@ -462,7 +463,7 @@ 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)); - FaviconID favicon_id = GetFavicon(last_row.url(), FAVICON); + chrome::FaviconID favicon_id = GetFavicon(last_row.url(), chrome::FAVICON); EXPECT_TRUE(HasFavicon(favicon_id)); // TODO(sky): fix this, see comment in HasThumbnail. // EXPECT_TRUE(HasThumbnail(url_ids[2])); @@ -512,7 +513,7 @@ TEST_F(ExpireHistoryTest, DISABLED_DeleteURLAndFavicon) { // All the normal data + the favicon should be gone. EnsureURLInfoGone(last_row); - EXPECT_FALSE(GetFavicon(last_row.url(), FAVICON)); + EXPECT_FALSE(GetFavicon(last_row.url(), chrome::FAVICON)); EXPECT_FALSE(HasFavicon(favicon_id)); } @@ -526,7 +527,7 @@ 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)); - FaviconID favicon_id = GetFavicon(last_row.url(), FAVICON); + chrome::FaviconID favicon_id = GetFavicon(last_row.url(), chrome::FAVICON); EXPECT_TRUE(HasFavicon(favicon_id)); // TODO(sky): fix this, see comment in HasThumbnail. // EXPECT_TRUE(HasThumbnail(url_ids[1])); @@ -564,7 +565,7 @@ TEST_F(ExpireHistoryTest, DontDeleteStarredURL) { ASSERT_TRUE(main_db_->GetRowForURL(url, &url_row)); // And the favicon should exist. - FaviconID favicon_id = GetFavicon(url_row.url(), FAVICON); + chrome::FaviconID favicon_id = GetFavicon(url_row.url(), chrome::FAVICON); EXPECT_TRUE(HasFavicon(favicon_id)); // But there should be no fts. @@ -597,13 +598,13 @@ TEST_F(ExpireHistoryTest, DeleteURLs) { // Verify things are the way we expect with URL rows, favicons, // thumbnails. URLRow rows[3]; - FaviconID favicon_ids[3]; + chrome::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(), FAVICON); + favicon_ids[i] = GetFavicon(rows[i].url(), chrome::FAVICON); EXPECT_TRUE(HasFavicon(favicon_ids[i])); // TODO(sky): fix this, see comment in HasThumbnail. // EXPECT_TRUE(HasThumbnail(url_ids[i])); @@ -671,13 +672,13 @@ TEST_F(ExpireHistoryTest, FlushRecentURLsUnstarred) { EXPECT_EQ(0, temp_row.typed_count()); // Verify that the middle URL's favicon and thumbnail is still there. - FaviconID favicon_id = GetFavicon(url_row1.url(), FAVICON); + chrome::FaviconID favicon_id = GetFavicon(url_row1.url(), chrome::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. - FaviconID favicon_id2 = GetFavicon(url_row2.url(), FAVICON); + chrome::FaviconID favicon_id2 = GetFavicon(url_row2.url(), chrome::FAVICON); EnsureURLInfoGone(url_row2); EXPECT_FALSE(HasFavicon(favicon_id2)); } @@ -729,13 +730,13 @@ TEST_F(ExpireHistoryTest, FlushURLsForTimes) { EXPECT_EQ(0, temp_row.typed_count()); // Verify that the middle URL's favicon and thumbnail is still there. - FaviconID favicon_id = GetFavicon(url_row1.url(), FAVICON); + chrome::FaviconID favicon_id = GetFavicon(url_row1.url(), chrome::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. - FaviconID favicon_id2 = GetFavicon(url_row2.url(), FAVICON); + chrome::FaviconID favicon_id2 = GetFavicon(url_row2.url(), chrome::FAVICON); EnsureURLInfoGone(url_row2); EXPECT_FALSE(HasFavicon(favicon_id2)); } @@ -788,7 +789,7 @@ TEST_F(ExpireHistoryTest, FlushRecentURLsUnstarredRestricted) { EXPECT_EQ(0, temp_row.typed_count()); // Verify that the middle URL's favicon and thumbnail is still there. - FaviconID favicon_id = GetFavicon(url_row1.url(), FAVICON); + chrome::FaviconID favicon_id = GetFavicon(url_row1.url(), chrome::FAVICON); EXPECT_TRUE(HasFavicon(favicon_id)); // TODO(sky): fix this, see comment in HasThumbnail. // EXPECT_TRUE(HasThumbnail(url_row1.id())); @@ -837,11 +838,11 @@ 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. - FaviconID favicon_id = GetFavicon(url_row1.url(), FAVICON); + chrome::FaviconID favicon_id = GetFavicon(url_row1.url(), chrome::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(), FAVICON); + favicon_id = GetFavicon(url_row1.url(), chrome::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 7924cad..17f996c 100644 --- a/chrome/browser/history/history_backend.cc +++ b/chrome/browser/history/history_backend.cc @@ -1906,7 +1906,7 @@ void HistoryBackend::GetFavicons( int icon_types, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<FaviconBitmapResult>* bitmap_results) { + std::vector<chrome::FaviconBitmapResult>* bitmap_results) { UpdateFaviconMappingsAndFetchImpl(NULL, icon_urls, icon_types, desired_size_in_dip, desired_scale_factors, bitmap_results); @@ -1917,18 +1917,18 @@ void HistoryBackend::GetFaviconsForURL( int icon_types, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<FaviconBitmapResult>* bitmap_results) { + std::vector<chrome::FaviconBitmapResult>* bitmap_results) { DCHECK(bitmap_results); GetFaviconsFromDB(page_url, icon_types, desired_size_in_dip, desired_scale_factors, bitmap_results); } void HistoryBackend::GetFaviconForID( - FaviconID favicon_id, + chrome::FaviconID favicon_id, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, - std::vector<FaviconBitmapResult>* bitmap_results) { - std::vector<FaviconID> favicon_ids; + std::vector<chrome::FaviconBitmapResult>* bitmap_results) { + std::vector<chrome::FaviconID> favicon_ids; favicon_ids.push_back(favicon_id); std::vector<ui::ScaleFactor> desired_scale_factors; desired_scale_factors.push_back(desired_scale_factor); @@ -1946,7 +1946,7 @@ void HistoryBackend::UpdateFaviconMappingsAndFetch( int icon_types, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<FaviconBitmapResult>* bitmap_results) { + std::vector<chrome::FaviconBitmapResult>* bitmap_results) { UpdateFaviconMappingsAndFetchImpl(&page_url, icon_urls, icon_types, desired_size_in_dip, desired_scale_factors, bitmap_results); @@ -1955,14 +1955,14 @@ void HistoryBackend::UpdateFaviconMappingsAndFetch( void HistoryBackend::MergeFavicon( const GURL& page_url, const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, scoped_refptr<base::RefCountedMemory> bitmap_data, const gfx::Size& pixel_size) { if (!thumbnail_db_ || !db_) return; - FaviconID favicon_id = thumbnail_db_->GetFaviconIDForFaviconURL(icon_url, - icon_type, NULL); + chrome::FaviconID favicon_id = + thumbnail_db_->GetFaviconIDForFaviconURL(icon_url, icon_type, NULL); if (!favicon_id) { // There is no favicon at |icon_url|, create it. @@ -2083,7 +2083,7 @@ void HistoryBackend::MergeFavicon( // |page_url|. bool mapping_changed = false; if (icon_mappings.size() != 1 || icon_mappings[0].icon_url != icon_url) { - std::vector<FaviconID> favicon_ids; + std::vector<chrome::FaviconID> favicon_ids; favicon_ids.push_back(favicon_id); SetFaviconMappingsForPageAndRedirects(page_url, icon_type, favicon_ids); mapping_changed = true; @@ -2096,15 +2096,15 @@ void HistoryBackend::MergeFavicon( void HistoryBackend::SetFavicons( const GURL& page_url, - IconType icon_type, - const std::vector<FaviconBitmapData>& favicon_bitmap_data) { + chrome::IconType icon_type, + const std::vector<chrome::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<FaviconBitmapData> > + typedef std::map<GURL, std::vector<chrome::FaviconBitmapData> > BitmapDataByIconURL; BitmapDataByIconURL grouped_by_icon_url; for (size_t i = 0; i < favicon_bitmap_data.size(); ++i) { @@ -2116,11 +2116,11 @@ void HistoryBackend::SetFavicons( // or icon mappings. bool data_modified = false; - std::vector<FaviconID> icon_ids; + std::vector<chrome::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; - FaviconID icon_id = + chrome::FaviconID icon_id = thumbnail_db_->GetFaviconIDForFaviconURL(icon_url, icon_type, NULL); if (!icon_id) { @@ -2188,14 +2188,14 @@ void HistoryBackend::SetImportedFavicons( std::set<GURL> favicons_changed; for (size_t i = 0; i < favicon_usage.size(); i++) { - FaviconID favicon_id = thumbnail_db_->GetFaviconIDForFaviconURL( - favicon_usage[i].favicon_url, history::FAVICON, NULL); + chrome::FaviconID favicon_id = thumbnail_db_->GetFaviconIDForFaviconURL( + favicon_usage[i].favicon_url, chrome::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, - history::FAVICON, + chrome::FAVICON, GetDefaultFaviconSizes(), new base::RefCountedBytes(favicon_usage[i].png_data), now, @@ -2224,7 +2224,8 @@ void HistoryBackend::SetImportedFavicons( favicons_changed.insert(*url); } } else { - if (!thumbnail_db_->GetIconMappingsForPageURL(*url, FAVICON, NULL)) { + if (!thumbnail_db_->GetIconMappingsForPageURL( + *url, chrome::FAVICON, NULL)) { // URL is present in history, update the favicon *only* if it is not // set already. thumbnail_db_->AddIconMapping(*url, favicon_id); @@ -2249,31 +2250,32 @@ void HistoryBackend::UpdateFaviconMappingsAndFetchImpl( int icon_types, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<FaviconBitmapResult>* bitmap_results) { + std::vector<chrome::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 == FAVICON || - icon_types == TOUCH_ICON || - icon_types == TOUCH_PRECOMPOSED_ICON || - icon_types == (TOUCH_ICON | TOUCH_PRECOMPOSED_ICON)); + icon_types == chrome::FAVICON || + icon_types == chrome::TOUCH_ICON || + icon_types == chrome::TOUCH_PRECOMPOSED_ICON || + icon_types == (chrome::TOUCH_ICON | chrome::TOUCH_PRECOMPOSED_ICON)); bitmap_results->clear(); if (!thumbnail_db_) { return; } - std::vector<FaviconID> favicon_ids; + std::vector<chrome::FaviconID> favicon_ids; // The icon type for which the mappings will the updated and data will be // returned. - IconType selected_icon_type = INVALID_ICON; + chrome::IconType selected_icon_type = chrome::INVALID_ICON; for (size_t i = 0; i < icon_urls.size(); ++i) { const GURL& icon_url = icon_urls[i]; - IconType icon_type_out; - const FaviconID favicon_id = thumbnail_db_->GetFaviconIDForFaviconURL( - icon_url, icon_types, &icon_type_out); + chrome::IconType icon_type_out; + const chrome::FaviconID favicon_id = + thumbnail_db_->GetFaviconIDForFaviconURL( + icon_url, icon_types, &icon_type_out); if (favicon_id) { // Return and update icon mappings only for the largest icon type. As @@ -2303,8 +2305,8 @@ void HistoryBackend::UpdateFaviconMappingsAndFetchImpl( } void HistoryBackend::SetFaviconBitmaps( - FaviconID icon_id, - const std::vector<FaviconBitmapData>& favicon_bitmap_data, + chrome::FaviconID icon_id, + const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data, bool* favicon_bitmaps_changed) { if (favicon_bitmaps_changed) *favicon_bitmaps_changed = false; @@ -2312,12 +2314,12 @@ void HistoryBackend::SetFaviconBitmaps( std::vector<FaviconBitmapIDSize> bitmap_id_sizes; thumbnail_db_->GetFaviconBitmapIDSizes(icon_id, &bitmap_id_sizes); - std::vector<FaviconBitmapData> to_add = favicon_bitmap_data; + std::vector<chrome::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<FaviconBitmapData>::iterator match_it = to_add.end(); - for (std::vector<FaviconBitmapData>::iterator it = to_add.begin(); + 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) { if (it->pixel_size == pixel_size) { match_it = it; @@ -2358,7 +2360,7 @@ void HistoryBackend::SetFaviconBitmaps( } bool HistoryBackend::ValidateSetFaviconsParams( - const std::vector<FaviconBitmapData>& favicon_bitmap_data) const { + const std::vector<chrome::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) { @@ -2402,7 +2404,7 @@ bool HistoryBackend::GetFaviconsFromDB( int icon_types, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<FaviconBitmapResult>* favicon_bitmap_results) { + std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results) { DCHECK(favicon_bitmap_results); favicon_bitmap_results->clear(); @@ -2416,7 +2418,7 @@ bool HistoryBackend::GetFaviconsFromDB( std::vector<IconMapping> icon_mappings; thumbnail_db_->GetIconMappingsForPageURL(page_url, icon_types, &icon_mappings); - std::vector<FaviconID> favicon_ids; + std::vector<chrome::FaviconID> favicon_ids; for (size_t i = 0; i < icon_mappings.size(); ++i) favicon_ids.push_back(icon_mappings[i].icon_id); @@ -2429,10 +2431,10 @@ bool HistoryBackend::GetFaviconsFromDB( } bool HistoryBackend::GetFaviconBitmapResultsForBestMatch( - const std::vector<FaviconID>& candidate_favicon_ids, + const std::vector<chrome::FaviconID>& candidate_favicon_ids, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<FaviconBitmapResult>* favicon_bitmap_results) { + std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results) { favicon_bitmap_results->clear(); if (candidate_favicon_ids.empty()) @@ -2442,7 +2444,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. - FaviconID best_favicon_id = 0; + chrome::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) { @@ -2477,7 +2479,7 @@ bool HistoryBackend::GetFaviconBitmapResultsForBestMatch( // Construct FaviconBitmapResults from |best_favicon_id| and // |best_bitmap_ids|. GURL icon_url; - IconType icon_type; + chrome::IconType icon_type; if (!thumbnail_db_->GetFaviconHeader(best_favicon_id, &icon_url, &icon_type, NULL)) { return false; @@ -2485,7 +2487,7 @@ bool HistoryBackend::GetFaviconBitmapResultsForBestMatch( for (size_t i = 0; i < best_bitmap_ids.size(); ++i) { base::Time last_updated; - FaviconBitmapResult bitmap_result; + chrome::FaviconBitmapResult bitmap_result; bitmap_result.icon_url = icon_url; bitmap_result.icon_type = icon_type; if (!thumbnail_db_->GetFaviconBitmap(best_bitmap_ids[i], @@ -2505,8 +2507,8 @@ bool HistoryBackend::GetFaviconBitmapResultsForBestMatch( bool HistoryBackend::SetFaviconMappingsForPageAndRedirects( const GURL& page_url, - IconType icon_type, - const std::vector<FaviconID>& icon_ids) { + chrome::IconType icon_type, + const std::vector<chrome::FaviconID>& icon_ids) { if (!thumbnail_db_) return false; @@ -2527,8 +2529,8 @@ bool HistoryBackend::SetFaviconMappingsForPageAndRedirects( bool HistoryBackend::SetFaviconMappingsForPage( const GURL& page_url, - IconType icon_type, - const std::vector<FaviconID>& icon_ids) { + chrome::IconType icon_type, + const std::vector<chrome::FaviconID>& icon_ids) { DCHECK_LE(icon_ids.size(), kMaxFaviconsPerPage); bool mappings_changed = false; @@ -2542,14 +2544,14 @@ bool HistoryBackend::SetFaviconMappingsForPage( // Remove any favicons which are orphaned as a result of the removal of the // icon mappings. - std::vector<FaviconID> unmapped_icon_ids = icon_ids; + std::vector<chrome::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<FaviconID>::iterator icon_id_it = std::find( + std::vector<chrome::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. @@ -2558,9 +2560,10 @@ bool HistoryBackend::SetFaviconMappingsForPage( continue; } - if ((icon_type == TOUCH_ICON && m->icon_type == TOUCH_PRECOMPOSED_ICON) || - (icon_type == TOUCH_PRECOMPOSED_ICON && m->icon_type == TOUCH_ICON) || - (icon_type == m->icon_type)) { + 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)) { thumbnail_db_->DeleteIconMapping(m->mapping_id); // Removing the icon mapping may have orphaned the associated favicon so @@ -2999,7 +3002,7 @@ bool HistoryBackend::ClearAllThumbnailHistory(URLRows* kept_urls) { return false; // This maps existing favicon IDs to the ones in the temporary table. - typedef std::map<FaviconID, FaviconID> FaviconMap; + typedef std::map<chrome::FaviconID, chrome::FaviconID> FaviconMap; FaviconMap copied_favicons; // Copy all unique favicons to the temporary table, and update all the @@ -3011,8 +3014,8 @@ bool HistoryBackend::ClearAllThumbnailHistory(URLRows* kept_urls) { for (std::vector<IconMapping>::iterator m = icon_mappings.begin(); m != icon_mappings.end(); ++m) { - FaviconID old_id = m->icon_id; - FaviconID new_id; + chrome::FaviconID old_id = m->icon_id; + chrome::FaviconID new_id; FaviconMap::const_iterator found = copied_favicons.find(old_id); if (found == copied_favicons.end()) { new_id = thumbnail_db_->CopyFaviconAndFaviconBitmapsToTemporaryTables( diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h index c6fc3bb..5a9fe9a 100644 --- a/chrome/browser/history/history_backend.h +++ b/chrome/browser/history/history_backend.h @@ -264,20 +264,20 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, int icon_types, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<FaviconBitmapResult>* bitmap_results); + std::vector<chrome::FaviconBitmapResult>* bitmap_results); void GetFaviconsForURL( const GURL& page_url, int icon_types, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<FaviconBitmapResult>* bitmap_results); + std::vector<chrome::FaviconBitmapResult>* bitmap_results); void GetFaviconForID( - FaviconID favicon_id, + chrome::FaviconID favicon_id, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, - std::vector<FaviconBitmapResult>* bitmap_results); + std::vector<chrome::FaviconBitmapResult>* bitmap_results); void UpdateFaviconMappingsAndFetch( const GURL& page_url, @@ -285,18 +285,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<FaviconBitmapResult>* bitmap_results); + std::vector<chrome::FaviconBitmapResult>* bitmap_results); void MergeFavicon(const GURL& page_url, const GURL& icon_url, - IconType icon_type, + chrome::IconType icon_type, scoped_refptr<base::RefCountedMemory> bitmap_data, const gfx::Size& pixel_size); void SetFavicons( const GURL& page_url, - IconType icon_type, - const std::vector<FaviconBitmapData>& favicon_bitmap_data); + chrome::IconType icon_type, + const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data); void SetFaviconsOutOfDateForPage(const GURL& page_url); @@ -684,7 +684,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<FaviconBitmapResult>* results); + std::vector<chrome::FaviconBitmapResult>* results); // Set the favicon bitmaps for |icon_id|. // For each entry in |favicon_bitmap_data|, if a favicon bitmap already @@ -697,8 +697,8 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, // Computing |favicon_bitmaps_changed| requires additional database queries // so should be avoided if unnecessary. void SetFaviconBitmaps( - FaviconID icon_id, - const std::vector<FaviconBitmapData>& favicon_bitmap_data, + chrome::FaviconID icon_id, + const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data, bool* favicon_bitmaps_changed); // Returns true if |favicon_bitmap_data| passed to SetFavicons() is valid. @@ -708,7 +708,7 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, // kMaxFaviconBitmapsPerIconURL favicon bitmaps for each icon URL. // 2) FaviconBitmapData::bitmap_data contains non NULL bitmap data. bool ValidateSetFaviconsParams( - const std::vector<FaviconBitmapData>& favicon_bitmap_data) const; + const std::vector<chrome::FaviconBitmapData>& favicon_bitmap_data) const; // Returns true if the bitmap data at |bitmap_id| equals |new_bitmap_data|. bool IsFaviconBitmapDataEqual( @@ -731,7 +731,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<FaviconBitmapResult>* favicon_bitmap_results); + std::vector<chrome::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 @@ -743,10 +743,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<FaviconID>& candidate_favicon_ids, + const std::vector<chrome::FaviconID>& candidate_favicon_ids, int desired_size_in_dip, const std::vector<ui::ScaleFactor>& desired_scale_factors, - std::vector<FaviconBitmapResult>* favicon_bitmap_results); + std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results); // Maps the favicon ids in |icon_ids| to |page_url| (and all redirects) // for |icon_type|. @@ -754,14 +754,15 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, // changed. bool SetFaviconMappingsForPageAndRedirects( const GURL& page_url, - IconType icon_type, - const std::vector<FaviconID>& icon_ids); + chrome::IconType icon_type, + const std::vector<chrome::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, - IconType icon_type, - const std::vector<FaviconID>& icon_ids); + bool SetFaviconMappingsForPage( + const GURL& page_url, + chrome::IconType icon_type, + const std::vector<chrome::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 d2b09d4..2c8f159 100644 --- a/chrome/browser/history/history_backend_unittest.cc +++ b/chrome/browser/history/history_backend_unittest.cc @@ -257,7 +257,8 @@ class HistoryBackendTest : public testing::Test { } // Returns the number of icon mappings of |icon_type| to |page_url|. - size_t NumIconMappingsForPageURL(const GURL& page_url, IconType icon_type) { + size_t NumIconMappingsForPageURL(const GURL& page_url, + chrome::IconType icon_type) { std::vector<IconMapping> icon_mappings; backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url, icon_type, &icon_mappings); @@ -281,7 +282,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(FaviconID icon_id, + bool GetSortedFaviconBitmaps(chrome::FaviconID icon_id, std::vector<FaviconBitmap>* favicon_bitmaps) { if (!backend_->thumbnail_db_->GetFaviconBitmaps(icon_id, favicon_bitmaps)) return false; @@ -292,7 +293,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 FaviconID icon_id, + bool GetOnlyFaviconBitmap(const chrome::FaviconID icon_id, FaviconBitmap* favicon_bitmap) { std::vector<FaviconBitmap> favicon_bitmaps; if (!backend_->thumbnail_db_->GetFaviconBitmaps(icon_id, &favicon_bitmaps)) @@ -309,7 +310,7 @@ class HistoryBackendTest : public testing::Test { void GenerateFaviconBitmapData( const GURL& icon_url1, const std::vector<gfx::Size>& icon_url1_sizes, - std::vector<FaviconBitmapData>* favicon_bitmap_data) { + std::vector<chrome::FaviconBitmapData>* favicon_bitmap_data) { GenerateFaviconBitmapData(icon_url1, icon_url1_sizes, GURL(), std::vector<gfx::Size>(), favicon_bitmap_data); } @@ -319,14 +320,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<FaviconBitmapData>* favicon_bitmap_data) { + std::vector<chrome::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); - FaviconBitmapData bitmap_data_element; + chrome::FaviconBitmapData bitmap_data_element; bitmap_data_element.bitmap_data = base::RefCountedBytes::TakeVector(&data); bitmap_data_element.pixel_size = icon_url1_sizes[i]; @@ -339,7 +340,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); - FaviconBitmapData bitmap_data_element; + chrome::FaviconBitmapData bitmap_data_element; bitmap_data_element.bitmap_data = base::RefCountedBytes::TakeVector(&data); bitmap_data_element.pixel_size = icon_url2_sizes[i]; @@ -450,10 +451,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"); - FaviconID favicon2 = backend_->thumbnail_db_->AddFavicon(favicon_url2, - FAVICON, GetSizesSmallAndLarge()); - FaviconID favicon1 = backend_->thumbnail_db_->AddFavicon(favicon_url1, - FAVICON, GetSizesSmallAndLarge()); + chrome::FaviconID favicon2 = backend_->thumbnail_db_->AddFavicon(favicon_url2, + chrome::FAVICON, GetSizesSmallAndLarge()); + chrome::FaviconID favicon1 = backend_->thumbnail_db_->AddFavicon(favicon_url1, + chrome::FAVICON, GetSizesSmallAndLarge()); std::vector<unsigned char> data; data.push_back('a'); @@ -566,8 +567,8 @@ 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. - FaviconID out_favicon1 = backend_->thumbnail_db_-> - GetFaviconIDForFaviconURL(favicon_url1, FAVICON, NULL); + chrome::FaviconID out_favicon1 = backend_->thumbnail_db_-> + GetFaviconIDForFaviconURL(favicon_url1, chrome::FAVICON, NULL); EXPECT_TRUE(out_favicon1); std::vector<FaviconBitmap> favicon_bitmaps; @@ -591,15 +592,15 @@ TEST_F(HistoryBackendTest, DeleteAll) { EXPECT_TRUE(BitmapDataEqual('b', favicon_bitmap2.bitmap_data)); EXPECT_EQ(kLargeSize, favicon_bitmap2.pixel_size); - FaviconID out_favicon2 = backend_->thumbnail_db_-> - GetFaviconIDForFaviconURL(favicon_url2, FAVICON, NULL); + chrome::FaviconID out_favicon2 = backend_->thumbnail_db_-> + GetFaviconIDForFaviconURL(favicon_url2, chrome::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(), FAVICON, &mappings)); + outrow1.url(), chrome::FAVICON, &mappings)); EXPECT_EQ(1u, mappings.size()); EXPECT_EQ(out_favicon1, mappings[0].icon_id); @@ -676,18 +677,18 @@ TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) { std::vector<unsigned char> data; data.push_back('1'); - FaviconID favicon1 = backend_->thumbnail_db_->AddFavicon( + chrome::FaviconID favicon1 = backend_->thumbnail_db_->AddFavicon( favicon_url1, - FAVICON, + chrome::FAVICON, GetDefaultFaviconSizes(), new base::RefCountedBytes(data), Time::Now(), gfx::Size()); data[0] = '2'; - FaviconID favicon2 = backend_->thumbnail_db_->AddFavicon( + chrome::FaviconID favicon2 = backend_->thumbnail_db_->AddFavicon( favicon_url2, - FAVICON, + chrome::FAVICON, GetDefaultFaviconSizes(), new base::RefCountedBytes(data), Time::Now(), @@ -730,7 +731,7 @@ TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) { // The favicon should still be valid. EXPECT_EQ(favicon2, backend_->thumbnail_db_->GetFaviconIDForFaviconURL(favicon_url2, - FAVICON, + chrome::FAVICON, NULL)); // Unstar row2. @@ -747,7 +748,7 @@ TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) { // And the favicon should be deleted. EXPECT_EQ(0, backend_->thumbnail_db_->GetFaviconIDForFaviconURL(favicon_url2, - FAVICON, + chrome::FAVICON, NULL)); // Unstar row 1. @@ -769,7 +770,7 @@ TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) { // The favicon should still be valid. EXPECT_EQ(favicon1, backend_->thumbnail_db_->GetFaviconIDForFaviconURL(favicon_url1, - FAVICON, + chrome::FAVICON, NULL)); } @@ -858,9 +859,9 @@ TEST_F(HistoryBackendTest, ImportedFaviconsTest) { GURL favicon_url1("http://www.google.com/favicon.ico"); std::vector<unsigned char> data; data.push_back('1'); - FaviconID favicon1 = backend_->thumbnail_db_->AddFavicon( + chrome::FaviconID favicon1 = backend_->thumbnail_db_->AddFavicon( favicon_url1, - FAVICON, + chrome::FAVICON, GetDefaultFaviconSizes(), base::RefCountedBytes::TakeVector(&data), Time::Now(), @@ -880,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(), FAVICON)); - EXPECT_EQ(0u, NumIconMappingsForPageURL(row2.url(), FAVICON)); + EXPECT_EQ(1u, NumIconMappingsForPageURL(row1.url(), chrome::FAVICON)); + EXPECT_EQ(0u, NumIconMappingsForPageURL(row2.url(), chrome::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 @@ -899,14 +900,14 @@ TEST_F(HistoryBackendTest, ImportedFaviconsTest) { std::vector<IconMapping> mappings; EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( - row1.url(), FAVICON, &mappings)); + row1.url(), chrome::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(), FAVICON, &mappings)); + row2.url(), chrome::FAVICON, &mappings)); EXPECT_EQ(1u, mappings.size()); EXPECT_EQ(favicon.favicon_url, mappings[0].icon_url); @@ -1330,51 +1331,55 @@ TEST_F(HistoryBackendTest, SetFaviconMappingsForPageAndRedirects) { const GURL icon_url2("http://www.google.com/icon2"); // Generate bitmap data for a page with two favicons. - std::vector<FaviconBitmapData> two_favicon_bitmap_data; + std::vector<chrome::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<FaviconBitmapData> one_favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> one_favicon_bitmap_data; GenerateFaviconBitmapData(icon_url1, GetSizesSmallAndLarge(), &one_favicon_bitmap_data); // Add two favicons - backend_->SetFavicons(url1, FAVICON, two_favicon_bitmap_data); - EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, FAVICON)); - EXPECT_EQ(2u, NumIconMappingsForPageURL(url2, FAVICON)); + backend_->SetFavicons(url1, chrome::FAVICON, two_favicon_bitmap_data); + EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, chrome::FAVICON)); + EXPECT_EQ(2u, NumIconMappingsForPageURL(url2, chrome::FAVICON)); // Add one touch_icon - backend_->SetFavicons(url1, TOUCH_ICON, one_favicon_bitmap_data); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, TOUCH_ICON)); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url2, TOUCH_ICON)); - EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, FAVICON)); + 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)); // Add one TOUCH_PRECOMPOSED_ICON - backend_->SetFavicons(url1, TOUCH_PRECOMPOSED_ICON, one_favicon_bitmap_data); + backend_->SetFavicons( + url1, chrome::TOUCH_PRECOMPOSED_ICON, one_favicon_bitmap_data); // The touch_icon was replaced. - EXPECT_EQ(0u, NumIconMappingsForPageURL(url1, TOUCH_ICON)); - EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, FAVICON)); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, TOUCH_PRECOMPOSED_ICON)); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url2, TOUCH_PRECOMPOSED_ICON)); + 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)); // Add a touch_icon. - backend_->SetFavicons(url1, TOUCH_ICON, one_favicon_bitmap_data); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, TOUCH_ICON)); - EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, FAVICON)); + 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)); // The TOUCH_PRECOMPOSED_ICON was replaced. - EXPECT_EQ(0u, NumIconMappingsForPageURL(url1, TOUCH_PRECOMPOSED_ICON)); + EXPECT_EQ(0u, + NumIconMappingsForPageURL(url1, chrome::TOUCH_PRECOMPOSED_ICON)); // Add a single favicon. - backend_->SetFavicons(url1, FAVICON, one_favicon_bitmap_data); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, TOUCH_ICON)); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, FAVICON)); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url2, 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)); // Add two favicons. - backend_->SetFavicons(url1, FAVICON, two_favicon_bitmap_data); - EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, TOUCH_ICON)); - EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, FAVICON)); + backend_->SetFavicons(url1, chrome::FAVICON, two_favicon_bitmap_data); + EXPECT_EQ(1u, NumIconMappingsForPageURL(url1, chrome::TOUCH_ICON)); + EXPECT_EQ(2u, NumIconMappingsForPageURL(url1, chrome::FAVICON)); } // Test that there is no churn in icon mappings from calling @@ -1383,23 +1388,23 @@ TEST_F(HistoryBackendTest, SetFaviconMappingsForPageDuplicates) { const GURL url("http://www.google.com/"); const GURL icon_url("http://www.google.com/icon"); - std::vector<FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesSmallAndLarge(), &favicon_bitmap_data); - backend_->SetFavicons(url, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(url, chrome::FAVICON, favicon_bitmap_data); std::vector<IconMapping> icon_mappings; EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( - url, FAVICON, &icon_mappings)); + url, chrome::FAVICON, &icon_mappings)); EXPECT_EQ(1u, icon_mappings.size()); IconMappingID mapping_id = icon_mappings[0].mapping_id; - backend_->SetFavicons(url, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(url, chrome::FAVICON, favicon_bitmap_data); icon_mappings.clear(); EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( - url, FAVICON, &icon_mappings)); + url, chrome::FAVICON, &icon_mappings)); EXPECT_EQ(1u, icon_mappings.size()); // The same row in the icon_mapping table should be used for the mapping as @@ -1414,18 +1419,18 @@ TEST_F(HistoryBackendTest, SetFaviconsDeleteBitmaps) { const GURL page_url("http://www.google.com/"); const GURL icon_url("http://www.google.com/icon"); - std::vector<FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesSmallAndLarge(), &favicon_bitmap_data); - backend_->SetFavicons(page_url, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, chrome::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(FAVICON, icon_mappings[0].icon_type); - FaviconID favicon_id = icon_mappings[0].icon_id; + EXPECT_EQ(chrome::FAVICON, icon_mappings[0].icon_type); + chrome::FaviconID favicon_id = icon_mappings[0].icon_id; std::vector<FaviconBitmap> favicon_bitmaps; EXPECT_TRUE(GetSortedFaviconBitmaps(favicon_id, &favicon_bitmaps)); @@ -1442,7 +1447,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, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); scoped_refptr<base::RefCountedMemory> bitmap_data_out; gfx::Size pixel_size_out; @@ -1462,7 +1467,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, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); EXPECT_FALSE(backend_->thumbnail_db_->GetFaviconBitmap(large_bitmap_id, NULL, NULL, NULL)); @@ -1482,20 +1487,20 @@ TEST_F(HistoryBackendTest, SetFaviconsReplaceBitmapData) { std::vector<unsigned char> data_initial; data_initial.push_back('a'); - FaviconBitmapData bitmap_data_element; + chrome::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<FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; favicon_bitmap_data.push_back(bitmap_data_element); // Add bitmap to the database. - backend_->SetFavicons(page_url, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); - FaviconID original_favicon_id = - backend_->thumbnail_db_->GetFaviconIDForFaviconURL(icon_url, FAVICON, - NULL); + chrome::FaviconID original_favicon_id = + backend_->thumbnail_db_->GetFaviconIDForFaviconURL( + icon_url, chrome::FAVICON, NULL); EXPECT_NE(0, original_favicon_id); FaviconBitmap original_favicon_bitmap; EXPECT_TRUE( @@ -1508,11 +1513,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, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); - FaviconID updated_favicon_id = - backend_->thumbnail_db_->GetFaviconIDForFaviconURL(icon_url, FAVICON, - NULL); + chrome::FaviconID updated_favicon_id = + backend_->thumbnail_db_->GetFaviconIDForFaviconURL( + icon_url, chrome::FAVICON, NULL); EXPECT_NE(0, updated_favicon_id); FaviconBitmap updated_favicon_bitmap; EXPECT_TRUE( @@ -1526,11 +1531,11 @@ 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, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); updated_favicon_id = - backend_->thumbnail_db_->GetFaviconIDForFaviconURL(icon_url, FAVICON, - NULL); + backend_->thumbnail_db_->GetFaviconIDForFaviconURL( + icon_url, chrome::FAVICON, NULL); EXPECT_NE(0, updated_favicon_id); EXPECT_TRUE( GetOnlyFaviconBitmap(updated_favicon_id, &updated_favicon_bitmap)); @@ -1555,18 +1560,18 @@ TEST_F(HistoryBackendTest, SetFaviconsSameFaviconURLForTwoPages) { GURL page_url1("http://www.google.com"); GURL page_url2("http://www.google.ca"); - std::vector<FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesSmallAndLarge(), &favicon_bitmap_data); - backend_->SetFavicons(page_url1, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url1, chrome::FAVICON, favicon_bitmap_data); std::vector<GURL> icon_urls; icon_urls.push_back(icon_url); - std::vector<FaviconBitmapResult> bitmap_results; + std::vector<chrome::FaviconBitmapResult> bitmap_results; backend_->UpdateFaviconMappingsAndFetch( - page_url2, icon_urls, FAVICON, kSmallSize.width(), + page_url2, icon_urls, chrome::FAVICON, kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results); // Check that the same FaviconID is mapped to both page URLs. @@ -1574,7 +1579,7 @@ TEST_F(HistoryBackendTest, SetFaviconsSameFaviconURLForTwoPages) { EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( page_url1, &icon_mappings)); EXPECT_EQ(1u, icon_mappings.size()); - FaviconID favicon_id = icon_mappings[0].icon_id; + chrome::FaviconID favicon_id = icon_mappings[0].icon_id; EXPECT_NE(0, favicon_id); icon_mappings.clear(); @@ -1586,7 +1591,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, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url1, chrome::FAVICON, favicon_bitmap_data); // |page_url1| should map to a new FaviconID and have valid bitmap data. icon_mappings.clear(); @@ -1625,26 +1630,27 @@ 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<FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesSmall(), &favicon_bitmap_data); - backend_->SetFavicons(page_url, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); - FaviconID icon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( - icon_url, FAVICON, NULL); + chrome::FaviconID icon_id = + backend_->thumbnail_db_->GetFaviconIDForFaviconURL( + icon_url, chrome::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<FaviconBitmapResult> bitmap_results; + std::vector<chrome::FaviconBitmapResult> bitmap_results; backend_->UpdateFaviconMappingsAndFetch( - page_url, icon_urls, FAVICON, kSmallSize.width(), + page_url, icon_urls, chrome::FAVICON, kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results); EXPECT_EQ(icon_id, backend_->thumbnail_db_->GetFaviconIDForFaviconURL( - icon_url, FAVICON, NULL)); + icon_url, chrome::FAVICON, NULL)); // No notification should have been broadcast as no icon mapping, favicon, // or favicon bitmap was updated, added or removed. @@ -1662,7 +1668,8 @@ TEST_F(HistoryBackendTest, MergeFaviconPageURLNotInDB) { scoped_refptr<base::RefCountedBytes> bitmap_data( new base::RefCountedBytes(data)); - backend_->MergeFavicon(page_url, icon_url, FAVICON, bitmap_data, kSmallSize); + backend_->MergeFavicon( + page_url, icon_url, chrome::FAVICON, bitmap_data, kSmallSize); // |page_url| should now be mapped to |icon_url| and the favicon bitmap should // not be expired. @@ -1680,7 +1687,8 @@ TEST_F(HistoryBackendTest, MergeFaviconPageURLNotInDB) { data[0] = 'b'; bitmap_data = new base::RefCountedBytes(data); - backend_->MergeFavicon(page_url, icon_url, FAVICON, bitmap_data, kSmallSize); + backend_->MergeFavicon( + page_url, icon_url, chrome::FAVICON, bitmap_data, kSmallSize); // |page_url| should still have a single favicon bitmap. The bitmap data // should be updated. @@ -1702,11 +1710,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<FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url1, GetSizesSmall(), &favicon_bitmap_data); - backend_->SetFavicons(page_url, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); // Test initial state. std::vector<IconMapping> icon_mappings; @@ -1728,7 +1736,8 @@ TEST_F(HistoryBackendTest, MergeFaviconPageURLInDB) { data.push_back('a'); scoped_refptr<base::RefCountedBytes> bitmap_data( new base::RefCountedBytes(data)); - backend_->MergeFavicon(page_url, icon_url1, FAVICON, bitmap_data, kSmallSize); + backend_->MergeFavicon( + page_url, icon_url1, chrome::FAVICON, bitmap_data, kSmallSize); // All the data should stay the same and no notifications should have been // sent. @@ -1748,7 +1757,8 @@ TEST_F(HistoryBackendTest, MergeFaviconPageURLInDB) { // 2) Merge favicon bitmap of the same size. data[0] = 'b'; bitmap_data = new base::RefCountedBytes(data); - backend_->MergeFavicon(page_url, icon_url1, FAVICON, bitmap_data, kSmallSize); + backend_->MergeFavicon( + page_url, icon_url1, chrome::FAVICON, bitmap_data, kSmallSize); // The small favicon bitmap at |icon_url1| should be overwritten. icon_mappings.clear(); @@ -1766,7 +1776,8 @@ TEST_F(HistoryBackendTest, MergeFaviconPageURLInDB) { // no favicon bitmap. data[0] = 'c'; bitmap_data = new base::RefCountedBytes(data); - backend_->MergeFavicon(page_url, icon_url1, FAVICON, bitmap_data, kTinySize); + backend_->MergeFavicon( + page_url, icon_url1, chrome::FAVICON, bitmap_data, kTinySize); // A new favicon bitmap should be created and the preexisting favicon bitmap // ('b') should be expired. @@ -1790,7 +1801,8 @@ TEST_F(HistoryBackendTest, MergeFaviconPageURLInDB) { // mapped to page URL. data[0] = 'd'; bitmap_data = new base::RefCountedBytes(data); - backend_->MergeFavicon(page_url, icon_url2, FAVICON, bitmap_data, kSmallSize); + backend_->MergeFavicon( + page_url, icon_url2, chrome::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|. @@ -1825,11 +1837,11 @@ TEST_F(HistoryBackendTest, MergeFaviconIconURLMappedToDifferentPageURL) { GURL page_url3("http://maps.google.com"); GURL icon_url("http:/www.google.com/favicon.ico"); - std::vector<FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesSmall(), &favicon_bitmap_data); - backend_->SetFavicons(page_url1, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url1, chrome::FAVICON, favicon_bitmap_data); // Test initial state. std::vector<IconMapping> icon_mappings; @@ -1850,10 +1862,12 @@ TEST_F(HistoryBackendTest, MergeFaviconIconURLMappedToDifferentPageURL) { scoped_refptr<base::RefCountedBytes> bitmap_data( new base::RefCountedBytes(data)); - backend_->MergeFavicon(page_url2, icon_url, FAVICON, bitmap_data, kSmallSize); + backend_->MergeFavicon( + page_url2, icon_url, chrome::FAVICON, bitmap_data, kSmallSize); - FaviconID favicon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( - icon_url, FAVICON, NULL); + chrome::FaviconID favicon_id = + backend_->thumbnail_db_->GetFaviconIDForFaviconURL( + icon_url, chrome::FAVICON, NULL); EXPECT_NE(0, favicon_id); EXPECT_TRUE(GetOnlyFaviconBitmap(favicon_id, &favicon_bitmap)); @@ -1864,10 +1878,11 @@ TEST_F(HistoryBackendTest, MergeFaviconIconURLMappedToDifferentPageURL) { // 2) Merging a favicon bitmap with different bitmap data for the same icon // URL should overwrite the small favicon bitmap at |icon_url|. bitmap_data->data()[0] = 'b'; - backend_->MergeFavicon(page_url3, icon_url, FAVICON, bitmap_data, kSmallSize); + backend_->MergeFavicon( + page_url3, icon_url, chrome::FAVICON, bitmap_data, kSmallSize); favicon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( - icon_url, FAVICON, NULL); + icon_url, chrome::FAVICON, NULL); EXPECT_NE(0, favicon_id); EXPECT_TRUE(GetOnlyFaviconBitmap(favicon_id, &favicon_bitmap)); @@ -1916,7 +1931,7 @@ TEST_F(HistoryBackendTest, MergeFaviconMaxFaviconBitmapsPerIconURL) { icon_url_string[replace_index] = '0' + i; GURL icon_url(icon_url_string); - backend_->MergeFavicon(page_url, icon_url, FAVICON, bitmap_data, + backend_->MergeFavicon(page_url, icon_url, chrome::FAVICON, bitmap_data, gfx::Size(pixel_size, pixel_size)); ++pixel_size; } @@ -1940,30 +1955,30 @@ 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<FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesSmallAndLarge(), &favicon_bitmap_data); // Set some preexisting favicons for |page_url|. - backend_->SetFavicons(page_url, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, chrome::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, FAVICON, bitmap_data, - kSmallSize); + backend_->MergeFavicon( + page_url, merged_icon_url, chrome::FAVICON, bitmap_data, kSmallSize); // Request favicon bitmaps for both 1x and 2x to simulate request done by // BookmarkModel::GetFavicon(). - std::vector<FaviconBitmapResult> bitmap_results; - backend_->GetFaviconsForURL(page_url, FAVICON, kSmallSize.width(), + std::vector<chrome::FaviconBitmapResult> bitmap_results; + backend_->GetFaviconsForURL(page_url, chrome::FAVICON, kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results); EXPECT_EQ(2u, bitmap_results.size()); - const FaviconBitmapResult& first_result = bitmap_results[0]; - const FaviconBitmapResult& result = + const chrome::FaviconBitmapResult& first_result = bitmap_results[0]; + const chrome::FaviconBitmapResult& result = (first_result.pixel_size == kSmallSize) ? first_result : bitmap_results[1]; EXPECT_TRUE(BitmapDataEqual('c', result.bitmap_data)); @@ -1979,25 +1994,30 @@ 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<FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_urla, GetSizesSmall(), &favicon_bitmap_data); - backend_->SetFavicons(page_url1, TOUCH_ICON, favicon_bitmap_data); + backend_->SetFavicons(page_url1, chrome::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, TOUCH_PRECOMPOSED_ICON, favicon_bitmap_data); + backend_->SetFavicons( + page_url2, chrome::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<FaviconBitmapResult> bitmap_results; + std::vector<chrome::FaviconBitmapResult> bitmap_results; backend_->UpdateFaviconMappingsAndFetch( - page_url3, icon_urls, (TOUCH_ICON | TOUCH_PRECOMPOSED_ICON), - kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results); + page_url3, + icon_urls, + (chrome::TOUCH_ICON | chrome::TOUCH_PRECOMPOSED_ICON), + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results); // |page_url1| and |page_url2| should still be mapped to the same icon URLs. std::vector<IconMapping> icon_mappings; @@ -2005,15 +2025,15 @@ TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchMultipleIconTypes) { &icon_mappings)); EXPECT_EQ(1u, icon_mappings.size()); EXPECT_EQ(icon_urla, icon_mappings[0].icon_url); - EXPECT_EQ(TOUCH_ICON, icon_mappings[0].icon_type); + EXPECT_EQ(chrome::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(TOUCH_PRECOMPOSED_ICON, icon_mappings[0].icon_type); + EXPECT_EQ(chrome::TOUCH_PRECOMPOSED_ICON, icon_mappings[0].icon_type); EXPECT_EQ(icon_urlc, icon_mappings[1].icon_url); - EXPECT_EQ(TOUCH_PRECOMPOSED_ICON, icon_mappings[1].icon_type); + EXPECT_EQ(chrome::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. @@ -2021,9 +2041,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(TOUCH_PRECOMPOSED_ICON, icon_mappings[0].icon_type); + EXPECT_EQ(chrome::TOUCH_PRECOMPOSED_ICON, icon_mappings[0].icon_type); EXPECT_EQ(icon_urlc, icon_mappings[1].icon_url); - EXPECT_EQ(TOUCH_PRECOMPOSED_ICON, icon_mappings[1].icon_type); + EXPECT_EQ(chrome::TOUCH_PRECOMPOSED_ICON, icon_mappings[1].icon_type); } // Test the results of GetFaviconsFromDB() when there are no found @@ -2031,8 +2051,8 @@ TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchMultipleIconTypes) { TEST_F(HistoryBackendTest, GetFaviconsFromDBEmpty) { const GURL page_url("http://www.google.com/"); - std::vector<FaviconBitmapResult> bitmap_results; - EXPECT_FALSE(backend_->GetFaviconsFromDB(page_url, FAVICON, + std::vector<chrome::FaviconBitmapResult> bitmap_results; + EXPECT_FALSE(backend_->GetFaviconsFromDB(page_url, chrome::FAVICON, kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results)); EXPECT_TRUE(bitmap_results.empty()); } @@ -2043,13 +2063,13 @@ TEST_F(HistoryBackendTest, GetFaviconsFromDBNoFaviconBitmaps) { const GURL page_url("http://www.google.com/"); const GURL icon_url("http://www.google.com/icon1"); - FaviconID icon_id = backend_->thumbnail_db_->AddFavicon(icon_url, FAVICON, - GetSizesSmallAndLarge()); + chrome::FaviconID icon_id = backend_->thumbnail_db_->AddFavicon( + icon_url, chrome::FAVICON, GetSizesSmallAndLarge()); EXPECT_NE(0, icon_id); EXPECT_NE(0, backend_->thumbnail_db_->AddIconMapping(page_url, icon_id)); - std::vector<FaviconBitmapResult> bitmap_results_out; - EXPECT_FALSE(backend_->GetFaviconsFromDB(page_url, FAVICON, + std::vector<chrome::FaviconBitmapResult> bitmap_results_out; + EXPECT_FALSE(backend_->GetFaviconsFromDB(page_url, chrome::FAVICON, kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); EXPECT_TRUE(bitmap_results_out.empty()); } @@ -2060,22 +2080,25 @@ TEST_F(HistoryBackendTest, GetFaviconsFromDBSelectClosestMatch) { const GURL page_url("http://www.google.com/"); const GURL icon_url("http://www.google.com/icon1"); - std::vector<FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesTinySmallAndLarge(), &favicon_bitmap_data); - backend_->SetFavicons(page_url, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); - std::vector<FaviconBitmapResult> bitmap_results_out; - EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, FAVICON, kSmallSize.width(), - GetScaleFactors1x2x(), &bitmap_results_out)); + std::vector<chrome::FaviconBitmapResult> bitmap_results_out; + EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, + chrome::FAVICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results_out)); // The bitmap data for the small and large bitmaps should be returned as their // sizes match exactly. EXPECT_EQ(2u, bitmap_results_out.size()); // No required order for results. if (bitmap_results_out[0].pixel_size == kLargeSize) { - FaviconBitmapResult tmp_result = bitmap_results_out[0]; + chrome::FaviconBitmapResult tmp_result = bitmap_results_out[0]; bitmap_results_out[0] = bitmap_results_out[1]; bitmap_results_out[1] = tmp_result; } @@ -2084,13 +2107,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(FAVICON, bitmap_results_out[0].icon_type); + EXPECT_EQ(chrome::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(FAVICON, bitmap_results_out[1].icon_type); + EXPECT_EQ(chrome::FAVICON, bitmap_results_out[1].icon_type); } // Test that GetFaviconsFromDB() returns results from the icon URL whose @@ -2101,15 +2124,18 @@ TEST_F(HistoryBackendTest, GetFaviconsFromDBSingleIconURL) { const GURL icon_url1("http://www.google.com/icon1"); const GURL icon_url2("http://www.google.com/icon2"); - std::vector<FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url1, GetSizesSmall(), icon_url2, GetSizesLarge(), &favicon_bitmap_data); - backend_->SetFavicons(page_url, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); - std::vector<FaviconBitmapResult> bitmap_results_out; - EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, FAVICON, kSmallSize.width(), - GetScaleFactors1x2x(), &bitmap_results_out)); + std::vector<chrome::FaviconBitmapResult> bitmap_results_out; + EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, + chrome::FAVICON, + kSmallSize.width(), + GetScaleFactors1x2x(), + &bitmap_results_out)); // The results should have results for the icon URL with the large bitmap as // downscaling is preferred to upscaling. @@ -2125,27 +2151,27 @@ 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<FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url1, GetSizesSmall(), &favicon_bitmap_data); - backend_->SetFavicons(page_url, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data); GenerateFaviconBitmapData(icon_url2, GetSizesSmall(), &favicon_bitmap_data); - backend_->SetFavicons(page_url, TOUCH_ICON, favicon_bitmap_data); + backend_->SetFavicons(page_url, chrome::TOUCH_ICON, favicon_bitmap_data); - std::vector<FaviconBitmapResult> bitmap_results_out; - EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, FAVICON, + std::vector<chrome::FaviconBitmapResult> bitmap_results_out; + EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, chrome::FAVICON, kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); EXPECT_EQ(1u, bitmap_results_out.size()); - EXPECT_EQ(FAVICON, bitmap_results_out[0].icon_type); + EXPECT_EQ(chrome::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, TOUCH_ICON, + EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, chrome::TOUCH_ICON, kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); EXPECT_EQ(1u, bitmap_results_out.size()); - EXPECT_EQ(TOUCH_ICON, bitmap_results_out[0].icon_type); + EXPECT_EQ(chrome::TOUCH_ICON, bitmap_results_out[0].icon_type); EXPECT_EQ(icon_url2, bitmap_results_out[0].icon_url); } @@ -2160,13 +2186,18 @@ TEST_F(HistoryBackendTest, GetFaviconsFromDBExpired) { scoped_refptr<base::RefCountedBytes> bitmap_data( base::RefCountedBytes::TakeVector(&data)); base::Time last_updated = base::Time::FromTimeT(0); - FaviconID icon_id = backend_->thumbnail_db_->AddFavicon(icon_url, FAVICON, - GetSizesSmallAndLarge(), bitmap_data, last_updated, kSmallSize); + chrome::FaviconID icon_id = + backend_->thumbnail_db_->AddFavicon(icon_url, + chrome::FAVICON, + GetSizesSmallAndLarge(), + bitmap_data, + last_updated, + kSmallSize); EXPECT_NE(0, icon_id); EXPECT_NE(0, backend_->thumbnail_db_->AddIconMapping(page_url, icon_id)); - std::vector<FaviconBitmapResult> bitmap_results_out; - EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, FAVICON, + std::vector<chrome::FaviconBitmapResult> bitmap_results_out; + EXPECT_TRUE(backend_->GetFaviconsFromDB(page_url, chrome::FAVICON, kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); EXPECT_EQ(1u, bitmap_results_out.size()); @@ -2179,10 +2210,10 @@ TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchNoDB) { // Make the thumbnail database invalid. backend_->thumbnail_db_.reset(); - std::vector<FaviconBitmapResult> bitmap_results; + std::vector<chrome::FaviconBitmapResult> bitmap_results; backend_->UpdateFaviconMappingsAndFetch( - GURL(), std::vector<GURL>(), FAVICON, kSmallSize.width(), + GURL(), std::vector<GURL>(), chrome::FAVICON, kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results); EXPECT_TRUE(bitmap_results.empty()); @@ -2195,29 +2226,29 @@ TEST_F(HistoryBackendTest, CloneFaviconIsRestrictedToSameDomain) { const GURL icon_url("http://www.google.com/icon.png"); // Add a favicon - std::vector<FaviconBitmapData> favicon_bitmap_data; + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data; GenerateFaviconBitmapData(icon_url, GetSizesSmall(), &favicon_bitmap_data); - backend_->SetFavicons(url, FAVICON, favicon_bitmap_data); + backend_->SetFavicons(url, chrome::FAVICON, favicon_bitmap_data); EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( - url, FAVICON, NULL)); + url, chrome::FAVICON, NULL)); // Validate starting state. - std::vector<FaviconBitmapResult> bitmap_results_out; - EXPECT_TRUE(backend_->GetFaviconsFromDB(url, FAVICON, + 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, FAVICON, + EXPECT_FALSE(backend_->GetFaviconsFromDB(same_domain_url, chrome::FAVICON, kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); - EXPECT_FALSE(backend_->GetFaviconsFromDB(foreign_domain_url, FAVICON, + EXPECT_FALSE(backend_->GetFaviconsFromDB(foreign_domain_url, chrome::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, FAVICON, + EXPECT_TRUE(backend_->GetFaviconsFromDB(same_domain_url, chrome::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, FAVICON, + EXPECT_FALSE(backend_->GetFaviconsFromDB(foreign_domain_url, chrome::FAVICON, kSmallSize.width(), GetScaleFactors1x2x(), &bitmap_results_out)); } diff --git a/chrome/browser/history/history_service.cc b/chrome/browser/history/history_service.cc index cd126c5..c95529e9 100644 --- a/chrome/browser/history/history_service.cc +++ b/chrome/browser/history/history_service.cc @@ -90,7 +90,7 @@ void DerefDownloadId( void RunWithFaviconResults( const FaviconService::FaviconResultsCallback& callback, - std::vector<history::FaviconBitmapResult>* bitmap_results) { + std::vector<chrome::FaviconBitmapResult>* bitmap_results) { callback.Run(*bitmap_results); } @@ -626,8 +626,8 @@ CancelableTaskTracker::TaskId HistoryService::GetFavicons( DCHECK(thread_checker_.CalledOnValidThread()); LoadBackendIfNecessary(); - std::vector<history::FaviconBitmapResult>* results = - new std::vector<history::FaviconBitmapResult>(); + std::vector<chrome::FaviconBitmapResult>* results = + new std::vector<chrome::FaviconBitmapResult>(); return tracker->PostTaskAndReply( thread_->message_loop_proxy(), FROM_HERE, @@ -647,8 +647,8 @@ CancelableTaskTracker::TaskId HistoryService::GetFaviconsForURL( DCHECK(thread_checker_.CalledOnValidThread()); LoadBackendIfNecessary(); - std::vector<history::FaviconBitmapResult>* results = - new std::vector<history::FaviconBitmapResult>(); + std::vector<chrome::FaviconBitmapResult>* results = + new std::vector<chrome::FaviconBitmapResult>(); return tracker->PostTaskAndReply( thread_->message_loop_proxy(), FROM_HERE, @@ -659,7 +659,7 @@ CancelableTaskTracker::TaskId HistoryService::GetFaviconsForURL( } CancelableTaskTracker::TaskId HistoryService::GetFaviconForID( - history::FaviconID favicon_id, + chrome::FaviconID favicon_id, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, const FaviconService::FaviconResultsCallback& callback, @@ -667,8 +667,8 @@ CancelableTaskTracker::TaskId HistoryService::GetFaviconForID( DCHECK(thread_checker_.CalledOnValidThread()); LoadBackendIfNecessary(); - std::vector<history::FaviconBitmapResult>* results = - new std::vector<history::FaviconBitmapResult>(); + std::vector<chrome::FaviconBitmapResult>* results = + new std::vector<chrome::FaviconBitmapResult>(); return tracker->PostTaskAndReply( thread_->message_loop_proxy(), FROM_HERE, @@ -689,8 +689,8 @@ CancelableTaskTracker::TaskId HistoryService::UpdateFaviconMappingsAndFetch( DCHECK(thread_checker_.CalledOnValidThread()); LoadBackendIfNecessary(); - std::vector<history::FaviconBitmapResult>* results = - new std::vector<history::FaviconBitmapResult>(); + std::vector<chrome::FaviconBitmapResult>* results = + new std::vector<chrome::FaviconBitmapResult>(); return tracker->PostTaskAndReply( thread_->message_loop_proxy(), FROM_HERE, @@ -703,7 +703,7 @@ CancelableTaskTracker::TaskId HistoryService::UpdateFaviconMappingsAndFetch( void HistoryService::MergeFavicon( const GURL& page_url, const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, scoped_refptr<base::RefCountedMemory> bitmap_data, const gfx::Size& pixel_size) { DCHECK(thread_checker_.CalledOnValidThread()); @@ -716,8 +716,8 @@ void HistoryService::MergeFavicon( void HistoryService::SetFavicons( const GURL& page_url, - history::IconType icon_type, - const std::vector<history::FaviconBitmapData>& favicon_bitmap_data) { + chrome::IconType icon_type, + const std::vector<chrome::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 59c44f4..40264be 100644 --- a/chrome/browser/history/history_service.h +++ b/chrome/browser/history/history_service.h @@ -739,7 +739,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. CancelableTaskTracker::TaskId GetFaviconForID( - history::FaviconID favicon_id, + chrome::FaviconID favicon_id, int desired_size_in_dip, ui::ScaleFactor desired_scale_factor, const FaviconService::FaviconResultsCallback& callback, @@ -795,7 +795,7 @@ class HistoryService : public CancelableRequestProvider, // TODO(pkotwicz): Remove once no longer required by sync. void MergeFavicon(const GURL& page_url, const GURL& icon_url, - history::IconType icon_type, + chrome::IconType icon_type, scoped_refptr<base::RefCountedMemory> bitmap_data, const gfx::Size& pixel_size); @@ -812,8 +812,8 @@ class HistoryService : public CancelableRequestProvider, // criteria for |favicon_bitmap_data| to be valid. void SetFavicons( const GURL& page_url, - history::IconType icon_type, - const std::vector<history::FaviconBitmapData>& favicon_bitmap_data); + chrome::IconType icon_type, + const std::vector<chrome::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 e610e8f..09fed81 100644 --- a/chrome/browser/history/history_types.cc +++ b/chrome/browser/history/history_types.cc @@ -380,29 +380,11 @@ bool RowQualifiesAsSignificant(const URLRow& row, IconMapping::IconMapping() : mapping_id(0), icon_id(0), - icon_type(INVALID_ICON) { + icon_type(chrome::INVALID_ICON) { } IconMapping::~IconMapping() {} -// FaviconBitmapResult -------------------------------------------------------- - -FaviconBitmapResult::FaviconBitmapResult() - : expired(false), - icon_type(history::INVALID_ICON) { -} - -FaviconBitmapResult::~FaviconBitmapResult() { -} - -// FaviconImageResult --------------------------------------------------------- - -FaviconImageResult::FaviconImageResult() { -} - -FaviconImageResult::~FaviconImageResult() { -} - // FaviconSizes -------------------------------------------------------------- const FaviconSizes& GetDefaultFaviconSizes() { diff --git a/chrome/browser/history/history_types.h b/chrome/browser/history/history_types.h index 15ab142..5e13a94 100644 --- a/chrome/browser/history/history_types.h +++ b/chrome/browser/history/history_types.h @@ -17,6 +17,7 @@ #include "base/memory/scoped_vector.h" #include "base/string16.h" #include "base/time.h" +#include "chrome/browser/favicon/favicon_types.h" #include "chrome/browser/history/snippet.h" #include "chrome/browser/search_engines/template_url_id.h" #include "chrome/common/ref_counted_util.h" @@ -42,7 +43,6 @@ typedef std::map<GURL, scoped_refptr<RefCountedVector<GURL> > > RedirectMap; typedef std::vector<GURL> RedirectList; typedef int64 DownloadID; // Identifier for a download. -typedef int64 FaviconID; // For favicons. typedef int64 FaviconBitmapID; // Identifier for a bitmap in a favicon. typedef int64 SegmentID; // URL segments for the most visited view. typedef int64 SegmentDurationID; // Unique identifier for segment_duration. @@ -676,18 +676,6 @@ bool RowQualifiesAsSignificant(const URLRow& row, const base::Time& threshold); // Favicons ------------------------------------------------------------------- -// Defines the icon types. They are also stored in icon_type field of favicons -// table. -// The values of the IconTypes are used to select the priority in which favicon -// data is returned in HistoryBackend and ThumbnailDatabase. Data for the -// largest IconType takes priority if data for multiple IconTypes is available. -enum IconType { - INVALID_ICON = 0x0, - FAVICON = 1 << 0, - TOUCH_ICON = 1 << 1, - TOUCH_PRECOMPOSED_ICON = 1 << 2 -}; - // Used for the mapping between the page and icon. struct IconMapping { IconMapping(); @@ -700,59 +688,13 @@ struct IconMapping { GURL page_url; // The unique id of the icon. - FaviconID icon_id; + chrome::FaviconID icon_id; // The url of the icon. GURL icon_url; // The type of icon. - IconType icon_type; -}; - -// Defines a favicon bitmap which best matches the desired DIP size and one of -// the desired scale factors. -struct FaviconBitmapResult { - FaviconBitmapResult(); - ~FaviconBitmapResult(); - - // Returns true if |bitmap_data| contains a valid bitmap. - bool is_valid() const { return bitmap_data.get() && bitmap_data->size(); } - - // Indicates whether |bitmap_data| is expired. - bool expired; - - // The bits of the bitmap. - scoped_refptr<base::RefCountedMemory> bitmap_data; - - // The pixel dimensions of |bitmap_data|. - gfx::Size pixel_size; - - // The URL of the containing favicon. - GURL icon_url; - - // The icon type of the containing favicon. - IconType icon_type; -}; - -// Define type with same structure as FaviconBitmapResult for passing data to -// HistoryBackend::SetFavicons(). -typedef FaviconBitmapResult FaviconBitmapData; - -// Defines a gfx::Image of size desired_size_in_dip composed of image -// representations for each of the desired scale factors. -struct FaviconImageResult { - FaviconImageResult(); - ~FaviconImageResult(); - - // The resulting image. - gfx::Image image; - - // The URL of the favicon which contains all of the image representations of - // |image|. - // TODO(pkotwicz): Return multiple |icon_urls| to allow |image| to have - // representations from several favicons once content::FaviconStatus supports - // multiple URLs. - GURL icon_url; + chrome::IconType icon_type; }; // FaviconSizes represents the sizes that the thumbnail database knows a @@ -789,7 +731,7 @@ struct FaviconBitmap { FaviconBitmapID bitmap_id; // The id of the favicon to which the bitmap belongs to. - FaviconID icon_id; + chrome::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 0fccf22..5c7d4fb 100644 --- a/chrome/browser/history/thumbnail_database.cc +++ b/chrome/browser/history/thumbnail_database.cc @@ -80,7 +80,7 @@ static 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<history::IconType>(statement.ColumnInt(2)); + static_cast<chrome::IconType>(statement.ColumnInt(2)); icon_mapping->icon_url = GURL(statement.ColumnString(3)); icon_mapping->page_url = page_url; } @@ -476,7 +476,7 @@ bool ThumbnailDatabase::ThumbnailScoreForId(URLID id, } bool ThumbnailDatabase::GetFaviconBitmapIDSizes( - FaviconID icon_id, + chrome::FaviconID icon_id, std::vector<FaviconBitmapIDSize>* bitmap_id_sizes) { DCHECK(icon_id); sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, @@ -499,7 +499,7 @@ bool ThumbnailDatabase::GetFaviconBitmapIDSizes( } bool ThumbnailDatabase::GetFaviconBitmaps( - FaviconID icon_id, + chrome::FaviconID icon_id, std::vector<FaviconBitmap>* favicon_bitmaps) { DCHECK(icon_id); sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, @@ -561,7 +561,7 @@ bool ThumbnailDatabase::GetFaviconBitmap( } FaviconBitmapID ThumbnailDatabase::AddFaviconBitmap( - FaviconID icon_id, + chrome::FaviconID icon_id, const scoped_refptr<base::RefCountedMemory>& icon_data, base::Time time, const gfx::Size& pixel_size) { @@ -615,7 +615,8 @@ bool ThumbnailDatabase::SetFaviconBitmapLastUpdateTime( return statement.Run(); } -bool ThumbnailDatabase::DeleteFaviconBitmapsForFavicon(FaviconID icon_id) { +bool ThumbnailDatabase::DeleteFaviconBitmapsForFavicon( + chrome::FaviconID icon_id) { sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, "DELETE FROM favicon_bitmaps WHERE icon_id=?")); statement.BindInt64(0, icon_id); @@ -629,7 +630,7 @@ bool ThumbnailDatabase::DeleteFaviconBitmap(FaviconBitmapID bitmap_id) { return statement.Run(); } -bool ThumbnailDatabase::SetFaviconSizes(FaviconID icon_id, +bool ThumbnailDatabase::SetFaviconSizes(chrome::FaviconID icon_id, const FaviconSizes& favicon_sizes) { std::string favicon_sizes_as_string; FaviconSizesToDatabaseString(favicon_sizes, &favicon_sizes_as_string); @@ -642,7 +643,7 @@ bool ThumbnailDatabase::SetFaviconSizes(FaviconID icon_id, return statement.Run(); } -bool ThumbnailDatabase::SetFaviconOutOfDate(FaviconID icon_id) { +bool ThumbnailDatabase::SetFaviconOutOfDate(chrome::FaviconID icon_id) { sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, "UPDATE favicon_bitmaps SET last_updated=? WHERE icon_id=?")); statement.BindInt64(0, 0); @@ -651,9 +652,10 @@ bool ThumbnailDatabase::SetFaviconOutOfDate(FaviconID icon_id) { return statement.Run(); } -FaviconID ThumbnailDatabase::GetFaviconIDForFaviconURL(const GURL& icon_url, - int required_icon_type, - IconType* icon_type) { +chrome::FaviconID ThumbnailDatabase::GetFaviconIDForFaviconURL( + const GURL& icon_url, + int required_icon_type, + chrome::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")); @@ -664,15 +666,14 @@ FaviconID ThumbnailDatabase::GetFaviconIDForFaviconURL(const GURL& icon_url, return 0; // not cached if (icon_type) - *icon_type = static_cast<IconType>(statement.ColumnInt(1)); + *icon_type = static_cast<chrome::IconType>(statement.ColumnInt(1)); return statement.ColumnInt64(0); } -bool ThumbnailDatabase::GetFaviconHeader( - FaviconID icon_id, - GURL* icon_url, - IconType* icon_type, - FaviconSizes* favicon_sizes) { +bool ThumbnailDatabase::GetFaviconHeader(chrome::FaviconID icon_id, + GURL* icon_url, + chrome::IconType* icon_type, + FaviconSizes* favicon_sizes) { DCHECK(icon_id); sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, @@ -685,16 +686,17 @@ bool ThumbnailDatabase::GetFaviconHeader( if (icon_url) *icon_url = GURL(statement.ColumnString(0)); if (icon_type) - *icon_type = static_cast<history::IconType>(statement.ColumnInt(1)); + *icon_type = static_cast<chrome::IconType>(statement.ColumnInt(1)); if (favicon_sizes) DatabaseStringToFaviconSizes(statement.ColumnString(2), favicon_sizes); return true; } -FaviconID ThumbnailDatabase::AddFavicon(const GURL& icon_url, - IconType icon_type, - const FaviconSizes& favicon_sizes) { +chrome::FaviconID ThumbnailDatabase::AddFavicon( + const GURL& icon_url, + chrome::IconType icon_type, + const FaviconSizes& favicon_sizes) { std::string favicon_sizes_as_string; FaviconSizesToDatabaseString(favicon_sizes, &favicon_sizes_as_string); @@ -709,21 +711,21 @@ FaviconID ThumbnailDatabase::AddFavicon(const GURL& icon_url, return db_.GetLastInsertRowId(); } -FaviconID ThumbnailDatabase::AddFavicon( +chrome::FaviconID ThumbnailDatabase::AddFavicon( const GURL& icon_url, - IconType icon_type, + chrome::IconType icon_type, const FaviconSizes& favicon_sizes, const scoped_refptr<base::RefCountedMemory>& icon_data, base::Time time, const gfx::Size& pixel_size) { - FaviconID icon_id = AddFavicon(icon_url, icon_type, favicon_sizes); + chrome::FaviconID icon_id = AddFavicon(icon_url, icon_type, favicon_sizes); if (!icon_id || !AddFaviconBitmap(icon_id, icon_data, time, pixel_size)) return 0; return icon_id; } -bool ThumbnailDatabase::DeleteFavicon(FaviconID id) { +bool ThumbnailDatabase::DeleteFavicon(chrome::FaviconID id) { sql::Statement statement; statement.Assign(db_.GetCachedStatement(SQL_FROM_HERE, "DELETE FROM favicons WHERE id = ?")); @@ -791,12 +793,12 @@ bool ThumbnailDatabase::GetIconMappingsForPageURL( } IconMappingID ThumbnailDatabase::AddIconMapping(const GURL& page_url, - FaviconID icon_id) { + chrome::FaviconID icon_id) { return AddIconMapping(page_url, icon_id, false); } bool ThumbnailDatabase::UpdateIconMapping(IconMappingID mapping_id, - FaviconID icon_id) { + chrome::FaviconID icon_id) { sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, "UPDATE icon_mapping SET icon_id=? WHERE id=?")); statement.BindInt64(0, icon_id); @@ -821,7 +823,7 @@ bool ThumbnailDatabase::DeleteIconMapping(IconMappingID mapping_id) { return statement.Run(); } -bool ThumbnailDatabase::HasMappingFor(FaviconID id) { +bool ThumbnailDatabase::HasMappingFor(chrome::FaviconID id) { sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, "SELECT id FROM icon_mapping " "WHERE icon_id=?")); @@ -854,7 +856,7 @@ bool ThumbnailDatabase::CloneIconMappings(const GURL& old_page_url, } bool ThumbnailDatabase::InitIconMappingEnumerator( - IconType type, + chrome::IconType type, IconMappingEnumerator* enumerator) { DCHECK(!enumerator->statement_.is_valid()); enumerator->statement_.Assign(db_.GetCachedStatement( @@ -922,12 +924,14 @@ bool ThumbnailDatabase::CommitTemporaryTables() { } IconMappingID ThumbnailDatabase::AddToTemporaryIconMappingTable( - const GURL& page_url, const FaviconID icon_id) { + const GURL& page_url, + const chrome::FaviconID icon_id) { return AddIconMapping(page_url, icon_id, true); } -FaviconID ThumbnailDatabase::CopyFaviconAndFaviconBitmapsToTemporaryTables( - FaviconID source) { +chrome::FaviconID +ThumbnailDatabase::CopyFaviconAndFaviconBitmapsToTemporaryTables( + chrome::FaviconID source) { sql::Statement statement; statement.Assign(db_.GetCachedStatement(SQL_FROM_HERE, "INSERT INTO temp_favicons (url, icon_type, sizes) " @@ -937,7 +941,7 @@ FaviconID ThumbnailDatabase::CopyFaviconAndFaviconBitmapsToTemporaryTables( if (!statement.Run()) return 0; - FaviconID new_favicon_id = db_.GetLastInsertRowId(); + chrome::FaviconID new_favicon_id = db_.GetLastInsertRowId(); statement.Assign(db_.GetCachedStatement(SQL_FROM_HERE, "INSERT INTO temp_favicon_bitmaps (icon_id, last_updated, image_data, " @@ -1065,7 +1069,7 @@ bool ThumbnailDatabase::InitIconMappingIndex() { } IconMappingID ThumbnailDatabase::AddIconMapping(const GURL& page_url, - FaviconID icon_id, + chrome::FaviconID icon_id, bool is_temporary) { const char* name = is_temporary ? "temp_icon_mapping" : "icon_mapping"; const char* statement_name = diff --git a/chrome/browser/history/thumbnail_database.h b/chrome/browser/history/thumbnail_database.h index a9e8bdc..fc726d6 100644 --- a/chrome/browser/history/thumbnail_database.h +++ b/chrome/browser/history/thumbnail_database.h @@ -110,12 +110,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( - FaviconID icon_id, + chrome::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(FaviconID icon_id, + bool GetFaviconBitmaps(chrome::FaviconID icon_id, std::vector<FaviconBitmap>* favicon_bitmaps); // Gets the last updated time, bitmap data, and pixel size of the favicon @@ -134,7 +134,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( - FaviconID icon_id, + chrome::FaviconID icon_id, const scoped_refptr<base::RefCountedMemory>& icon_data, base::Time time, const gfx::Size& pixel_size); @@ -153,7 +153,7 @@ class ThumbnailDatabase { // Deletes the favicon bitmaps for the favicon with with |icon_id|. // Returns true if successful. - bool DeleteFaviconBitmapsForFavicon(FaviconID icon_id); + bool DeleteFaviconBitmapsForFavicon(chrome::FaviconID icon_id); // Deletes the favicon bitmap with |bitmap_id|. // Returns true if successful. @@ -163,11 +163,12 @@ class ThumbnailDatabase { // Updates the favicon sizes associated with a favicon to |favicon_sizes|. // See comment in history_types.h for description of |favicon_sizes|. - bool SetFaviconSizes(FaviconID icon_id, const FaviconSizes& favicon_sizes); + bool SetFaviconSizes(chrome::FaviconID icon_id, + const FaviconSizes& favicon_sizes); // 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(FaviconID icon_id); + bool SetFaviconOutOfDate(chrome::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 @@ -176,33 +177,34 @@ 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. - FaviconID GetFaviconIDForFaviconURL(const GURL& icon_url, - int required_icon_type, - IconType* icon_type); + chrome::FaviconID GetFaviconIDForFaviconURL(const GURL& icon_url, + int required_icon_type, + chrome::IconType* icon_type); // Gets the icon_url, icon_type and sizes for the specified |icon_id|. - bool GetFaviconHeader(FaviconID icon_id, + bool GetFaviconHeader(chrome::FaviconID icon_id, GURL* icon_url, - IconType* icon_type, + chrome::IconType* icon_type, FaviconSizes* favicon_sizes); // Adds favicon with |icon_url|, |icon_type| and |favicon_sizes| to the // favicon db, returning its id. - FaviconID AddFavicon(const GURL& icon_url, - IconType icon_type, - const FaviconSizes& favicon_sizes); + chrome::FaviconID AddFavicon(const GURL& icon_url, + chrome::IconType icon_type, + const FaviconSizes& favicon_sizes); // Adds a favicon with a single bitmap. This call is equivalent to calling // AddFavicon and AddFaviconBitmap. - FaviconID AddFavicon(const GURL& icon_url, - IconType icon_type, - const FaviconSizes& favicon_sizes, - const scoped_refptr<base::RefCountedMemory>& icon_data, - base::Time time, - const gfx::Size& pixel_size); + chrome::FaviconID AddFavicon( + const GURL& icon_url, + chrome::IconType icon_type, + const FaviconSizes& favicon_sizes, + 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(FaviconID id); + bool DeleteFavicon(chrome::FaviconID id); // Icon Mapping -------------------------------------------------------------- // @@ -230,12 +232,12 @@ 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, FaviconID icon_id); + IconMappingID AddIconMapping(const GURL& page_url, chrome::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, FaviconID icon_id); + bool UpdateIconMapping(IconMappingID mapping_id, chrome::FaviconID icon_id); // Deletes the icon mapping entries for the given page url. // Returns true if the deletion succeeded. @@ -246,7 +248,7 @@ class ThumbnailDatabase { bool DeleteIconMapping(IconMappingID mapping_id); // Checks whether a favicon is used by any URLs in the database. - bool HasMappingFor(FaviconID id); + bool HasMappingFor(chrome::FaviconID id); // Clones the existing mappings from |old_page_url| if |new_page_url| has no // mappings. Otherwise, will leave mappings alone. @@ -273,7 +275,7 @@ class ThumbnailDatabase { }; // Return all icon mappings of the given |icon_type|. - bool InitIconMappingEnumerator(IconType type, + bool InitIconMappingEnumerator(chrome::IconType type, IconMappingEnumerator* enumerator); // Temporary Tables --------------------------------------------------------- @@ -296,7 +298,7 @@ class ThumbnailDatabase { // The ID of the favicon will change when this copy takes place. The new ID // is returned, or 0 on failure. IconMappingID AddToTemporaryIconMappingTable(const GURL& page_url, - const FaviconID icon_id); + const chrome::FaviconID icon_id); // Copies the given favicon and associated favicon bitmaps from the "main" // favicon and favicon_bitmaps tables to the temporary ones. This is only @@ -305,7 +307,8 @@ class ThumbnailDatabase { // // The ID of the favicon will change when this copy takes place. The new ID // is returned, or 0 on failure. - FaviconID CopyFaviconAndFaviconBitmapsToTemporaryTables(FaviconID source); + chrome::FaviconID CopyFaviconAndFaviconBitmapsToTemporaryTables( + chrome::FaviconID source); // Returns true iff the thumbnails table exists. // Migrating to TopSites is dropping the thumbnails table. @@ -392,7 +395,7 @@ class ThumbnailDatabase { // added to temp_icon_mapping table if is_temporary is true. // Returns the new mapping id if the adding succeeds, otherwise 0 is returned. IconMappingID AddIconMapping(const GURL& page_url, - FaviconID icon_id, + chrome::FaviconID icon_id, bool is_temporary); // Returns True if the current database is latest. diff --git a/chrome/browser/history/thumbnail_database_unittest.cc b/chrome/browser/history/thumbnail_database_unittest.cc index ce27d25..d81ad30 100644 --- a/chrome/browser/history/thumbnail_database_unittest.cc +++ b/chrome/browser/history/thumbnail_database_unittest.cc @@ -128,8 +128,8 @@ TEST_F(ThumbnailDatabaseTest, GetFaviconAfterMigrationToTopSites) { scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); GURL url("http://google.com"); - FaviconID icon_id = db.AddFavicon(url, FAVICON, - GetFaviconSizesSmallAndLarge()); + chrome::FaviconID icon_id = + db.AddFavicon(url, chrome::FAVICON, GetFaviconSizesSmallAndLarge()); base::Time time = base::Time::Now(); FaviconBitmapID bitmap1_id = db.AddFaviconBitmap(icon_id, favicon, time, kSmallSize); @@ -139,13 +139,13 @@ TEST_F(ThumbnailDatabaseTest, GetFaviconAfterMigrationToTopSites) { EXPECT_TRUE(db.IsLatestVersion()); GURL url_out; - IconType icon_type_out; + chrome::IconType icon_type_out; FaviconSizes favicon_sizes_out; EXPECT_TRUE(db.GetFaviconHeader(icon_id, &url_out, &icon_type_out, &favicon_sizes_out)); EXPECT_EQ(url, url_out); - EXPECT_EQ(FAVICON, icon_type_out); + EXPECT_EQ(chrome::FAVICON, icon_type_out); EXPECT_EQ(GetFaviconSizesSmallAndLarge(), favicon_sizes_out); std::vector<FaviconBitmap> favicon_bitmaps_out; @@ -193,8 +193,12 @@ TEST_F(ThumbnailDatabaseTest, AddIconMapping) { GURL url("http://google.com"); base::Time time = base::Time::Now(); - FaviconID id = db.AddFavicon(url, TOUCH_ICON, GetDefaultFaviconSizes(), - favicon, time, gfx::Size()); + chrome::FaviconID id = db.AddFavicon(url, + chrome::TOUCH_ICON, + GetDefaultFaviconSizes(), + favicon, + time, + gfx::Size()); EXPECT_NE(0, id); EXPECT_NE(0, db.AddIconMapping(url, id)); @@ -211,7 +215,8 @@ TEST_F(ThumbnailDatabaseTest, UpdateIconMapping) { db.BeginTransaction(); GURL url("http://google.com"); - FaviconID id = db.AddFavicon(url, TOUCH_ICON, GetDefaultFaviconSizes()); + chrome::FaviconID id = + db.AddFavicon(url, chrome::TOUCH_ICON, GetDefaultFaviconSizes()); EXPECT_LT(0, db.AddIconMapping(url, id)); std::vector<IconMapping> icon_mapping; @@ -221,7 +226,8 @@ TEST_F(ThumbnailDatabaseTest, UpdateIconMapping) { EXPECT_EQ(id, icon_mapping.front().icon_id); GURL url1("http://www.google.com/"); - FaviconID new_id = db.AddFavicon(url1, TOUCH_ICON, GetDefaultFaviconSizes()); + chrome::FaviconID new_id = + db.AddFavicon(url1, chrome::TOUCH_ICON, GetDefaultFaviconSizes()); EXPECT_TRUE(db.UpdateIconMapping(icon_mapping.front().mapping_id, new_id)); icon_mapping.clear(); @@ -241,25 +247,27 @@ TEST_F(ThumbnailDatabaseTest, DeleteIconMappings) { scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); GURL url("http://google.com"); - FaviconID id = db.AddFavicon(url, TOUCH_ICON, GetDefaultFaviconSizes()); + chrome::FaviconID id = + db.AddFavicon(url, chrome::TOUCH_ICON, GetDefaultFaviconSizes()); base::Time time = base::Time::Now(); db.AddFaviconBitmap(id, favicon, time, gfx::Size()); EXPECT_LT(0, db.AddIconMapping(url, id)); - FaviconID id2 = db.AddFavicon(url, FAVICON, GetDefaultFaviconSizes()); + chrome::FaviconID id2 = + db.AddFavicon(url, chrome::FAVICON, GetDefaultFaviconSizes()); 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, TOUCH_ICON); - EXPECT_TRUE(db.GetIconMappingsForPageURL(url, FAVICON, NULL)); + EXPECT_EQ(icon_mapping.front().icon_type, chrome::TOUCH_ICON); + EXPECT_TRUE(db.GetIconMappingsForPageURL(url, chrome::FAVICON, NULL)); db.DeleteIconMappings(url); EXPECT_FALSE(db.GetIconMappingsForPageURL(url, NULL)); - EXPECT_FALSE(db.GetIconMappingsForPageURL(url, FAVICON, NULL)); + EXPECT_FALSE(db.GetIconMappingsForPageURL(url, chrome::FAVICON, NULL)); } TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURL) { @@ -272,14 +280,15 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURL) { GURL url("http://google.com"); - FaviconID id1 = db.AddFavicon(url, TOUCH_ICON, - GetFaviconSizesSmallAndLarge()); + chrome::FaviconID id1 = + db.AddFavicon(url, chrome::TOUCH_ICON, GetFaviconSizesSmallAndLarge()); 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)); - FaviconID id2 = db.AddFavicon(url, FAVICON, GetFaviconSizesSmallAndLarge()); + chrome::FaviconID id2 = + db.AddFavicon(url, chrome::FAVICON, GetFaviconSizesSmallAndLarge()); EXPECT_NE(id1, id2); db.AddFaviconBitmap(id2, favicon, time, kSmallSize); EXPECT_LT(0, db.AddIconMapping(url, id2)); @@ -321,14 +330,15 @@ TEST_F(ThumbnailDatabaseTest, UpgradeToVersion4) { statement.Assign(db.db_.GetCachedStatement(SQL_FROM_HERE, "INSERT INTO favicons (url, icon_type) VALUES (?, ?)")); statement.BindString(0, URLDatabase::GURLToDatabaseURL(url)); - statement.BindInt(1, TOUCH_ICON); + statement.BindInt(1, chrome::TOUCH_ICON); EXPECT_TRUE(statement.Run()); statement.Assign(db.db_.GetCachedStatement(SQL_FROM_HERE, "SELECT icon_type FROM favicons")); EXPECT_TRUE(statement.Step()); - EXPECT_EQ(TOUCH_ICON, static_cast<IconType>(statement.ColumnInt(0))); + EXPECT_EQ(chrome::TOUCH_ICON, + static_cast<chrome::IconType>(statement.ColumnInt(0))); } // Test upgrading database to version 5. @@ -400,7 +410,7 @@ TEST_F(ThumbnailDatabaseTest, UpgradeToVersion6) { statement.BindInt64(2, last_updated); statement.BindBlob(3, bitmap_data->front(), static_cast<int>(bitmap_data->size())); - statement.BindInt(4, TOUCH_ICON); + statement.BindInt(4, chrome::TOUCH_ICON); statement.BindCString(5, "Data which happened to be there"); EXPECT_TRUE(statement.Run()); @@ -411,7 +421,7 @@ TEST_F(ThumbnailDatabaseTest, UpgradeToVersion6) { EXPECT_TRUE(statement.Step()); EXPECT_EQ(favicon_id, statement.ColumnInt(0)); EXPECT_EQ(url, GURL(statement.ColumnString(1))); - EXPECT_EQ(TOUCH_ICON, statement.ColumnInt(2)); + EXPECT_EQ(chrome::TOUCH_ICON, statement.ColumnInt(2)); // Any previous data in sizes should be cleared. EXPECT_EQ(std::string(), statement.ColumnString(3)); @@ -442,20 +452,20 @@ TEST_F(ThumbnailDatabaseTest, TemporaryTables) { scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); GURL unkept_url("http://google.com/favicon2.ico"); - FaviconID unkept_id = db.AddFavicon(unkept_url, FAVICON, - GetFaviconSizesSmallAndLarge()); + chrome::FaviconID unkept_id = db.AddFavicon( + unkept_url, chrome::FAVICON, GetFaviconSizesSmallAndLarge()); db.AddFaviconBitmap(unkept_id, favicon, base::Time::Now(), kSmallSize); GURL kept_url("http://google.com/favicon.ico"); - FaviconID kept_id = db.AddFavicon(kept_url, FAVICON, - GetFaviconSizesSmallAndLarge()); + chrome::FaviconID kept_id = + db.AddFavicon(kept_url, chrome::FAVICON, GetFaviconSizesSmallAndLarge()); db.AddFaviconBitmap(kept_id, favicon, base::Time::Now(), kLargeSize); GURL page_url("http://google.com"); db.AddIconMapping(page_url, unkept_id); db.AddIconMapping(page_url, kept_id); - FaviconID new_favicon_id = + chrome::FaviconID new_favicon_id = db.CopyFaviconAndFaviconBitmapsToTemporaryTables(kept_id); EXPECT_NE(0, new_favicon_id); EXPECT_TRUE(db.AddToTemporaryIconMappingTable(page_url, new_favicon_id)); @@ -464,7 +474,8 @@ TEST_F(ThumbnailDatabaseTest, TemporaryTables) { // Only copied data should be left. std::vector<IconMapping> icon_mappings; - EXPECT_TRUE(db.GetIconMappingsForPageURL(page_url, FAVICON, &icon_mappings)); + EXPECT_TRUE( + db.GetIconMappingsForPageURL(page_url, chrome::FAVICON, &icon_mappings)); EXPECT_EQ(1u, icon_mappings.size()); EXPECT_EQ(new_favicon_id, icon_mappings[0].icon_id); EXPECT_EQ(page_url, icon_mappings[0].page_url); @@ -492,7 +503,8 @@ TEST_F(ThumbnailDatabaseTest, DeleteFavicon) { new base::RefCountedBytes(data2)); GURL url("http://google.com"); - FaviconID id = db.AddFavicon(url, FAVICON, GetFaviconSizesSmallAndLarge()); + chrome::FaviconID id = + db.AddFavicon(url, chrome::FAVICON, GetFaviconSizesSmallAndLarge()); base::Time last_updated = base::Time::Now(); db.AddFaviconBitmap(id, favicon1, last_updated, kSmallSize); db.AddFaviconBitmap(id, favicon2, last_updated, kLargeSize); @@ -516,15 +528,19 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLForReturnOrder) { GURL icon_url("http://google.com/favicon.ico"); base::Time time = base::Time::Now(); - FaviconID id = db.AddFavicon(icon_url, FAVICON, GetDefaultFaviconSizes(), - favicon, time, gfx::Size()); + chrome::FaviconID id = db.AddFavicon(icon_url, + chrome::FAVICON, + GetDefaultFaviconSizes(), + 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(FAVICON, icon_mappings.front().icon_type); + EXPECT_EQ(chrome::FAVICON, icon_mappings.front().icon_type); EXPECT_EQ(icon_url, icon_mappings.front().icon_url); // Add a touch icon @@ -532,8 +548,12 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLForReturnOrder) { scoped_refptr<base::RefCountedBytes> favicon2 = new base::RefCountedBytes(data); - FaviconID id2 = db.AddFavicon(icon_url, TOUCH_ICON, - GetDefaultFaviconSizes(), favicon2, time, gfx::Size()); + chrome::FaviconID id2 = db.AddFavicon(icon_url, + chrome::TOUCH_ICON, + GetDefaultFaviconSizes(), + favicon2, + time, + gfx::Size()); EXPECT_NE(0, db.AddIconMapping(page_url, id2)); icon_mappings.clear(); @@ -541,15 +561,19 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLForReturnOrder) { EXPECT_EQ(page_url, icon_mappings.front().page_url); EXPECT_EQ(id2, icon_mappings.front().icon_id); - EXPECT_EQ(TOUCH_ICON, icon_mappings.front().icon_type); + EXPECT_EQ(chrome::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); - FaviconID id3 = db.AddFavicon(icon_url, TOUCH_PRECOMPOSED_ICON, - GetDefaultFaviconSizes(), favicon3, time, gfx::Size()); + chrome::FaviconID id3 = db.AddFavicon(icon_url, + chrome::TOUCH_PRECOMPOSED_ICON, + GetDefaultFaviconSizes(), + favicon3, + time, + gfx::Size()); EXPECT_NE(0, db.AddIconMapping(page_url, id3)); icon_mappings.clear(); @@ -557,7 +581,7 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLForReturnOrder) { EXPECT_EQ(page_url, icon_mappings.front().page_url); EXPECT_EQ(id3, icon_mappings.front().icon_id); - EXPECT_EQ(TOUCH_PRECOMPOSED_ICON, icon_mappings.front().icon_type); + EXPECT_EQ(chrome::TOUCH_PRECOMPOSED_ICON, icon_mappings.front().icon_type); EXPECT_EQ(icon_url, icon_mappings.front().icon_url); } @@ -572,16 +596,28 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLWithIconType) { scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); base::Time time = base::Time::Now(); - FaviconID id1 = db.AddFavicon(url, FAVICON, GetDefaultFaviconSizes(), - favicon, time, gfx::Size()); + chrome::FaviconID id1 = db.AddFavicon(url, + chrome::FAVICON, + GetDefaultFaviconSizes(), + favicon, + time, + gfx::Size()); EXPECT_NE(0, db.AddIconMapping(url, id1)); - FaviconID id2 = db.AddFavicon(url, TOUCH_ICON, GetDefaultFaviconSizes(), - favicon, time, gfx::Size()); + chrome::FaviconID id2 = db.AddFavicon(url, + chrome::TOUCH_ICON, + GetDefaultFaviconSizes(), + favicon, + time, + gfx::Size()); EXPECT_NE(0, db.AddIconMapping(url, id2)); - FaviconID id3 = db.AddFavicon(url, TOUCH_ICON, GetDefaultFaviconSizes(), - favicon, time, gfx::Size()); + chrome::FaviconID id3 = db.AddFavicon(url, + chrome::TOUCH_ICON, + GetDefaultFaviconSizes(), + favicon, + time, + gfx::Size()); EXPECT_NE(0, db.AddIconMapping(url, id3)); // Only the mappings for favicons of type TOUCH_ICON should be returned as @@ -589,7 +625,7 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLWithIconType) { std::vector<IconMapping> icon_mappings; EXPECT_TRUE(db.GetIconMappingsForPageURL( url, - FAVICON | TOUCH_ICON | TOUCH_PRECOMPOSED_ICON, + chrome::FAVICON | chrome::TOUCH_ICON | chrome::TOUCH_PRECOMPOSED_ICON, &icon_mappings)); EXPECT_EQ(2u, icon_mappings.size()); @@ -601,7 +637,8 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLWithIconType) { } icon_mappings.clear(); - EXPECT_TRUE(db.GetIconMappingsForPageURL(url, TOUCH_ICON, &icon_mappings)); + EXPECT_TRUE( + db.GetIconMappingsForPageURL(url, chrome::TOUCH_ICON, &icon_mappings)); if (id2 == icon_mappings[0].icon_id) { EXPECT_EQ(id3, icon_mappings[1].icon_id); } else { @@ -610,7 +647,8 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLWithIconType) { } icon_mappings.clear(); - EXPECT_TRUE(db.GetIconMappingsForPageURL(url, FAVICON, &icon_mappings)); + EXPECT_TRUE( + db.GetIconMappingsForPageURL(url, chrome::FAVICON, &icon_mappings)); EXPECT_EQ(1u, icon_mappings.size()); EXPECT_EQ(id1, icon_mappings[0].icon_id); } @@ -625,20 +663,32 @@ TEST_F(ThumbnailDatabaseTest, HasMappingFor) { // Add a favicon which will have icon_mappings base::Time time = base::Time::Now(); - FaviconID id1 = db.AddFavicon(GURL("http://google.com"), FAVICON, - GetDefaultFaviconSizes(), favicon, time, gfx::Size()); + chrome::FaviconID id1 = db.AddFavicon(GURL("http://google.com"), + chrome::FAVICON, + GetDefaultFaviconSizes(), + favicon, + time, + gfx::Size()); EXPECT_NE(id1, 0); // Add another type of favicon time = base::Time::Now(); - FaviconID id2 = db.AddFavicon(GURL("http://www.google.com/icon"), TOUCH_ICON, - GetDefaultFaviconSizes(), favicon, time, gfx::Size()); + chrome::FaviconID id2 = db.AddFavicon(GURL("http://www.google.com/icon"), + chrome::TOUCH_ICON, + GetDefaultFaviconSizes(), + favicon, + time, + gfx::Size()); EXPECT_NE(id2, 0); // Add 3rd favicon time = base::Time::Now(); - FaviconID id3 = db.AddFavicon(GURL("http://www.google.com/icon"), TOUCH_ICON, - GetDefaultFaviconSizes(), favicon, time, gfx::Size()); + chrome::FaviconID id3 = db.AddFavicon(GURL("http://www.google.com/icon"), + chrome::TOUCH_ICON, + GetDefaultFaviconSizes(), + favicon, + time, + gfx::Size()); EXPECT_NE(id3, 0); // Add 2 icon mapping @@ -666,22 +716,24 @@ TEST_F(ThumbnailDatabaseTest, CloneIconMappings) { scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); // Add a favicon which will have icon_mappings - FaviconID id1 = db.AddFavicon(GURL("http://google.com"), FAVICON, - GetDefaultFaviconSizes()); + chrome::FaviconID id1 = db.AddFavicon( + GURL("http://google.com"), chrome::FAVICON, GetDefaultFaviconSizes()); EXPECT_NE(0, id1); base::Time time = base::Time::Now(); db.AddFaviconBitmap(id1, favicon, time, gfx::Size()); // Add another type of favicon - FaviconID id2 = db.AddFavicon(GURL("http://www.google.com/icon"), TOUCH_ICON, - GetDefaultFaviconSizes()); + chrome::FaviconID id2 = db.AddFavicon(GURL("http://www.google.com/icon"), + chrome::TOUCH_ICON, + GetDefaultFaviconSizes()); EXPECT_NE(0, id2); time = base::Time::Now(); db.AddFaviconBitmap(id2, favicon, time, gfx::Size()); // Add 3rd favicon - FaviconID id3 = db.AddFavicon(GURL("http://www.google.com/icon"), TOUCH_ICON, - GetDefaultFaviconSizes()); + chrome::FaviconID id3 = db.AddFavicon(GURL("http://www.google.com/icon"), + chrome::TOUCH_ICON, + GetDefaultFaviconSizes()); EXPECT_NE(0, id3); time = base::Time::Now(); db.AddFaviconBitmap(id3, favicon, time, gfx::Size()); @@ -740,7 +792,7 @@ TEST_F(IconMappingMigrationTest, TestIconMappingMigration) { std::vector<IconMapping> icon_mappings; EXPECT_TRUE(db.GetIconMappingsForPageURL(page_url1, &icon_mappings)); ASSERT_EQ(1u, icon_mappings.size()); - EXPECT_EQ(FAVICON, icon_mappings[0].icon_type); + EXPECT_EQ(chrome::FAVICON, icon_mappings[0].icon_type); EXPECT_EQ(page_url1, icon_mappings[0].page_url); EXPECT_EQ(1, icon_mappings[0].icon_id); EXPECT_EQ(icon1, icon_mappings[0].icon_url); @@ -750,7 +802,7 @@ TEST_F(IconMappingMigrationTest, TestIconMappingMigration) { icon_mappings.clear(); EXPECT_TRUE(db.GetIconMappingsForPageURL(page_url3, &icon_mappings)); ASSERT_EQ(1u, icon_mappings.size()); - EXPECT_EQ(FAVICON, icon_mappings[0].icon_type); + EXPECT_EQ(chrome::FAVICON, icon_mappings[0].icon_type); EXPECT_EQ(page_url3, icon_mappings[0].page_url); EXPECT_EQ(1, icon_mappings[0].icon_id); EXPECT_EQ(icon1, icon_mappings[0].icon_url); @@ -760,7 +812,7 @@ TEST_F(IconMappingMigrationTest, TestIconMappingMigration) { icon_mappings.clear(); EXPECT_TRUE(db.GetIconMappingsForPageURL(page_url2, &icon_mappings)); ASSERT_EQ(1u, icon_mappings.size()); - EXPECT_EQ(FAVICON, icon_mappings[0].icon_type); + EXPECT_EQ(chrome::FAVICON, icon_mappings[0].icon_type); EXPECT_EQ(page_url2, icon_mappings[0].page_url); EXPECT_EQ(2, icon_mappings[0].icon_id); EXPECT_EQ(icon2, icon_mappings[0].icon_url); @@ -780,29 +832,41 @@ TEST_F(ThumbnailDatabaseTest, IconMappingEnumerator) { GURL url("http://google.com"); GURL icon_url1("http://google.com/favicon.ico"); - FaviconID touch_icon_id1 = db.AddFavicon(icon_url1, TOUCH_ICON, - GetDefaultFaviconSizes(), favicon, base::Time::Now(), gfx::Size()); + chrome::FaviconID touch_icon_id1 = db.AddFavicon(icon_url1, + chrome::TOUCH_ICON, + GetDefaultFaviconSizes(), + favicon, + base::Time::Now(), + gfx::Size()); ASSERT_NE(0, touch_icon_id1); IconMappingID touch_mapping_id1 = db.AddIconMapping(url, touch_icon_id1); ASSERT_NE(0, touch_mapping_id1); - FaviconID favicon_id1 = db.AddFavicon(icon_url1, FAVICON, - GetDefaultFaviconSizes(), favicon, base::Time::Now(), gfx::Size()); + chrome::FaviconID favicon_id1 = db.AddFavicon(icon_url1, + chrome::FAVICON, + GetDefaultFaviconSizes(), + favicon, + base::Time::Now(), + gfx::Size()); ASSERT_NE(0, favicon_id1); IconMappingID favicon_mapping_id1 = db.AddIconMapping(url, favicon_id1); ASSERT_NE(0, favicon_mapping_id1); GURL url2("http://chromium.org"); GURL icon_url2("http://chromium.org/favicon.ico"); - FaviconID favicon_id2 = db.AddFavicon(icon_url2, FAVICON, - GetDefaultFaviconSizes(), favicon, base::Time::Now(), gfx::Size()); + chrome::FaviconID favicon_id2 = db.AddFavicon(icon_url2, + chrome::FAVICON, + GetDefaultFaviconSizes(), + favicon, + base::Time::Now(), + gfx::Size()); ASSERT_NE(0, favicon_id2); IconMappingID favicon_mapping_id2 = db.AddIconMapping(url2, favicon_id2); ASSERT_NE(0, favicon_mapping_id2); IconMapping icon_mapping; ThumbnailDatabase::IconMappingEnumerator enumerator1; - ASSERT_TRUE(db.InitIconMappingEnumerator(FAVICON, &enumerator1)); + ASSERT_TRUE(db.InitIconMappingEnumerator(chrome::FAVICON, &enumerator1)); // There are 2 favicon mappings. bool has_favicon_mapping1 = false; bool has_favicon_mapping2 = false; @@ -814,13 +878,13 @@ TEST_F(ThumbnailDatabaseTest, IconMappingEnumerator) { EXPECT_EQ(url, icon_mapping.page_url); EXPECT_EQ(favicon_id1, icon_mapping.icon_id); EXPECT_EQ(icon_url1, icon_mapping.icon_url); - EXPECT_EQ(FAVICON, icon_mapping.icon_type); + EXPECT_EQ(chrome::FAVICON, icon_mapping.icon_type); } else if (favicon_mapping_id2 == icon_mapping.mapping_id) { has_favicon_mapping2 = true; EXPECT_EQ(url2, icon_mapping.page_url); EXPECT_EQ(favicon_id2, icon_mapping.icon_id); EXPECT_EQ(icon_url2, icon_mapping.icon_url); - EXPECT_EQ(FAVICON, icon_mapping.icon_type); + EXPECT_EQ(chrome::FAVICON, icon_mapping.icon_type); } } EXPECT_EQ(2, mapping_count); @@ -828,13 +892,13 @@ TEST_F(ThumbnailDatabaseTest, IconMappingEnumerator) { EXPECT_TRUE(has_favicon_mapping2); ThumbnailDatabase::IconMappingEnumerator enumerator2; - ASSERT_TRUE(db.InitIconMappingEnumerator(TOUCH_ICON, &enumerator2)); + ASSERT_TRUE(db.InitIconMappingEnumerator(chrome::TOUCH_ICON, &enumerator2)); ASSERT_TRUE(enumerator2.GetNextIconMapping(&icon_mapping)); EXPECT_EQ(touch_mapping_id1, icon_mapping.mapping_id); EXPECT_EQ(url, icon_mapping.page_url); EXPECT_EQ(touch_icon_id1, icon_mapping.icon_id); EXPECT_EQ(icon_url1, icon_mapping.icon_url); - EXPECT_EQ(TOUCH_ICON, icon_mapping.icon_type); + EXPECT_EQ(chrome::TOUCH_ICON, icon_mapping.icon_type); EXPECT_FALSE(enumerator2.GetNextIconMapping(&icon_mapping)); } diff --git a/chrome/browser/history/url_database_unittest.cc b/chrome/browser/history/url_database_unittest.cc index f3d025d..b51dd16 100644 --- a/chrome/browser/history/url_database_unittest.cc +++ b/chrome/browser/history/url_database_unittest.cc @@ -233,7 +233,7 @@ TEST_F(URLDatabaseTest, IconMappingEnumerator) { URLID url_id1 = AddURL(url_info1); ASSERT_NE(0, url_id1); - FaviconID icon_id = 1; + chrome::FaviconID icon_id = 1; sql::Statement statement(GetDB().GetCachedStatement( SQL_FROM_HERE, "UPDATE urls SET favicon_id =? WHERE id=?")); diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc index fa4d0bd..fa1b2b5 100644 --- a/chrome/browser/jumplist_win.cc +++ b/chrome/browser/jumplist_win.cc @@ -25,6 +25,7 @@ #include "base/win/windows_version.h" #include "chrome/browser/favicon/favicon_service.h" #include "chrome/browser/favicon/favicon_service_factory.h" +#include "chrome/browser/favicon/favicon_types.h" #include "chrome/browser/history/history_service.h" #include "chrome/browser/history/page_usage_data.h" #include "chrome/browser/history/top_sites.h" @@ -685,7 +686,7 @@ void JumpList::StartLoadingFavicon() { task_id_ = favicon_service->GetFaviconImageForURL( FaviconService::FaviconForURLParams(profile_, url, - history::FAVICON, + chrome::FAVICON, gfx::kFaviconSize), base::Bind(&JumpList::OnFaviconDataAvailable, base::Unretained(this)), @@ -693,7 +694,7 @@ void JumpList::StartLoadingFavicon() { } void JumpList::OnFaviconDataAvailable( - const history::FaviconImageResult& image_result) { + const chrome::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_ = CancelableTaskTracker::kBadTaskId; diff --git a/chrome/browser/jumplist_win.h b/chrome/browser/jumplist_win.h index d4865ab..581721c 100644 --- a/chrome/browser/jumplist_win.h +++ b/chrome/browser/jumplist_win.h @@ -25,6 +25,10 @@ namespace base { class FilePath; } +namespace chrome { +struct FaviconImageResult; +} + namespace content { class NotificationRegistrar; } @@ -187,7 +191,7 @@ class JumpList : public TabRestoreServiceObserver, // is available. // To avoid file operations, this function just attaches the given data to // a ShellLinkItem object. - void OnFaviconDataAvailable(const history::FaviconImageResult& image_result); + void OnFaviconDataAvailable(const chrome::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 24a7448..a1cea8f 100644 --- a/chrome/browser/notifications/message_center_settings_controller.cc +++ b/chrome/browser/notifications/message_center_settings_controller.cc @@ -12,6 +12,8 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/favicon/favicon_service.h" #include "chrome/browser/favicon/favicon_service_factory.h" +#include "chrome/browser/favicon/favicon_types.h" +#include "chrome/browser/history/history_types.h" #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/notifications/desktop_notification_service_factory.h" #include "chrome/browser/profiles/profile.h" @@ -126,7 +128,7 @@ void MessageCenterSettingsController::GetNotifierList( notification_service->GetContentSetting(url) == CONTENT_SETTING_ALLOW)); patterns_[name] = iter->primary_pattern; FaviconService::FaviconForURLParams favicon_params( - profile, url, history::FAVICON | history::TOUCH_ICON, + profile, url, chrome::FAVICON | chrome::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 @@ -217,7 +219,7 @@ void MessageCenterSettingsController::OnNotifierSettingsClosing() { void MessageCenterSettingsController::OnFaviconLoaded( const GURL& url, - const history::FaviconImageResult& favicon_result) { + const chrome::FaviconImageResult& favicon_result) { if (!delegate_) return; delegate_->UpdateFavicon(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 a57b7a1..8f7ffa1 100644 --- a/chrome/browser/notifications/message_center_settings_controller.h +++ b/chrome/browser/notifications/message_center_settings_controller.h @@ -11,12 +11,15 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "chrome/browser/extensions/app_icon_loader.h" -#include "chrome/browser/history/history_types.h" #include "chrome/common/content_settings.h" #include "ui/message_center/notifier_settings.h" class CancelableTaskTracker; +namespace chrome { +struct FaviconImageResult; +} + // The class to bridge between the settings UI of notifiers and the preference // storage. class MessageCenterSettingsController @@ -46,7 +49,7 @@ class MessageCenterSettingsController private: void OnFaviconLoaded(const GURL& url, - const history::FaviconImageResult& favicon_result); + const chrome::FaviconImageResult& favicon_result); // The view displaying notifier settings. NULL if the settings are not // visible. diff --git a/chrome/browser/sync/glue/bookmark_change_processor.cc b/chrome/browser/sync/glue/bookmark_change_processor.cc index 9446303..3a443c9 100644 --- a/chrome/browser/sync/glue/bookmark_change_processor.cc +++ b/chrome/browser/sync/glue/bookmark_change_processor.cc @@ -789,7 +789,7 @@ void BookmarkChangeProcessor::ApplyBookmarkFavicon( gfx::Size pixel_size(gfx::kFaviconSize, gfx::kFaviconSize); favicon_service->MergeFavicon(bookmark_node->url(), icon_url, - history::FAVICON, + chrome::FAVICON, bitmap_data, pixel_size); } diff --git a/chrome/browser/sync/glue/favicon_cache.cc b/chrome/browser/sync/glue/favicon_cache.cc index 6f48fdb..c94528e 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). - history::FaviconBitmapResult bitmap_data[NUM_SIZES]; + chrome::FaviconBitmapResult bitmap_data[NUM_SIZES]; // The URL this favicon was loaded from. const GURL favicon_url; // Is the favicon for a bookmarked page? @@ -79,7 +79,7 @@ const int kMaxFaviconResolution = 16; // TODO(zea): Supporting other favicons types will involve some work in the // favicon service and navigation controller. See crbug.com/181068. int SupportedFaviconTypes() { - return history::FAVICON; + return chrome::FAVICON; } // Returns the appropriate IconSize to use for a given gfx::Size pixel @@ -122,12 +122,12 @@ GURL GetFaviconURLFromSpecifics(const sync_pb::EntitySpecifics& specifics) { } // Convert protobuf image data into a FaviconBitmapResult. -history::FaviconBitmapResult GetImageDataFromSpecifics( +chrome::FaviconBitmapResult GetImageDataFromSpecifics( const sync_pb::FaviconData& favicon_data) { base::RefCountedString* temp_string = new base::RefCountedString(); temp_string->data() = favicon_data.favicon(); - history::FaviconBitmapResult bitmap_result; + chrome::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 +136,7 @@ history::FaviconBitmapResult GetImageDataFromSpecifics( // Convert a FaviconBitmapResult into protobuf image data. void FillSpecificsWithImageData( - const history::FaviconBitmapResult& bitmap_result, + const chrome::FaviconBitmapResult& bitmap_result, sync_pb::FaviconData* favicon_data) { if (!bitmap_result.bitmap_data) return; @@ -172,7 +172,7 @@ void BuildTrackingSpecifics( // Updates |favicon_info| with the image data in |bitmap_result|. bool UpdateFaviconFromBitmapResult( - const history::FaviconBitmapResult& bitmap_result, + const chrome::FaviconBitmapResult& bitmap_result, SyncedFaviconInfo* favicon_info) { DCHECK_EQ(favicon_info->favicon_url, bitmap_result.icon_url); if (!bitmap_result.is_valid()) { @@ -374,7 +374,7 @@ syncer::SyncError FaviconCache::ProcessSyncChanges( } else { for (int i = 0; i < NUM_SIZES; ++i) { favicon_iter->second->bitmap_data[i] = - history::FaviconBitmapResult(); + chrome::FaviconBitmapResult(); } DCHECK(!FaviconInfoHasImages(*(favicon_iter->second))); } @@ -636,7 +636,7 @@ bool FaviconCache::FaviconRecencyFunctor::operator()( void FaviconCache::OnFaviconDataAvailable( const GURL& page_url, - const std::vector<history::FaviconBitmapResult>& bitmap_results) { + const std::vector<chrome::FaviconBitmapResult>& bitmap_results) { PageTaskMap::iterator page_iter = page_task_map_.find(page_url); if (page_iter == page_task_map_.end()) return; @@ -652,7 +652,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 history::FaviconBitmapResult& bitmap_result = bitmap_results[i]; + const chrome::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. diff --git a/chrome/browser/sync/glue/favicon_cache.h b/chrome/browser/sync/glue/favicon_cache.h index 8675fa0..d7641c7 100644 --- a/chrome/browser/sync/glue/favicon_cache.h +++ b/chrome/browser/sync/glue/favicon_cache.h @@ -27,7 +27,7 @@ class Profile; -namespace history { +namespace chrome { struct FaviconBitmapResult; } @@ -144,7 +144,7 @@ class FaviconCache : public syncer::SyncableService, // available. Does nothing if no favicon data was available. void OnFaviconDataAvailable( const GURL& page_url, - const std::vector<history::FaviconBitmapResult>& bitmap_result); + const std::vector<chrome::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 1af86cb..ad3a91a 100644 --- a/chrome/browser/sync/glue/favicon_cache_unittest.cc +++ b/chrome/browser/sync/glue/favicon_cache_unittest.cc @@ -414,9 +414,9 @@ scoped_ptr<syncer::SyncErrorFactory> SyncFaviconCacheTest:: void SyncFaviconCacheTest::OnCustomFaviconDataAvailable( const TestFaviconData& test_data) { - std::vector<history::FaviconBitmapResult> bitmap_results; + std::vector<chrome::FaviconBitmapResult> bitmap_results; if (!test_data.image_16.empty()) { - history::FaviconBitmapResult bitmap_result; + chrome::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); @@ -426,7 +426,7 @@ void SyncFaviconCacheTest::OnCustomFaviconDataAvailable( bitmap_results.push_back(bitmap_result); } if (!test_data.image_32.empty()) { - history::FaviconBitmapResult bitmap_result; + chrome::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); @@ -436,7 +436,7 @@ void SyncFaviconCacheTest::OnCustomFaviconDataAvailable( bitmap_results.push_back(bitmap_result); } if (!test_data.image_64.empty()) { - history::FaviconBitmapResult bitmap_result; + chrome::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 fde3b91..dc4a341 100644 --- a/chrome/browser/sync/test/integration/bookmarks_helper.cc +++ b/chrome/browser/sync/test/integration/bookmarks_helper.cc @@ -227,7 +227,7 @@ void SetFaviconImpl(Profile* profile, if (favicon_source == bookmarks_helper::FROM_UI) { favicon_service->SetFavicons(node->url(), icon_url, - history::FAVICON, + chrome::FAVICON, image); } else { browser_sync::BookmarkChangeProcessor::ApplyBookmarkFavicon( diff --git a/chrome/browser/task_manager/task_manager_guest_resource_provider.cc b/chrome/browser/task_manager/task_manager_guest_resource_provider.cc index c837e59..16946cc 100644 --- a/chrome/browser/task_manager/task_manager_guest_resource_provider.cc +++ b/chrome/browser/task_manager/task_manager_guest_resource_provider.cc @@ -17,6 +17,7 @@ #include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/gfx/image/image.h" #include "ui/gfx/image/image_skia.h" using content::RenderProcessHost; diff --git a/chrome/browser/ui/android/navigation_popup.cc b/chrome/browser/ui/android/navigation_popup.cc index 3ae9b01..69ef1df 100644 --- a/chrome/browser/ui/android/navigation_popup.cc +++ b/chrome/browser/ui/android/navigation_popup.cc @@ -51,7 +51,7 @@ void NavigationPopup::FetchFaviconForUrl(JNIEnv* env, favicon_service->GetFaviconImageForURL( FaviconService::FaviconForURLParams(profile, url, - history::FAVICON, + chrome::FAVICON, gfx::kFaviconSize), base::Bind(&NavigationPopup::OnFaviconDataAvailable, base::Unretained(this), @@ -61,7 +61,7 @@ void NavigationPopup::FetchFaviconForUrl(JNIEnv* env, void NavigationPopup::OnFaviconDataAvailable( GURL navigation_entry_url, - const history::FaviconImageResult& image_result) { + const chrome::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 8b1a43c..da3e222 100644 --- a/chrome/browser/ui/android/navigation_popup.h +++ b/chrome/browser/ui/android/navigation_popup.h @@ -13,7 +13,7 @@ class GURL; -namespace history { +namespace chrome { struct FaviconImageResult; } @@ -27,7 +27,7 @@ class NavigationPopup { void FetchFaviconForUrl(JNIEnv* env, jobject obj, jstring jurl); void OnFaviconDataAvailable(GURL navigation_entry_url, - const history::FaviconImageResult& image_result); + const chrome::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 b649765..8f4582e 100644 --- a/chrome/browser/ui/cocoa/history_menu_bridge.h +++ b/chrome/browser/ui/cocoa/history_menu_bridge.h @@ -28,10 +28,12 @@ class TabRestoreService; @class HistoryMenuCocoaController; namespace { - class HistoryMenuBridgeTest; +} -} // namespace +namespace chrome { +struct FaviconImageResult; +} // C++ bridge for the history menu; one per AppController (means there // is only one). This class observes various data sources, namely the @@ -192,7 +194,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 history::FaviconImageResult& image_result); + const chrome::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 eb65338..747a22d 100644 --- a/chrome/browser/ui/cocoa/history_menu_bridge.mm +++ b/chrome/browser/ui/cocoa/history_menu_bridge.mm @@ -13,6 +13,7 @@ #include "chrome/app/chrome_command_ids.h" // IDC_HISTORY_MENU #import "chrome/browser/app_controller_mac.h" #include "chrome/browser/favicon/favicon_service_factory.h" +#include "chrome/browser/favicon/favicon_types.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/page_usage_data.h" #include "chrome/browser/profiles/profile.h" @@ -460,7 +461,7 @@ void HistoryMenuBridge::GetFaviconForHistoryItem(HistoryItem* item) { CancelableTaskTracker::TaskId task_id = service->GetFaviconImageForURL( FaviconService::FaviconForURLParams(profile_, item->url, - history::FAVICON, + chrome::FAVICON, gfx::kFaviconSize), base::Bind(&HistoryMenuBridge::GotFaviconData, base::Unretained(this), @@ -472,7 +473,7 @@ void HistoryMenuBridge::GetFaviconForHistoryItem(HistoryItem* item) { void HistoryMenuBridge::GotFaviconData( HistoryItem* item, - const history::FaviconImageResult& image_result) { + const chrome::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 719f5ce..fc32b24 100644 --- a/chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm +++ b/chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm @@ -12,6 +12,7 @@ #include "base/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/common/cancelable_request.h" +#include "chrome/browser/favicon/favicon_types.h" #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" @@ -107,7 +108,7 @@ class HistoryMenuBridgeTest : public CocoaProfileTest { void GotFaviconData( HistoryMenuBridge::HistoryItem* item, - const history::FaviconImageResult& image_result) { + const chrome::FaviconImageResult& image_result) { bridge_->GotFaviconData(item, image_result); } @@ -351,7 +352,7 @@ TEST_F(HistoryMenuBridgeTest, GotFaviconData) { GetFaviconForHistoryItem(&item); // Pretend to be called back. - history::FaviconImageResult image_result; + chrome::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 ae77a5e4..4e610da 100644 --- a/chrome/browser/ui/search_engines/template_url_table_model.cc +++ b/chrome/browser/ui/search_engines/template_url_table_model.cc @@ -11,6 +11,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/favicon/favicon_service.h" #include "chrome/browser/favicon/favicon_service_factory.h" +#include "chrome/browser/favicon/favicon_types.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_service.h" @@ -94,14 +95,13 @@ class ModelEntry { } load_state_ = LOADING; favicon_service->GetFaviconImage( - favicon_url, history::FAVICON, gfx::kFaviconSize, + favicon_url, chrome::FAVICON, gfx::kFaviconSize, base::Bind(&ModelEntry::OnFaviconDataAvailable, base::Unretained(this)), &tracker_); } - void OnFaviconDataAvailable( - const history::FaviconImageResult& image_result) { + void OnFaviconDataAvailable(const chrome::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 705c234..09ae305c 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model.cc +++ b/chrome/browser/ui/toolbar/back_forward_menu_model.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "build/build_config.h" - #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" #include "base/bind.h" #include "base/bind_helpers.h" #include "base/prefs/pref_service.h" #include "base/strings/string_number_conversions.h" +#include "build/build_config.h" #include "chrome/browser/favicon/favicon_service_factory.h" +#include "chrome/browser/favicon/favicon_types.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" @@ -257,7 +257,7 @@ void BackForwardMenuModel::FetchFavicon(NavigationEntry* entry) { favicon_service->GetFaviconImageForURL( FaviconService::FaviconForURLParams(browser_->profile(), entry->GetURL(), - history::FAVICON, + chrome::FAVICON, gfx::kFaviconSize), base::Bind(&BackForwardMenuModel::OnFavIconDataAvailable, base::Unretained(this), @@ -267,7 +267,7 @@ void BackForwardMenuModel::FetchFavicon(NavigationEntry* entry) { void BackForwardMenuModel::OnFavIconDataAvailable( int navigation_entry_unique_id, - const history::FaviconImageResult& image_result) { + const chrome::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 16a4d6b..f085352 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model.h +++ b/chrome/browser/ui/toolbar/back_forward_menu_model.h @@ -18,6 +18,10 @@ class Browser; +namespace chrome { +struct FaviconImageResult; +} + namespace content { class NavigationEntry; class WebContents; @@ -98,7 +102,7 @@ class BackForwardMenuModel : public ui::MenuModel { // Callback from the favicon service. void OnFavIconDataAvailable( int navigation_entry_unique_id, - const history::FaviconImageResult& image_result); + const chrome::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 c76eb6a..357dc82 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc +++ b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc @@ -534,7 +534,7 @@ TEST_F(BackFwdMenuModelTest, FaviconLoadTest) { url1, base::Time::Now(), history::SOURCE_BROWSED); FaviconServiceFactory::GetForProfile( profile(), Profile::EXPLICIT_ACCESS)->SetFavicons( - url1, url1_favicon, history::FAVICON, + url1, url1_favicon, chrome::FAVICON, gfx::Image::CreateFrom1xBitmap(new_icon_bitmap)); // Will return the current icon (default) but start an anync call 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 3e4bdd2..0c0ed93 100644 --- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc +++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc @@ -9,6 +9,7 @@ #include "base/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/favicon/favicon_service_factory.h" +#include "chrome/browser/favicon/favicon_types.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sessions/session_restore.h" @@ -494,7 +495,7 @@ void RecentTabsSubMenuModel::AddTabFavicon(int model_index, favicon_service->GetFaviconImageForURL( FaviconService::FaviconForURLParams(browser_->profile(), url, - history::FAVICON, + chrome::FAVICON, gfx::kFaviconSize), base::Bind(&RecentTabsSubMenuModel::OnFaviconDataAvailable, weak_ptr_factory_.GetWeakPtr(), @@ -504,7 +505,7 @@ void RecentTabsSubMenuModel::AddTabFavicon(int model_index, void RecentTabsSubMenuModel::OnFaviconDataAvailable( int command_id, - const history::FaviconImageResult& image_result) { + const chrome::FaviconImageResult& image_result) { if (image_result.image.IsEmpty()) return; DCHECK(!tab_navigation_items_.empty()); 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 c6f5e83..8f7fc13 100644 --- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h +++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h @@ -22,6 +22,10 @@ namespace browser_sync { class SessionModelAssociator; } +namespace chrome { +struct FaviconImageResult; +} + namespace gfx { class Image; } @@ -80,7 +84,7 @@ class RecentTabsSubMenuModel : public ui::SimpleMenuModel, browser_sync::SyncedSession::DeviceType device_type); void AddTabFavicon(int model_index, int command_id, const GURL& url); void OnFaviconDataAvailable(int command_id, - const history::FaviconImageResult& image_result); + const chrome::FaviconImageResult& image_result); browser_sync::SessionModelAssociator* GetModelAssociator(); Browser* browser_; // Weak. diff --git a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc index 5363dfc..f31bd94 100644 --- a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc +++ b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc @@ -29,6 +29,7 @@ #include "content/public/browser/web_contents.h" #include "ui/base/layout.h" #include "ui/base/models/list_selection_model.h" +#include "ui/gfx/image/image.h" #include "ui/views/controls/menu/menu_item_view.h" #include "ui/views/controls/menu/menu_runner.h" #include "ui/views/widget/widget.h" 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 52c64b0..29ef6a4 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc @@ -433,7 +433,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, void RunFaviconCallbackAsync( const FaviconService::FaviconResultsCallback& callback, - const std::vector<history::FaviconBitmapResult>* results) { + const std::vector<chrome::FaviconBitmapResult>* results) { base::MessageLoopProxy::current()->PostTask( FROM_HERE, base::Bind(&FaviconService::FaviconResultsCallbackRunner, @@ -493,22 +493,22 @@ void ChromeWebUIControllerFactory::GetFaviconForURL( ExtensionWebUI::GetFaviconForURL(profile, url, callback); #else RunFaviconCallbackAsync(callback, - new std::vector<history::FaviconBitmapResult>()); + new std::vector<chrome::FaviconBitmapResult>()); #endif return; } - std::vector<history::FaviconBitmapResult>* favicon_bitmap_results = - new std::vector<history::FaviconBitmapResult>(); + std::vector<chrome::FaviconBitmapResult>* favicon_bitmap_results = + new std::vector<chrome::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()) { - history::FaviconBitmapResult bitmap_result; + chrome::FaviconBitmapResult bitmap_result; bitmap_result.bitmap_data = bitmap; // Leave |bitmap_result|'s icon URL as the default of GURL(). - bitmap_result.icon_type = history::FAVICON; + bitmap_result.icon_type = chrome::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 4f53bc3..8e58c6d 100644 --- a/chrome/browser/ui/webui/extensions/extension_icon_source.cc +++ b/chrome/browser/ui/webui/extensions/extension_icon_source.cc @@ -221,7 +221,7 @@ void ExtensionIconSource::LoadFaviconImage(int request_id) { GURL favicon_url = GetData(request_id)->extension->GetFullLaunchURL(); favicon_service->GetRawFaviconForURL( FaviconService::FaviconForURLParams( - profile_, favicon_url, history::FAVICON, gfx::kFaviconSize), + profile_, favicon_url, chrome::FAVICON, gfx::kFaviconSize), ui::SCALE_FACTOR_100P, base::Bind(&ExtensionIconSource::OnFaviconDataAvailable, base::Unretained(this), request_id), @@ -230,7 +230,7 @@ void ExtensionIconSource::LoadFaviconImage(int request_id) { void ExtensionIconSource::OnFaviconDataAvailable( int request_id, - const history::FaviconBitmapResult& bitmap_result) { + const chrome::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 7ead961..a238551 100644 --- a/chrome/browser/ui/webui/extensions/extension_icon_source.h +++ b/chrome/browser/ui/webui/extensions/extension_icon_source.h @@ -111,7 +111,7 @@ class ExtensionIconSource : public content::URLDataSource, // FaviconService callback void OnFaviconDataAvailable( int request_id, - const history::FaviconBitmapResult& bitmap_result); + const chrome::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 2f75cad..0552d87 100644 --- a/chrome/browser/ui/webui/favicon_source.cc +++ b/chrome/browser/ui/webui/favicon_source.cc @@ -68,16 +68,16 @@ FaviconSource::IconRequest::~IconRequest() { FaviconSource::FaviconSource(Profile* profile, IconType type) : profile_(profile->GetOriginalProfile()), - icon_types_(type == FAVICON ? history::FAVICON : - history::TOUCH_PRECOMPOSED_ICON | history::TOUCH_ICON | - history::FAVICON) { + icon_types_(type == FAVICON ? chrome::FAVICON : + chrome::TOUCH_PRECOMPOSED_ICON | chrome::TOUCH_ICON | + chrome::FAVICON) { } FaviconSource::~FaviconSource() { } std::string FaviconSource::GetSource() const { - return icon_types_ == history::FAVICON ? + return icon_types_ == chrome::FAVICON ? chrome::kChromeUIFaviconHost : chrome::kChromeUITouchIconHost; } @@ -110,7 +110,7 @@ void FaviconSource::StartDataRequest( // IconType. favicon_service->GetRawFavicon( url, - history::FAVICON, + chrome::FAVICON, size_in_dip, scale_factor, base::Bind(&FaviconSource::OnFaviconDataAvailable, @@ -234,7 +234,7 @@ bool FaviconSource::ParsePath(const std::string& raw_path, // - favicons of sizes "16 * scale factor" px of type FAVICON // where scale factor is one of FaviconUtil::GetFaviconScaleFactors(). // - the largest TOUCH_ICON / TOUCH_PRECOMPOSED_ICON - if (*size_in_dip != 16 && icon_types_ == history::FAVICON) + if (*size_in_dip != 16 && icon_types_ == chrome::FAVICON) return false; parsed_index = slash + 1; @@ -268,7 +268,7 @@ bool FaviconSource::ParsePath(const std::string& raw_path, void FaviconSource::OnFaviconDataAvailable( const IconRequest& request, - const history::FaviconBitmapResult& bitmap_result) { + const chrome::FaviconBitmapResult& bitmap_result) { if (bitmap_result.is_valid()) { // Forward the data along to the networking system. request.callback.Run(bitmap_result.bitmap_data); diff --git a/chrome/browser/ui/webui/favicon_source.h b/chrome/browser/ui/webui/favicon_source.h index 8921594..b1faf72 100644 --- a/chrome/browser/ui/webui/favicon_source.h +++ b/chrome/browser/ui/webui/favicon_source.h @@ -128,7 +128,7 @@ class FaviconSource : public content::URLDataSource { // Called when favicon data is available from the history backend. void OnFaviconDataAvailable( const IconRequest& request, - const history::FaviconBitmapResult& bitmap_result); + const chrome::FaviconBitmapResult& bitmap_result); // Sends the 16x16 DIP 1x default favicon. void SendDefaultResponse( @@ -143,7 +143,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 history::IconTypes of icon that this FaviconSource handles. + // The chrome::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 b2f2f12..a55d09b 100644 --- a/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc +++ b/chrome/browser/ui/webui/ntp/android/bookmarks_handler.cc @@ -393,8 +393,8 @@ void BookmarksHandler::HandleCreateHomeScreenBookmarkShortcut( FaviconService::FaviconForURLParams( profile, node->url(), - history::TOUCH_PRECOMPOSED_ICON | history::TOUCH_ICON | - history::FAVICON, + chrome::TOUCH_PRECOMPOSED_ICON | chrome::TOUCH_ICON | + chrome::FAVICON, 0), // request the largest icon. ui::SCALE_FACTOR_100P, // density doesn't matter for the largest icon. base::Bind(&BookmarksHandler::OnShortcutFaviconDataAvailable, @@ -405,7 +405,7 @@ void BookmarksHandler::HandleCreateHomeScreenBookmarkShortcut( void BookmarksHandler::OnShortcutFaviconDataAvailable( const BookmarkNode* node, - const history::FaviconBitmapResult& bitmap_result) { + const chrome::FaviconBitmapResult& bitmap_result) { SkColor color = SK_ColorWHITE; SkBitmap favicon_bitmap; if (bitmap_result.is_valid()) { diff --git a/chrome/browser/ui/webui/ntp/android/bookmarks_handler.h b/chrome/browser/ui/webui/ntp/android/bookmarks_handler.h index 451ab83..d834a15 100644 --- a/chrome/browser/ui/webui/ntp/android/bookmarks_handler.h +++ b/chrome/browser/ui/webui/ntp/android/bookmarks_handler.h @@ -134,7 +134,7 @@ class BookmarksHandler : public content::WebUIMessageHandler, // and is available for use. void OnShortcutFaviconDataAvailable( const BookmarkNode* node, - const history::FaviconBitmapResult& bitmap_result); + const chrome::FaviconBitmapResult& bitmap_result); DISALLOW_COPY_AND_ASSIGN(BookmarksHandler); }; diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc index 41b18e2..4dcd462 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc @@ -24,6 +24,7 @@ #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/management_policy.h" #include "chrome/browser/favicon/favicon_service_factory.h" +#include "chrome/browser/favicon/favicon_types.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser_finder.h" @@ -669,7 +670,7 @@ void AppLauncherHandler::HandleGenerateAppForLink(const ListValue* args) { favicon_service->GetFaviconImageForURL( FaviconService::FaviconForURLParams(profile, launch_url, - history::FAVICON, + chrome::FAVICON, gfx::kFaviconSize), base::Bind(&AppLauncherHandler::OnFaviconForApp, base::Unretained(this), @@ -699,7 +700,7 @@ void AppLauncherHandler::StopShowingAppLauncherPromo( void AppLauncherHandler::OnFaviconForApp( scoped_ptr<AppInstallInfo> install_info, - const history::FaviconImageResult& image_result) { + const chrome::FaviconImageResult& image_result) { scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo()); web_app->is_bookmark_app = install_info->is_bookmark_app; web_app->title = install_info->title; diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.h b/chrome/browser/ui/webui/ntp/app_launcher_handler.h index 1bcf7a4..2e65afd 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.h +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.h @@ -27,6 +27,10 @@ class ExtensionService; class PrefChangeRegistrar; class Profile; +namespace chrome { +struct FaviconImageResult; +} + namespace user_prefs { class PrefRegistrySyncable; } @@ -158,7 +162,7 @@ class AppLauncherHandler : public content::WebUIMessageHandler, // Continuation for installing a bookmark app after favicon lookup. void OnFaviconForApp(scoped_ptr<AppInstallInfo> install_info, - const history::FaviconImageResult& image_result); + const chrome::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 78501e1..1963866 100644 --- a/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc +++ b/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc @@ -114,7 +114,7 @@ void FaviconWebUIHandler::HandleGetFaviconDominantColor(const ListValue* args) { FaviconService::FaviconForURLParams( Profile::FromWebUI(web_ui()), url, - history::FAVICON, + chrome::FAVICON, gfx::kFaviconSize), ui::SCALE_FACTOR_100P, base::Bind(&FaviconWebUIHandler::OnFaviconDataAvailable, @@ -125,7 +125,7 @@ void FaviconWebUIHandler::HandleGetFaviconDominantColor(const ListValue* args) { void FaviconWebUIHandler::OnFaviconDataAvailable( int id, - const history::FaviconBitmapResult& bitmap_result) { + const chrome::FaviconBitmapResult& bitmap_result) { scoped_ptr<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 02f0a62..1fa5521 100644 --- a/chrome/browser/ui/webui/ntp/favicon_webui_handler.h +++ b/chrome/browser/ui/webui/ntp/favicon_webui_handler.h @@ -43,7 +43,7 @@ class FaviconWebUIHandler : public content::WebUIMessageHandler { // Called when favicon data is available from the history backend. void OnFaviconDataAvailable( FaviconService::Handle request_handle, - const history::FaviconBitmapResult& bitmap_result); + const chrome::FaviconBitmapResult& bitmap_result); CancelableTaskTracker cancelable_task_tracker_; |