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

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

Issue 10821035: wip Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 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 <vector> 9 #include <vector>
10 10
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 if (favicon.known_icon && favicon.icon_type == history::FAVICON && 409 if (favicon.known_icon && favicon.icon_type == history::FAVICON &&
410 !entry->GetFavicon().valid && 410 !entry->GetFavicon().valid &&
411 (!current_candidate() || 411 (!current_candidate() ||
412 DoUrlAndIconMatch( 412 DoUrlAndIconMatch(
413 *current_candidate(), favicon.icon_url, favicon.icon_type))) { 413 *current_candidate(), favicon.icon_url, favicon.icon_type))) {
414 // The db knows the favicon (although it may be out of date) and the entry 414 // The db knows the favicon (although it may be out of date) and the entry
415 // doesn't have an icon. Set the favicon now, and if the favicon turns out 415 // doesn't have an icon. Set the favicon now, and if the favicon turns out
416 // to be expired (or the wrong url) we'll fetch later on. This way the 416 // to be expired (or the wrong url) we'll fetch later on. This way the
417 // user doesn't see a flash of the default favicon. 417 // user doesn't see a flash of the default favicon.
418 entry->GetFavicon().url = favicon.icon_url; 418 entry->GetFavicon().url = favicon.icon_url;
419 if (favicon.is_valid()) 419 if (favicon.is_valid() && favicon.variants.size() > 0)
420 UpdateFavicon(entry, favicon.bitmap_data); 420 UpdateFavicon(entry, favicon.variants[0].bitmap_data); // XXX pass all va riants
421 entry->GetFavicon().valid = true; 421 entry->GetFavicon().valid = true;
422 } 422 }
423 423
424 if (favicon.known_icon && !favicon.expired) { 424 if (favicon.known_icon && !favicon.expired) {
425 if (current_candidate() && 425 if (current_candidate() &&
426 !DoUrlAndIconMatch( 426 !DoUrlAndIconMatch(
427 *current_candidate(), favicon.icon_url, favicon.icon_type)) { 427 *current_candidate(), favicon.icon_url, favicon.icon_type)) {
428 // Mapping in the database is wrong. DownloadFavIconOrAskHistory will 428 // Mapping in the database is wrong. DownloadFavIconOrAskHistory will
429 // update the mapping for this url and download the favicon if we don't 429 // update the mapping for this url and download the favicon if we don't
430 // already have it. 430 // already have it.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 474
475 void FaviconHandler::OnFaviconData(FaviconService::Handle handle, 475 void FaviconHandler::OnFaviconData(FaviconService::Handle handle,
476 history::FaviconData favicon) { 476 history::FaviconData favicon) {
477 NavigationEntry* entry = GetEntry(); 477 NavigationEntry* entry = GetEntry();
478 if (!entry) 478 if (!entry)
479 return; 479 return;
480 480
481 // No need to update the favicon url. By the time we get here 481 // No need to update the favicon url. By the time we get here
482 // UpdateFaviconURL will have set the favicon url. 482 // UpdateFaviconURL will have set the favicon url.
483 if (favicon.icon_type == history::FAVICON) { 483 if (favicon.icon_type == history::FAVICON) {
484 if (favicon.is_valid()) { 484 if (favicon.is_valid() && favicon.variants.size() > 0) {
485 // There is a favicon, set it now. If expired we'll download the current 485 // There is a favicon, set it now. If expired we'll download the current
486 // one again, but at least the user will get some icon instead of the 486 // one again, but at least the user will get some icon instead of the
487 // default and most likely the current one is fine anyway. 487 // default and most likely the current one is fine anyway.
488 UpdateFavicon(entry, favicon.bitmap_data); 488 UpdateFavicon(entry, favicon.variants[0].bitmap_data); // XXX all
489 } 489 }
490 if (!favicon.known_icon || favicon.expired) { 490 if (!favicon.known_icon || favicon.expired) {
491 // We don't know the favicon, or it is out of date. Request the current 491 // We don't know the favicon, or it is out of date. Request the current
492 // one. 492 // one.
493 ScheduleDownload(entry->GetURL(), entry->GetFavicon().url, 493 ScheduleDownload(entry->GetURL(), entry->GetFavicon().url,
494 preferred_icon_size(), 494 preferred_icon_size(),
495 history::FAVICON, 495 history::FAVICON,
496 FaviconTabHelper::ImageDownloadCallback()); 496 FaviconTabHelper::ImageDownloadCallback());
497 } 497 }
498 } else if (current_candidate() && (!favicon.known_icon || favicon.expired || 498 } else if (current_candidate() && (!favicon.known_icon || favicon.expired ||
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 int height = bitmap.height(); 532 int height = bitmap.height();
533 if (width > 0 && height > 0) { 533 if (width > 0 && height > 0) {
534 gfx::CalculateFaviconTargetSize(&width, &height); 534 gfx::CalculateFaviconTargetSize(&width, &height);
535 return gfx::Image(skia::ImageOperations::Resize( 535 return gfx::Image(skia::ImageOperations::Resize(
536 bitmap, skia::ImageOperations::RESIZE_LANCZOS3, 536 bitmap, skia::ImageOperations::RESIZE_LANCZOS3,
537 width, height)); 537 width, height));
538 } 538 }
539 539
540 return image; 540 return image;
541 } 541 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_web_ui.cc ('k') | chrome/browser/favicon/favicon_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698