OLD | NEW |
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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
15 #include "chrome/browser/favicon/favicon_service_factory.h" | 15 #include "chrome/browser/favicon/favicon_service_factory.h" |
16 #include "chrome/browser/favicon/favicon_util.h" | 16 #include "chrome/browser/favicon/favicon_util.h" |
17 #include "components/favicon_base/select_favicon_frames.h" | 17 #include "components/favicon_base/select_favicon_frames.h" |
18 #include "content/public/browser/favicon_status.h" | |
19 #include "content/public/browser/navigation_entry.h" | |
20 #include "skia/ext/image_operations.h" | 18 #include "skia/ext/image_operations.h" |
21 #include "ui/gfx/codec/png_codec.h" | 19 #include "ui/gfx/codec/png_codec.h" |
22 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
23 #include "ui/gfx/image/image_skia.h" | 21 #include "ui/gfx/image/image_skia.h" |
24 #include "ui/gfx/image/image_util.h" | 22 #include "ui/gfx/image/image_util.h" |
25 | 23 |
26 using content::FaviconURL; | 24 using content::FaviconURL; |
27 using content::NavigationEntry; | |
28 | 25 |
29 namespace { | 26 namespace { |
30 | 27 |
31 // Size (along each axis) of a touch icon. This currently corresponds to | 28 // Size (along each axis) of a touch icon. This currently corresponds to |
32 // the apple touch icon for iPad. | 29 // the apple touch icon for iPad. |
33 const int kTouchIconSize = 144; | 30 const int kTouchIconSize = 144; |
34 | 31 |
35 // Returns favicon_base::IconType the given icon_type corresponds to. | 32 // Returns favicon_base::IconType the given icon_type corresponds to. |
36 favicon_base::IconType ToChromeIconType(FaviconURL::IconType icon_type) { | 33 favicon_base::IconType ToChromeIconType(FaviconURL::IconType icon_type) { |
37 switch (icon_type) { | 34 switch (icon_type) { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 318 } |
322 | 319 |
323 void FaviconHandler::SetFavicon(const GURL& url, | 320 void FaviconHandler::SetFavicon(const GURL& url, |
324 const GURL& icon_url, | 321 const GURL& icon_url, |
325 const gfx::Image& image, | 322 const gfx::Image& image, |
326 favicon_base::IconType icon_type) { | 323 favicon_base::IconType icon_type) { |
327 if (client_->GetFaviconService() && ShouldSaveFavicon(url)) | 324 if (client_->GetFaviconService() && ShouldSaveFavicon(url)) |
328 SetHistoryFavicons(url, icon_url, icon_type, image); | 325 SetHistoryFavicons(url, icon_url, icon_type, image); |
329 | 326 |
330 if (UrlMatches(url, url_) && icon_type == favicon_base::FAVICON) { | 327 if (UrlMatches(url, url_) && icon_type == favicon_base::FAVICON) { |
331 NavigationEntry* entry = GetEntry(); | 328 if (!PageChangedSinceFaviconWasRequested()) |
332 if (entry) | 329 SetFaviconOnNavigationEntry(icon_url, image); |
333 SetFaviconOnNavigationEntry(entry, icon_url, image); | |
334 } | 330 } |
335 } | 331 } |
336 | 332 |
337 void FaviconHandler::SetFaviconOnNavigationEntry( | 333 void FaviconHandler::SetFaviconOnNavigationEntry( |
338 NavigationEntry* entry, | |
339 const std::vector<favicon_base::FaviconBitmapResult>& | 334 const std::vector<favicon_base::FaviconBitmapResult>& |
340 favicon_bitmap_results) { | 335 favicon_bitmap_results) { |
341 gfx::Image resized_image = FaviconUtil::SelectFaviconFramesFromPNGs( | 336 gfx::Image resized_image = FaviconUtil::SelectFaviconFramesFromPNGs( |
342 favicon_bitmap_results, | 337 favicon_bitmap_results, |
343 FaviconUtil::GetFaviconScaleFactors(), | 338 FaviconUtil::GetFaviconScaleFactors(), |
344 preferred_icon_size()); | 339 preferred_icon_size()); |
345 // The history service sends back results for a single icon URL, so it does | 340 // The history service sends back results for a single icon URL, so it does |
346 // not matter which result we get the |icon_url| from. | 341 // not matter which result we get the |icon_url| from. |
347 const GURL icon_url = favicon_bitmap_results.empty() ? | 342 const GURL icon_url = favicon_bitmap_results.empty() ? |
348 GURL() : favicon_bitmap_results[0].icon_url; | 343 GURL() : favicon_bitmap_results[0].icon_url; |
349 SetFaviconOnNavigationEntry(entry, icon_url, resized_image); | 344 SetFaviconOnNavigationEntry(icon_url, resized_image); |
350 } | 345 } |
351 | 346 |
352 void FaviconHandler::SetFaviconOnNavigationEntry( | 347 void FaviconHandler::SetFaviconOnNavigationEntry( |
353 NavigationEntry* entry, | |
354 const GURL& icon_url, | 348 const GURL& icon_url, |
355 const gfx::Image& image) { | 349 const gfx::Image& image) { |
356 // No matter what happens, we need to mark the favicon as being set. | 350 // No matter what happens, we need to mark the favicon as being set. |
357 entry->GetFavicon().valid = true; | 351 driver_->SetActiveFaviconValidity(true); |
358 | 352 |
359 bool icon_url_changed = (entry->GetFavicon().url != icon_url); | 353 bool icon_url_changed = driver_->GetActiveFaviconURL() != icon_url; |
360 entry->GetFavicon().url = icon_url; | 354 driver_->SetActiveFaviconURL(icon_url); |
361 | 355 |
362 if (image.IsEmpty()) | 356 if (image.IsEmpty()) |
363 return; | 357 return; |
364 | 358 |
365 gfx::Image image_with_adjusted_colorspace = image; | 359 gfx::Image image_with_adjusted_colorspace = image; |
366 FaviconUtil::SetFaviconColorSpace(&image_with_adjusted_colorspace); | 360 FaviconUtil::SetFaviconColorSpace(&image_with_adjusted_colorspace); |
367 | 361 |
368 entry->GetFavicon().image = image_with_adjusted_colorspace; | 362 driver_->SetActiveFaviconImage(image_with_adjusted_colorspace); |
369 NotifyFaviconUpdated(icon_url_changed); | 363 NotifyFaviconUpdated(icon_url_changed); |
370 } | 364 } |
371 | 365 |
372 void FaviconHandler::OnUpdateFaviconURL( | 366 void FaviconHandler::OnUpdateFaviconURL( |
373 const std::vector<FaviconURL>& candidates) { | 367 const std::vector<FaviconURL>& candidates) { |
374 image_urls_.clear(); | 368 image_urls_.clear(); |
375 best_favicon_candidate_ = FaviconCandidate(); | 369 best_favicon_candidate_ = FaviconCandidate(); |
376 for (std::vector<FaviconURL>::const_iterator i = candidates.begin(); | 370 for (std::vector<FaviconURL>::const_iterator i = candidates.begin(); |
377 i != candidates.end(); ++i) { | 371 i != candidates.end(); ++i) { |
378 if (!i->icon_url.is_empty() && (i->icon_type & icon_types_)) | 372 if (!i->icon_url.is_empty() && (i->icon_type & icon_types_)) |
(...skipping 10 matching lines...) Expand all Loading... |
389 | 383 |
390 if (download_largest_icon_) | 384 if (download_largest_icon_) |
391 SortAndPruneImageUrls(); | 385 SortAndPruneImageUrls(); |
392 | 386 |
393 ProcessCurrentUrl(); | 387 ProcessCurrentUrl(); |
394 } | 388 } |
395 | 389 |
396 void FaviconHandler::ProcessCurrentUrl() { | 390 void FaviconHandler::ProcessCurrentUrl() { |
397 DCHECK(!image_urls_.empty()); | 391 DCHECK(!image_urls_.empty()); |
398 | 392 |
399 NavigationEntry* entry = GetEntry(); | |
400 | |
401 // current_candidate() may return NULL if download_largest_icon_ is true and | 393 // current_candidate() may return NULL if download_largest_icon_ is true and |
402 // all the sizes are larger than the max. | 394 // all the sizes are larger than the max. |
403 if (!entry || !current_candidate()) | 395 if (PageChangedSinceFaviconWasRequested() || !current_candidate()) |
404 return; | 396 return; |
405 | 397 |
406 if (current_candidate()->icon_type == FaviconURL::FAVICON) { | 398 if (current_candidate()->icon_type == FaviconURL::FAVICON) { |
407 if (!favicon_expired_or_incomplete_ && entry->GetFavicon().valid && | 399 if (!favicon_expired_or_incomplete_ && |
| 400 driver_->GetActiveFaviconValidity() && |
408 DoUrlAndIconMatch(*current_candidate(), | 401 DoUrlAndIconMatch(*current_candidate(), |
409 entry->GetFavicon().url, | 402 driver_->GetActiveFaviconURL(), |
410 favicon_base::FAVICON)) | 403 favicon_base::FAVICON)) |
411 return; | 404 return; |
412 } else if (!favicon_expired_or_incomplete_ && got_favicon_from_history_ && | 405 } else if (!favicon_expired_or_incomplete_ && got_favicon_from_history_ && |
413 HasValidResult(history_results_) && | 406 HasValidResult(history_results_) && |
414 DoUrlsAndIconsMatch(*current_candidate(), history_results_)) { | 407 DoUrlsAndIconsMatch(*current_candidate(), history_results_)) { |
415 return; | 408 return; |
416 } | 409 } |
417 | 410 |
418 if (got_favicon_from_history_) | 411 if (got_favicon_from_history_) |
419 DownloadFaviconOrAskFaviconService( | 412 DownloadFaviconOrAskFaviconService( |
420 entry->GetURL(), current_candidate()->icon_url, | 413 driver_->GetActiveURL(), |
| 414 current_candidate()->icon_url, |
421 ToChromeIconType(current_candidate()->icon_type)); | 415 ToChromeIconType(current_candidate()->icon_type)); |
422 } | 416 } |
423 | 417 |
424 void FaviconHandler::OnDidDownloadFavicon( | 418 void FaviconHandler::OnDidDownloadFavicon( |
425 int id, | 419 int id, |
426 const GURL& image_url, | 420 const GURL& image_url, |
427 const std::vector<SkBitmap>& bitmaps, | 421 const std::vector<SkBitmap>& bitmaps, |
428 const std::vector<gfx::Size>& original_bitmap_sizes) { | 422 const std::vector<gfx::Size>& original_bitmap_sizes) { |
429 DownloadRequests::iterator i = download_requests_.find(id); | 423 DownloadRequests::iterator i = download_requests_.find(id); |
430 if (i == download_requests_.end()) { | 424 if (i == download_requests_.end()) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 | 461 |
468 if (!image_skia.isNull()) { | 462 if (!image_skia.isNull()) { |
469 gfx::Image image(image_skia); | 463 gfx::Image image(image_skia); |
470 // The downloaded icon is still valid when there is no FaviconURL update | 464 // The downloaded icon is still valid when there is no FaviconURL update |
471 // during the downloading. | 465 // during the downloading. |
472 if (!bitmaps.empty()) { | 466 if (!bitmaps.empty()) { |
473 request_next_icon = !UpdateFaviconCandidate( | 467 request_next_icon = !UpdateFaviconCandidate( |
474 i->second.url, image_url, image, score, i->second.icon_type); | 468 i->second.url, image_url, image, score, i->second.icon_type); |
475 } | 469 } |
476 } | 470 } |
477 if (request_next_icon && GetEntry() && image_urls_.size() > 1) { | 471 if (request_next_icon && !PageChangedSinceFaviconWasRequested() && |
| 472 image_urls_.size() > 1) { |
478 // Remove the first member of image_urls_ and process the remaining. | 473 // Remove the first member of image_urls_ and process the remaining. |
479 image_urls_.erase(image_urls_.begin()); | 474 image_urls_.erase(image_urls_.begin()); |
480 ProcessCurrentUrl(); | 475 ProcessCurrentUrl(); |
481 } else if (best_favicon_candidate_.icon_type != | 476 } else if (best_favicon_candidate_.icon_type != |
482 favicon_base::INVALID_ICON) { | 477 favicon_base::INVALID_ICON) { |
483 // No more icons to request, set the favicon from the candidate. | 478 // No more icons to request, set the favicon from the candidate. |
484 SetFavicon(best_favicon_candidate_.url, | 479 SetFavicon(best_favicon_candidate_.url, |
485 best_favicon_candidate_.image_url, | 480 best_favicon_candidate_.image_url, |
486 best_favicon_candidate_.image, | 481 best_favicon_candidate_.image, |
487 best_favicon_candidate_.icon_type); | 482 best_favicon_candidate_.icon_type); |
488 // Reset candidate. | 483 // Reset candidate. |
489 image_urls_.clear(); | 484 image_urls_.clear(); |
490 best_favicon_candidate_ = FaviconCandidate(); | 485 best_favicon_candidate_ = FaviconCandidate(); |
491 } | 486 } |
492 } | 487 } |
493 download_requests_.erase(i); | 488 download_requests_.erase(i); |
494 } | 489 } |
495 | 490 |
496 NavigationEntry* FaviconHandler::GetEntry() { | 491 bool FaviconHandler::PageChangedSinceFaviconWasRequested() { |
497 NavigationEntry* entry = driver_->GetActiveEntry(); | 492 if (UrlMatches(driver_->GetActiveURL(), url_) && url_.is_valid()) { |
498 if (entry && UrlMatches(entry->GetURL(), url_)) | 493 return false; |
499 return entry; | 494 } |
500 | |
501 // If the URL has changed out from under us (as will happen with redirects) | 495 // If the URL has changed out from under us (as will happen with redirects) |
502 // return NULL. | 496 // return true. |
503 return NULL; | 497 return true; |
504 } | 498 } |
505 | 499 |
506 int FaviconHandler::DownloadFavicon(const GURL& image_url, | 500 int FaviconHandler::DownloadFavicon(const GURL& image_url, |
507 int max_bitmap_size) { | 501 int max_bitmap_size) { |
508 if (!image_url.is_valid()) { | 502 if (!image_url.is_valid()) { |
509 NOTREACHED(); | 503 NOTREACHED(); |
510 return 0; | 504 return 0; |
511 } | 505 } |
512 return driver_->StartDownload(image_url, max_bitmap_size); | 506 return driver_->StartDownload(image_url, max_bitmap_size); |
513 } | 507 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 return client_->IsBookmarked(url); | 557 return client_->IsBookmarked(url); |
564 } | 558 } |
565 | 559 |
566 void FaviconHandler::NotifyFaviconUpdated(bool icon_url_changed) { | 560 void FaviconHandler::NotifyFaviconUpdated(bool icon_url_changed) { |
567 driver_->NotifyFaviconUpdated(icon_url_changed); | 561 driver_->NotifyFaviconUpdated(icon_url_changed); |
568 } | 562 } |
569 | 563 |
570 void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService( | 564 void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService( |
571 const std::vector<favicon_base::FaviconBitmapResult>& | 565 const std::vector<favicon_base::FaviconBitmapResult>& |
572 favicon_bitmap_results) { | 566 favicon_bitmap_results) { |
573 NavigationEntry* entry = GetEntry(); | 567 if (PageChangedSinceFaviconWasRequested()) |
574 if (!entry) | |
575 return; | 568 return; |
576 | |
577 got_favicon_from_history_ = true; | 569 got_favicon_from_history_ = true; |
578 history_results_ = favicon_bitmap_results; | 570 history_results_ = favicon_bitmap_results; |
579 | |
580 bool has_results = !favicon_bitmap_results.empty(); | 571 bool has_results = !favicon_bitmap_results.empty(); |
581 favicon_expired_or_incomplete_ = has_results && HasExpiredOrIncompleteResult( | 572 favicon_expired_or_incomplete_ = has_results && HasExpiredOrIncompleteResult( |
582 preferred_icon_size(), favicon_bitmap_results); | 573 preferred_icon_size(), favicon_bitmap_results); |
583 | |
584 if (has_results && icon_types_ == favicon_base::FAVICON && | 574 if (has_results && icon_types_ == favicon_base::FAVICON && |
585 !entry->GetFavicon().valid && | 575 !driver_->GetActiveFaviconValidity() && |
586 (!current_candidate() || | 576 (!current_candidate() || |
587 DoUrlsAndIconsMatch(*current_candidate(), favicon_bitmap_results))) { | 577 DoUrlsAndIconsMatch(*current_candidate(), favicon_bitmap_results))) { |
588 if (HasValidResult(favicon_bitmap_results)) { | 578 if (HasValidResult(favicon_bitmap_results)) { |
589 // The db knows the favicon (although it may be out of date) and the entry | 579 // The db knows the favicon (although it may be out of date) and the entry |
590 // doesn't have an icon. Set the favicon now, and if the favicon turns out | 580 // doesn't have an icon. Set the favicon now, and if the favicon turns out |
591 // to be expired (or the wrong url) we'll fetch later on. This way the | 581 // to be expired (or the wrong url) we'll fetch later on. This way the |
592 // user doesn't see a flash of the default favicon. | 582 // user doesn't see a flash of the default favicon. |
593 SetFaviconOnNavigationEntry(entry, favicon_bitmap_results); | 583 SetFaviconOnNavigationEntry(favicon_bitmap_results); |
594 } else { | 584 } else { |
595 // If |favicon_bitmap_results| does not have any valid results, treat the | 585 // If |favicon_bitmap_results| does not have any valid results, treat the |
596 // favicon as if it's expired. | 586 // favicon as if it's expired. |
597 // TODO(pkotwicz): Do something better. | 587 // TODO(pkotwicz): Do something better. |
598 favicon_expired_or_incomplete_ = true; | 588 favicon_expired_or_incomplete_ = true; |
599 } | 589 } |
600 } | 590 } |
601 | |
602 if (has_results && !favicon_expired_or_incomplete_) { | 591 if (has_results && !favicon_expired_or_incomplete_) { |
603 if (current_candidate() && | 592 if (current_candidate() && |
604 !DoUrlsAndIconsMatch(*current_candidate(), favicon_bitmap_results)) { | 593 !DoUrlsAndIconsMatch(*current_candidate(), favicon_bitmap_results)) { |
605 // Mapping in the database is wrong. DownloadFavIconOrAskHistory will | 594 // Mapping in the database is wrong. DownloadFavIconOrAskHistory will |
606 // update the mapping for this url and download the favicon if we don't | 595 // update the mapping for this url and download the favicon if we don't |
607 // already have it. | 596 // already have it. |
608 DownloadFaviconOrAskFaviconService( | 597 DownloadFaviconOrAskFaviconService( |
609 entry->GetURL(), current_candidate()->icon_url, | 598 driver_->GetActiveURL(), |
| 599 current_candidate()->icon_url, |
610 ToChromeIconType(current_candidate()->icon_type)); | 600 ToChromeIconType(current_candidate()->icon_type)); |
611 } | 601 } |
612 } else if (current_candidate()) { | 602 } else if (current_candidate()) { |
613 // We know the official url for the favicon, but either don't have the | 603 // We know the official url for the favicon, but either don't have the |
614 // favicon or it's expired. Continue on to DownloadFaviconOrAskHistory to | 604 // favicon or it's expired. Continue on to DownloadFaviconOrAskHistory to |
615 // either download or check history again. | 605 // either download or check history again. |
616 DownloadFaviconOrAskFaviconService( | 606 DownloadFaviconOrAskFaviconService( |
617 entry->GetURL(), current_candidate()->icon_url, | 607 driver_->GetActiveURL(), |
| 608 current_candidate()->icon_url, |
618 ToChromeIconType(current_candidate()->icon_type)); | 609 ToChromeIconType(current_candidate()->icon_type)); |
619 } | 610 } |
620 // else we haven't got the icon url. When we get it we'll ask the | 611 // else we haven't got the icon url. When we get it we'll ask the |
621 // renderer to download the icon. | 612 // renderer to download the icon. |
622 } | 613 } |
623 | 614 |
624 void FaviconHandler::DownloadFaviconOrAskFaviconService( | 615 void FaviconHandler::DownloadFaviconOrAskFaviconService( |
625 const GURL& page_url, | 616 const GURL& page_url, |
626 const GURL& icon_url, | 617 const GURL& icon_url, |
627 favicon_base::IconType icon_type) { | 618 favicon_base::IconType icon_type) { |
(...skipping 18 matching lines...) Expand all Loading... |
646 UpdateFaviconMappingAndFetch( | 637 UpdateFaviconMappingAndFetch( |
647 page_url, icon_url, icon_type, | 638 page_url, icon_url, icon_type, |
648 base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)), | 639 base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)), |
649 &cancelable_task_tracker_); | 640 &cancelable_task_tracker_); |
650 } | 641 } |
651 } | 642 } |
652 } | 643 } |
653 | 644 |
654 void FaviconHandler::OnFaviconData(const std::vector< | 645 void FaviconHandler::OnFaviconData(const std::vector< |
655 favicon_base::FaviconBitmapResult>& favicon_bitmap_results) { | 646 favicon_base::FaviconBitmapResult>& favicon_bitmap_results) { |
656 NavigationEntry* entry = GetEntry(); | 647 if (PageChangedSinceFaviconWasRequested()) |
657 if (!entry) | |
658 return; | 648 return; |
659 | 649 |
660 bool has_results = !favicon_bitmap_results.empty(); | 650 bool has_results = !favicon_bitmap_results.empty(); |
661 bool has_expired_or_incomplete_result = HasExpiredOrIncompleteResult( | 651 bool has_expired_or_incomplete_result = HasExpiredOrIncompleteResult( |
662 preferred_icon_size(), favicon_bitmap_results); | 652 preferred_icon_size(), favicon_bitmap_results); |
663 | 653 |
664 if (has_results && icon_types_ == favicon_base::FAVICON) { | 654 if (has_results && icon_types_ == favicon_base::FAVICON) { |
665 if (HasValidResult(favicon_bitmap_results)) { | 655 if (HasValidResult(favicon_bitmap_results)) { |
666 // There is a favicon, set it now. If expired we'll download the current | 656 // There is a favicon, set it now. If expired we'll download the current |
667 // one again, but at least the user will get some icon instead of the | 657 // one again, but at least the user will get some icon instead of the |
668 // default and most likely the current one is fine anyway. | 658 // default and most likely the current one is fine anyway. |
669 SetFaviconOnNavigationEntry(entry, favicon_bitmap_results); | 659 SetFaviconOnNavigationEntry(favicon_bitmap_results); |
670 } | 660 } |
671 if (has_expired_or_incomplete_result) { | 661 if (has_expired_or_incomplete_result) { |
672 // The favicon is out of date. Request the current one. | 662 // The favicon is out of date. Request the current one. |
673 ScheduleDownload( | 663 ScheduleDownload(driver_->GetActiveURL(), |
674 entry->GetURL(), entry->GetFavicon().url, favicon_base::FAVICON); | 664 driver_->GetActiveFaviconURL(), |
| 665 favicon_base::FAVICON); |
675 } | 666 } |
676 } else if (current_candidate() && | 667 } else if (current_candidate() && |
677 (!has_results || has_expired_or_incomplete_result || | 668 (!has_results || has_expired_or_incomplete_result || |
678 !(DoUrlsAndIconsMatch(*current_candidate(), favicon_bitmap_results)))) { | 669 !(DoUrlsAndIconsMatch(*current_candidate(), favicon_bitmap_results)))) { |
679 // We don't know the favicon, it is out of date or its type is not same as | 670 // We don't know the favicon, it is out of date or its type is not same as |
680 // one got from page. Request the current one. | 671 // one got from page. Request the current one. |
681 ScheduleDownload(entry->GetURL(), current_candidate()->icon_url, | 672 ScheduleDownload(driver_->GetActiveURL(), |
| 673 current_candidate()->icon_url, |
682 ToChromeIconType(current_candidate()->icon_type)); | 674 ToChromeIconType(current_candidate()->icon_type)); |
683 } | 675 } |
684 history_results_ = favicon_bitmap_results; | 676 history_results_ = favicon_bitmap_results; |
685 } | 677 } |
686 | 678 |
687 int FaviconHandler::ScheduleDownload(const GURL& url, | 679 int FaviconHandler::ScheduleDownload(const GURL& url, |
688 const GURL& image_url, | 680 const GURL& image_url, |
689 favicon_base::IconType icon_type) { | 681 favicon_base::IconType icon_type) { |
690 // A max bitmap size is specified to avoid receiving huge bitmaps in | 682 // A max bitmap size is specified to avoid receiving huge bitmaps in |
691 // OnDidDownloadFavicon(). See FaviconDriver::StartDownload() | 683 // OnDidDownloadFavicon(). See FaviconDriver::StartDownload() |
(...skipping 24 matching lines...) Expand all Loading... |
716 } else { | 708 } else { |
717 gfx::Size largest = i->icon_sizes[index]; | 709 gfx::Size largest = i->icon_sizes[index]; |
718 i->icon_sizes.clear(); | 710 i->icon_sizes.clear(); |
719 i->icon_sizes.push_back(largest); | 711 i->icon_sizes.push_back(largest); |
720 ++i; | 712 ++i; |
721 } | 713 } |
722 } | 714 } |
723 std::stable_sort(image_urls_.begin(), image_urls_.end(), | 715 std::stable_sort(image_urls_.begin(), image_urls_.end(), |
724 CompareIconSize); | 716 CompareIconSize); |
725 } | 717 } |
OLD | NEW |