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

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

Issue 10910212: Enable hidpi favicons for favicons history does not know about (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
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_handler.h" 5 #include "chrome/browser/favicon/favicon_handler.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 url, image_url, image, score, icon_type); 242 url, image_url, image, score, icon_type);
243 } 243 }
244 return exact_match; 244 return exact_match;
245 } 245 }
246 246
247 void FaviconHandler::SetFavicon( 247 void FaviconHandler::SetFavicon(
248 const GURL& url, 248 const GURL& url,
249 const GURL& icon_url, 249 const GURL& icon_url,
250 const gfx::Image& image, 250 const gfx::Image& image,
251 history::IconType icon_type) { 251 history::IconType icon_type) {
252 if (GetFaviconService() && ShouldSaveFavicon(url)) { 252 if (GetFaviconService() && ShouldSaveFavicon(url))
253 std::vector<unsigned char> image_data; 253 SetHistoryFavicons(url, icon_url, icon_type, image);
254 if (gfx::PNGEncodedDataFromImage(image, &image_data))
255 SetHistoryFavicon(url, icon_url, image_data, icon_type);
256 }
257 254
258 if (UrlMatches(url, url_) && icon_type == history::FAVICON) { 255 if (UrlMatches(url, url_) && icon_type == history::FAVICON) {
259 NavigationEntry* entry = GetEntry(); 256 NavigationEntry* entry = GetEntry();
260 if (entry) { 257 if (entry) {
261 entry->GetFavicon().url = icon_url; 258 entry->GetFavicon().url = icon_url;
262 UpdateFavicon(entry, &image); 259 UpdateFavicon(entry, &image);
263 } 260 }
264 } 261 }
265 } 262 }
266 263
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 int id = delegate_->StartDownload(image_url, image_size); 414 int id = delegate_->StartDownload(image_url, image_size);
418 return id; 415 return id;
419 } 416 }
420 417
421 void FaviconHandler::UpdateFaviconMappingAndFetch( 418 void FaviconHandler::UpdateFaviconMappingAndFetch(
422 const GURL& page_url, 419 const GURL& page_url,
423 const GURL& icon_url, 420 const GURL& icon_url,
424 history::IconType icon_type, 421 history::IconType icon_type,
425 CancelableRequestConsumerBase* consumer, 422 CancelableRequestConsumerBase* consumer,
426 const FaviconService::FaviconResultsCallback& callback) { 423 const FaviconService::FaviconResultsCallback& callback) {
427 GetFaviconService()->UpdateFaviconMappingAndFetch(page_url, icon_url, 424 // TODO(pkotwicz): pass in all of |image_urls_| to
428 icon_type, consumer, callback); 425 // UpdateFaviconMappingsAndFetch().
426 std::vector<GURL> icon_urls;
427 icon_urls.push_back(icon_url);
428 GetFaviconService()->UpdateFaviconMappingsAndFetch(page_url, icon_urls,
429 icon_type, preferred_icon_size(), ui::GetSupportedScaleFactors(),
430 consumer, callback);
429 } 431 }
430 432
431 void FaviconHandler::GetFavicon( 433 void FaviconHandler::GetFavicon(
432 const GURL& icon_url, 434 const GURL& icon_url,
433 history::IconType icon_type, 435 history::IconType icon_type,
434 CancelableRequestConsumerBase* consumer, 436 CancelableRequestConsumerBase* consumer,
435 const FaviconService::FaviconResultsCallback& callback) { 437 const FaviconService::FaviconResultsCallback& callback) {
436 GetFaviconService()->GetFavicon(icon_url, icon_type, preferred_icon_size(), 438 GetFaviconService()->GetFavicon(icon_url, icon_type, preferred_icon_size(),
437 ui::GetSupportedScaleFactors(), consumer, callback); 439 ui::GetSupportedScaleFactors(), consumer, callback);
438 } 440 }
439 441
440 void FaviconHandler::GetFaviconForURL( 442 void FaviconHandler::GetFaviconForURL(
441 const GURL& page_url, 443 const GURL& page_url,
442 int icon_types, 444 int icon_types,
443 CancelableRequestConsumerBase* consumer, 445 CancelableRequestConsumerBase* consumer,
444 const FaviconService::FaviconResultsCallback& callback) { 446 const FaviconService::FaviconResultsCallback& callback) {
445 GetFaviconService()->GetFaviconForURL( 447 GetFaviconService()->GetFaviconForURL(
446 FaviconService::FaviconForURLParams(profile_, page_url, icon_types, 448 FaviconService::FaviconForURLParams(profile_, page_url, icon_types,
447 preferred_icon_size(), consumer), 449 preferred_icon_size(), consumer),
448 ui::GetSupportedScaleFactors(), callback); 450 ui::GetSupportedScaleFactors(), callback);
449 } 451 }
450 452
451 void FaviconHandler::SetHistoryFavicon( 453 void FaviconHandler::SetHistoryFavicons(const GURL& page_url,
452 const GURL& page_url, 454 const GURL& icon_url,
453 const GURL& icon_url, 455 history::IconType icon_type,
454 const std::vector<unsigned char>& image_data, 456 const gfx::Image& image) {
455 history::IconType icon_type) { 457 GetFaviconService()->SetFavicons(page_url, icon_url, icon_type, image);
456 GetFaviconService()->SetFavicon(page_url, icon_url, image_data, icon_type);
457 } 458 }
458 459
459 bool FaviconHandler::ShouldSaveFavicon(const GURL& url) { 460 bool FaviconHandler::ShouldSaveFavicon(const GURL& url) {
460 if (!profile_->IsOffTheRecord()) 461 if (!profile_->IsOffTheRecord())
461 return true; 462 return true;
462 463
463 // Otherwise store the favicon if the page is bookmarked. 464 // Otherwise store the favicon if the page is bookmarked.
464 BookmarkModel* bookmark_model = 465 BookmarkModel* bookmark_model =
465 BookmarkModelFactory::GetForProfile(profile_); 466 BookmarkModelFactory::GetForProfile(profile_);
466 return bookmark_model && bookmark_model->IsBookmarked(url); 467 return bookmark_model && bookmark_model->IsBookmarked(url);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 const int download_id = DownloadFavicon(image_url, image_size); 596 const int download_id = DownloadFavicon(image_url, image_size);
596 if (download_id) { 597 if (download_id) {
597 // Download ids should be unique. 598 // Download ids should be unique.
598 DCHECK(download_requests_.find(download_id) == download_requests_.end()); 599 DCHECK(download_requests_.find(download_id) == download_requests_.end());
599 download_requests_[download_id] = 600 download_requests_[download_id] =
600 DownloadRequest(url, image_url, callback, icon_type); 601 DownloadRequest(url, image_url, callback, icon_type);
601 } 602 }
602 603
603 return download_id; 604 return download_id;
604 } 605 }
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_handler.h ('k') | chrome/browser/favicon/favicon_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698