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

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

Issue 11418021: Revert 168079 - This CL ensures that favicons always (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « chrome/browser/extensions/extension_web_ui.cc ('k') | chrome/browser/favicon/favicon_service.h » ('j') | 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_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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 entry->GetFavicon().url = icon_url; 307 entry->GetFavicon().url = icon_url;
308 UpdateFavicon(entry, &image); 308 UpdateFavicon(entry, &image);
309 } 309 }
310 } 310 }
311 } 311 }
312 312
313 void FaviconHandler::UpdateFavicon(NavigationEntry* entry, 313 void FaviconHandler::UpdateFavicon(NavigationEntry* entry,
314 const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results) { 314 const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results) {
315 gfx::Image resized_image = FaviconUtil::SelectFaviconFramesFromPNGs( 315 gfx::Image resized_image = FaviconUtil::SelectFaviconFramesFromPNGs(
316 favicon_bitmap_results, 316 favicon_bitmap_results,
317 FaviconUtil::GetFaviconScaleFactors(), 317 ui::GetSupportedScaleFactors(),
318 preferred_icon_size()); 318 preferred_icon_size());
319 if (!resized_image.IsEmpty()) 319 if (!resized_image.IsEmpty())
320 UpdateFavicon(entry, &resized_image); 320 UpdateFavicon(entry, &resized_image);
321 } 321 }
322 322
323 void FaviconHandler::UpdateFavicon(NavigationEntry* entry, 323 void FaviconHandler::UpdateFavicon(NavigationEntry* entry,
324 const gfx::Image* image) { 324 const gfx::Image* image) {
325 // No matter what happens, we need to mark the favicon as being set. 325 // No matter what happens, we need to mark the favicon as being set.
326 entry->GetFavicon().valid = true; 326 entry->GetFavicon().valid = true;
327 327
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 std::vector<size_t> selected_bitmap_indices; 405 std::vector<size_t> selected_bitmap_indices;
406 SelectFaviconFrameIndices(sizes, scale_factors, requested_size, 406 SelectFaviconFrameIndices(sizes, scale_factors, requested_size,
407 &selected_bitmap_indices, NULL); 407 &selected_bitmap_indices, NULL);
408 DCHECK_EQ(1u, selected_bitmap_indices.size()); 408 DCHECK_EQ(1u, selected_bitmap_indices.size());
409 size_t closest_index = selected_bitmap_indices[0]; 409 size_t closest_index = selected_bitmap_indices[0];
410 i->second.callback.Run(id, errored, bitmaps[closest_index]); 410 i->second.callback.Run(id, errored, bitmaps[closest_index]);
411 } else if (current_candidate() && 411 } else if (current_candidate() &&
412 DoUrlAndIconMatch(*current_candidate(), image_url, 412 DoUrlAndIconMatch(*current_candidate(), image_url,
413 i->second.icon_type)) { 413 i->second.icon_type)) {
414 float score = 0.0f; 414 float score = 0.0f;
415 std::vector<ui::ScaleFactor> scale_factors = 415 std::vector<ui::ScaleFactor> scale_factors = ui::GetSupportedScaleFactors();
416 FaviconUtil::GetFaviconScaleFactors();
417 gfx::Image image(SelectFaviconFrames(bitmaps, scale_factors, requested_size, 416 gfx::Image image(SelectFaviconFrames(bitmaps, scale_factors, requested_size,
418 &score)); 417 &score));
419 418
420 // The downloaded icon is still valid when there is no FaviconURL update 419 // The downloaded icon is still valid when there is no FaviconURL update
421 // during the downloading. 420 // during the downloading.
422 bool request_next_icon = true; 421 bool request_next_icon = true;
423 if (!errored) { 422 if (!errored) {
424 request_next_icon = !UpdateFaviconCandidate( 423 request_next_icon = !UpdateFaviconCandidate(
425 i->second.url, image_url, image, score, i->second.icon_type); 424 i->second.url, image_url, image, score, i->second.icon_type);
426 } 425 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 const GURL& page_url, 464 const GURL& page_url,
466 const GURL& icon_url, 465 const GURL& icon_url,
467 history::IconType icon_type, 466 history::IconType icon_type,
468 CancelableRequestConsumerBase* consumer, 467 CancelableRequestConsumerBase* consumer,
469 const FaviconService::FaviconResultsCallback& callback) { 468 const FaviconService::FaviconResultsCallback& callback) {
470 // TODO(pkotwicz): pass in all of |image_urls_| to 469 // TODO(pkotwicz): pass in all of |image_urls_| to
471 // UpdateFaviconMappingsAndFetch(). 470 // UpdateFaviconMappingsAndFetch().
472 std::vector<GURL> icon_urls; 471 std::vector<GURL> icon_urls;
473 icon_urls.push_back(icon_url); 472 icon_urls.push_back(icon_url);
474 GetFaviconService()->UpdateFaviconMappingsAndFetch(page_url, icon_urls, 473 GetFaviconService()->UpdateFaviconMappingsAndFetch(page_url, icon_urls,
475 icon_type, preferred_icon_size(), consumer, callback); 474 icon_type, preferred_icon_size(), ui::GetSupportedScaleFactors(),
475 consumer, callback);
476 } 476 }
477 477
478 void FaviconHandler::GetFavicon( 478 void FaviconHandler::GetFavicon(
479 const GURL& icon_url, 479 const GURL& icon_url,
480 history::IconType icon_type, 480 history::IconType icon_type,
481 CancelableRequestConsumerBase* consumer, 481 CancelableRequestConsumerBase* consumer,
482 const FaviconService::FaviconResultsCallback& callback) { 482 const FaviconService::FaviconResultsCallback& callback) {
483 GetFaviconService()->GetFavicon(icon_url, icon_type, preferred_icon_size(), 483 GetFaviconService()->GetFavicon(icon_url, icon_type, preferred_icon_size(),
484 consumer, callback); 484 ui::GetSupportedScaleFactors(), consumer, callback);
485 } 485 }
486 486
487 void FaviconHandler::GetFaviconForURL( 487 void FaviconHandler::GetFaviconForURL(
488 const GURL& page_url, 488 const GURL& page_url,
489 int icon_types, 489 int icon_types,
490 CancelableRequestConsumerBase* consumer, 490 CancelableRequestConsumerBase* consumer,
491 const FaviconService::FaviconResultsCallback& callback) { 491 const FaviconService::FaviconResultsCallback& callback) {
492 GetFaviconService()->GetFaviconForURL( 492 GetFaviconService()->GetFaviconForURL(
493 FaviconService::FaviconForURLParams(profile_, page_url, icon_types, 493 FaviconService::FaviconForURLParams(profile_, page_url, icon_types,
494 preferred_icon_size(), consumer), 494 preferred_icon_size(), consumer),
495 callback); 495 ui::GetSupportedScaleFactors(), callback);
496 } 496 }
497 497
498 void FaviconHandler::SetHistoryFavicons(const GURL& page_url, 498 void FaviconHandler::SetHistoryFavicons(const GURL& page_url,
499 const GURL& icon_url, 499 const GURL& icon_url,
500 history::IconType icon_type, 500 history::IconType icon_type,
501 const gfx::Image& image) { 501 const gfx::Image& image) {
502 GetFaviconService()->SetFavicons(page_url, icon_url, icon_type, image); 502 GetFaviconService()->SetFavicons(page_url, icon_url, icon_type, image);
503 } 503 }
504 504
505 bool FaviconHandler::ShouldSaveFavicon(const GURL& url) { 505 bool FaviconHandler::ShouldSaveFavicon(const GURL& url) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 const int download_id = DownloadFavicon(image_url, image_size); 644 const int download_id = DownloadFavicon(image_url, image_size);
645 if (download_id) { 645 if (download_id) {
646 // Download ids should be unique. 646 // Download ids should be unique.
647 DCHECK(download_requests_.find(download_id) == download_requests_.end()); 647 DCHECK(download_requests_.find(download_id) == download_requests_.end());
648 download_requests_[download_id] = 648 download_requests_[download_id] =
649 DownloadRequest(url, image_url, callback, icon_type); 649 DownloadRequest(url, image_url, callback, icon_type);
650 } 650 }
651 651
652 return download_id; 652 return download_id;
653 } 653 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_web_ui.cc ('k') | chrome/browser/favicon/favicon_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698