Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: chrome/browser/favicon/favicon_tab_helper.cc

Issue 285293005: Replace content's faviconURL with components/favicon's (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/favicon/favicon_handler_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/favicon/favicon_tab_helper.h" 5 #include "chrome/browser/favicon/favicon_tab_helper.h"
6 6
7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 7 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/favicon/favicon_handler.h" 9 #include "chrome/browser/favicon/favicon_handler.h"
10 #include "chrome/browser/favicon/favicon_service_factory.h" 10 #include "chrome/browser/favicon/favicon_service_factory.h"
11 #include "chrome/browser/favicon/favicon_util.h" 11 #include "chrome/browser/favicon/favicon_util.h"
12 #include "chrome/browser/history/history_service.h" 12 #include "chrome/browser/history/history_service.h"
13 #include "chrome/browser/history/history_service_factory.h" 13 #include "chrome/browser/history/history_service_factory.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/search/search.h" 15 #include "chrome/browser/search/search.h"
16 #include "chrome/common/chrome_constants.h" 16 #include "chrome/common/chrome_constants.h"
17 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
18 #include "components/bookmarks/core/browser/bookmark_model.h" 18 #include "components/bookmarks/core/browser/bookmark_model.h"
19 #include "components/favicon_base/favicon_types.h"
19 #include "content/public/browser/favicon_status.h" 20 #include "content/public/browser/favicon_status.h"
20 #include "content/public/browser/invalidate_type.h" 21 #include "content/public/browser/invalidate_type.h"
21 #include "content/public/browser/navigation_controller.h" 22 #include "content/public/browser/navigation_controller.h"
22 #include "content/public/browser/navigation_details.h" 23 #include "content/public/browser/navigation_details.h"
23 #include "content/public/browser/navigation_entry.h" 24 #include "content/public/browser/navigation_entry.h"
24 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/render_view_host.h" 26 #include "content/public/browser/render_view_host.h"
26 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
27 #include "content/public/browser/web_contents_delegate.h" 28 #include "content/public/browser/web_contents_delegate.h"
29 #include "content/public/common/favicon_url.h"
28 #include "ui/gfx/codec/png_codec.h" 30 #include "ui/gfx/codec/png_codec.h"
29 #include "ui/gfx/image/image.h" 31 #include "ui/gfx/image/image.h"
30 #include "ui/gfx/image/image_skia.h" 32 #include "ui/gfx/image/image_skia.h"
31 #include "ui/gfx/image/image_skia_rep.h" 33 #include "ui/gfx/image/image_skia_rep.h"
32 34
33 using content::FaviconStatus; 35 using content::FaviconStatus;
34 using content::NavigationController; 36 using content::NavigationController;
35 using content::NavigationEntry; 37 using content::NavigationEntry;
36 using content::WebContents; 38 using content::WebContents;
37 39
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 217 }
216 218
217 void FaviconTabHelper::DidNavigateMainFrame( 219 void FaviconTabHelper::DidNavigateMainFrame(
218 const content::LoadCommittedDetails& details, 220 const content::LoadCommittedDetails& details,
219 const content::FrameNavigateParams& params) { 221 const content::FrameNavigateParams& params) {
220 favicon_urls_.clear(); 222 favicon_urls_.clear();
221 // Get the favicon, either from history or request it from the net. 223 // Get the favicon, either from history or request it from the net.
222 FetchFavicon(details.entry->GetURL()); 224 FetchFavicon(details.entry->GetURL());
223 } 225 }
224 226
227 // Returns favicon_base::IconType the given icon_type corresponds to.
228 // TODO(jif): Move function to /components/favicon_base/content/
229 // crbug.com/374281.
230 favicon_base::IconType ToChromeIconType(
231 content::FaviconURL::IconType icon_type) {
232 switch (icon_type) {
233 case content::FaviconURL::FAVICON:
234 return favicon_base::FAVICON;
235 case content::FaviconURL::TOUCH_ICON:
236 return favicon_base::TOUCH_ICON;
237 case content::FaviconURL::TOUCH_PRECOMPOSED_ICON:
238 return favicon_base::TOUCH_PRECOMPOSED_ICON;
239 case content::FaviconURL::INVALID_ICON:
240 return favicon_base::INVALID_ICON;
241 }
242 NOTREACHED();
243 return favicon_base::INVALID_ICON;
244 }
245
225 void FaviconTabHelper::DidUpdateFaviconURL( 246 void FaviconTabHelper::DidUpdateFaviconURL(
226 const std::vector<content::FaviconURL>& candidates) { 247 const std::vector<content::FaviconURL>& candidates) {
227 DCHECK(!candidates.empty()); 248 DCHECK(!candidates.empty());
228 favicon_urls_ = candidates; 249 favicon_urls_ = candidates;
229 250 std::vector<favicon::FaviconURL> favicon_urls;
230 favicon_handler_->OnUpdateFaviconURL(candidates); 251 for (size_t i = 0; i < candidates.size(); i++) {
252 const content::FaviconURL& candidate = candidates[i];
253 favicon_urls.push_back(
254 favicon::FaviconURL(candidate.icon_url,
255 ToChromeIconType(candidate.icon_type),
256 candidate.icon_sizes));
257 }
258 favicon_handler_->OnUpdateFaviconURL(favicon_urls);
231 if (touch_icon_handler_.get()) 259 if (touch_icon_handler_.get())
232 touch_icon_handler_->OnUpdateFaviconURL(candidates); 260 touch_icon_handler_->OnUpdateFaviconURL(favicon_urls);
233 } 261 }
234 262
235 FaviconService* FaviconTabHelper::GetFaviconService() { 263 FaviconService* FaviconTabHelper::GetFaviconService() {
236 return FaviconServiceFactory::GetForProfile(profile_, 264 return FaviconServiceFactory::GetForProfile(profile_,
237 Profile::EXPLICIT_ACCESS); 265 Profile::EXPLICIT_ACCESS);
238 } 266 }
239 267
240 bool FaviconTabHelper::IsBookmarked(const GURL& url) { 268 bool FaviconTabHelper::IsBookmarked(const GURL& url) {
241 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile_); 269 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile_);
242 return bookmark_model && bookmark_model->IsBookmarked(url); 270 return bookmark_model && bookmark_model->IsBookmarked(url);
(...skipping 14 matching lines...) Expand all
257 favicon_service->UnableToDownloadFavicon(image_url); 285 favicon_service->UnableToDownloadFavicon(image_url);
258 } 286 }
259 287
260 favicon_handler_->OnDidDownloadFavicon( 288 favicon_handler_->OnDidDownloadFavicon(
261 id, image_url, bitmaps, original_bitmap_sizes); 289 id, image_url, bitmaps, original_bitmap_sizes);
262 if (touch_icon_handler_.get()) { 290 if (touch_icon_handler_.get()) {
263 touch_icon_handler_->OnDidDownloadFavicon( 291 touch_icon_handler_->OnDidDownloadFavicon(
264 id, image_url, bitmaps, original_bitmap_sizes); 292 id, image_url, bitmaps, original_bitmap_sizes);
265 } 293 }
266 } 294 }
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_handler_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698