Chromium Code Reviews| 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> |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 } | 321 } |
| 322 | 322 |
| 323 void FaviconHandler::SetFavicon(const GURL& url, | 323 void FaviconHandler::SetFavicon(const GURL& url, |
| 324 const GURL& icon_url, | 324 const GURL& icon_url, |
| 325 const gfx::Image& image, | 325 const gfx::Image& image, |
| 326 favicon_base::IconType icon_type) { | 326 favicon_base::IconType icon_type) { |
| 327 if (client_->GetFaviconService() && ShouldSaveFavicon(url)) | 327 if (client_->GetFaviconService() && ShouldSaveFavicon(url)) |
| 328 SetHistoryFavicons(url, icon_url, icon_type, image); | 328 SetHistoryFavicons(url, icon_url, icon_type, image); |
| 329 | 329 |
| 330 if (UrlMatches(url, url_) && icon_type == favicon_base::FAVICON) { | 330 if (UrlMatches(url, url_) && icon_type == favicon_base::FAVICON) { |
| 331 NavigationEntry* entry = GetEntry(); | 331 if (NavigationEntryConcernsFavicon()) |
| 332 if (entry) | 332 SetFaviconOnNavigationEntry(icon_url, image); |
| 333 SetFaviconOnNavigationEntry(entry, icon_url, image); | |
| 334 } | 333 } |
| 335 } | 334 } |
| 336 | 335 |
| 337 void FaviconHandler::SetFaviconOnNavigationEntry( | 336 void FaviconHandler::SetFaviconOnNavigationEntry( |
| 338 NavigationEntry* entry, | |
| 339 const std::vector<favicon_base::FaviconBitmapResult>& | 337 const std::vector<favicon_base::FaviconBitmapResult>& |
| 340 favicon_bitmap_results) { | 338 favicon_bitmap_results) { |
| 341 gfx::Image resized_image = FaviconUtil::SelectFaviconFramesFromPNGs( | 339 gfx::Image resized_image = FaviconUtil::SelectFaviconFramesFromPNGs( |
| 342 favicon_bitmap_results, | 340 favicon_bitmap_results, |
| 343 FaviconUtil::GetFaviconScaleFactors(), | 341 FaviconUtil::GetFaviconScaleFactors(), |
| 344 preferred_icon_size()); | 342 preferred_icon_size()); |
| 345 // The history service sends back results for a single icon URL, so it does | 343 // 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. | 344 // not matter which result we get the |icon_url| from. |
| 347 const GURL icon_url = favicon_bitmap_results.empty() ? | 345 const GURL icon_url = favicon_bitmap_results.empty() ? |
| 348 GURL() : favicon_bitmap_results[0].icon_url; | 346 GURL() : favicon_bitmap_results[0].icon_url; |
| 349 SetFaviconOnNavigationEntry(entry, icon_url, resized_image); | 347 SetFaviconOnNavigationEntry(icon_url, resized_image); |
| 350 } | 348 } |
| 351 | 349 |
| 352 void FaviconHandler::SetFaviconOnNavigationEntry( | 350 void FaviconHandler::SetFaviconOnNavigationEntry( |
| 353 NavigationEntry* entry, | |
| 354 const GURL& icon_url, | 351 const GURL& icon_url, |
| 355 const gfx::Image& image) { | 352 const gfx::Image& image) { |
| 356 // No matter what happens, we need to mark the favicon as being set. | 353 // No matter what happens, we need to mark the favicon as being set. |
| 357 entry->GetFavicon().valid = true; | 354 driver_->SetActiveFaviconValidity(true); |
| 358 | 355 |
| 359 bool icon_url_changed = (entry->GetFavicon().url != icon_url); | 356 bool icon_url_changed = driver_->GetActiveFaviconURL() != icon_url; |
| 360 entry->GetFavicon().url = icon_url; | 357 driver_->SetActiveFaviconURL(icon_url); |
| 361 | 358 |
| 362 if (image.IsEmpty()) | 359 if (image.IsEmpty()) |
| 363 return; | 360 return; |
| 364 | 361 |
| 365 gfx::Image image_with_adjusted_colorspace = image; | 362 gfx::Image image_with_adjusted_colorspace = image; |
| 366 FaviconUtil::SetFaviconColorSpace(&image_with_adjusted_colorspace); | 363 FaviconUtil::SetFaviconColorSpace(&image_with_adjusted_colorspace); |
| 367 | 364 |
| 368 entry->GetFavicon().image = image_with_adjusted_colorspace; | 365 driver_->SetActiveFaviconImage(image_with_adjusted_colorspace); |
| 369 NotifyFaviconUpdated(icon_url_changed); | 366 NotifyFaviconUpdated(icon_url_changed); |
| 370 } | 367 } |
| 371 | 368 |
| 372 void FaviconHandler::OnUpdateFaviconURL( | 369 void FaviconHandler::OnUpdateFaviconURL( |
| 373 const std::vector<FaviconURL>& candidates) { | 370 const std::vector<FaviconURL>& candidates) { |
| 374 image_urls_.clear(); | 371 image_urls_.clear(); |
| 375 best_favicon_candidate_ = FaviconCandidate(); | 372 best_favicon_candidate_ = FaviconCandidate(); |
| 376 for (std::vector<FaviconURL>::const_iterator i = candidates.begin(); | 373 for (std::vector<FaviconURL>::const_iterator i = candidates.begin(); |
| 377 i != candidates.end(); ++i) { | 374 i != candidates.end(); ++i) { |
| 378 if (!i->icon_url.is_empty() && (i->icon_type & icon_types_)) | 375 if (!i->icon_url.is_empty() && (i->icon_type & icon_types_)) |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 389 | 386 |
| 390 if (download_largest_icon_) | 387 if (download_largest_icon_) |
| 391 SortAndPruneImageUrls(); | 388 SortAndPruneImageUrls(); |
| 392 | 389 |
| 393 ProcessCurrentUrl(); | 390 ProcessCurrentUrl(); |
| 394 } | 391 } |
| 395 | 392 |
| 396 void FaviconHandler::ProcessCurrentUrl() { | 393 void FaviconHandler::ProcessCurrentUrl() { |
| 397 DCHECK(!image_urls_.empty()); | 394 DCHECK(!image_urls_.empty()); |
| 398 | 395 |
| 399 NavigationEntry* entry = GetEntry(); | |
| 400 | |
| 401 // current_candidate() may return NULL if download_largest_icon_ is true and | 396 // current_candidate() may return NULL if download_largest_icon_ is true and |
| 402 // all the sizes are larger than the max. | 397 // all the sizes are larger than the max. |
| 403 if (!entry || !current_candidate()) | 398 if (NavigationEntryConcernsFavicon() || !current_candidate()) |
| 404 return; | 399 return; |
| 405 | 400 |
| 406 if (current_candidate()->icon_type == FaviconURL::FAVICON) { | 401 if (current_candidate()->icon_type == FaviconURL::FAVICON) { |
| 407 if (!favicon_expired_or_incomplete_ && entry->GetFavicon().valid && | 402 if (!favicon_expired_or_incomplete_ && |
| 403 driver_->GetActiveFaviconValidity() && | |
|
blundell
2014/05/06 15:04:00
Hmm, maybe these would all read better as "FooForC
jif
2014/05/09 14:17:18
Done.
| |
| 408 DoUrlAndIconMatch(*current_candidate(), | 404 DoUrlAndIconMatch(*current_candidate(), |
| 409 entry->GetFavicon().url, | 405 driver_->GetActiveFaviconURL(), |
| 410 favicon_base::FAVICON)) | 406 favicon_base::FAVICON)) |
| 411 return; | 407 return; |
| 412 } else if (!favicon_expired_or_incomplete_ && got_favicon_from_history_ && | 408 } else if (!favicon_expired_or_incomplete_ && got_favicon_from_history_ && |
| 413 HasValidResult(history_results_) && | 409 HasValidResult(history_results_) && |
| 414 DoUrlsAndIconsMatch(*current_candidate(), history_results_)) { | 410 DoUrlsAndIconsMatch(*current_candidate(), history_results_)) { |
| 415 return; | 411 return; |
| 416 } | 412 } |
| 417 | 413 |
| 418 if (got_favicon_from_history_) | 414 if (got_favicon_from_history_) |
| 419 DownloadFaviconOrAskFaviconService( | 415 DownloadFaviconOrAskFaviconService( |
| 420 entry->GetURL(), current_candidate()->icon_url, | 416 driver_->GetActiveURL(), |
| 417 current_candidate()->icon_url, | |
| 421 ToChromeIconType(current_candidate()->icon_type)); | 418 ToChromeIconType(current_candidate()->icon_type)); |
| 422 } | 419 } |
| 423 | 420 |
| 424 void FaviconHandler::OnDidDownloadFavicon( | 421 void FaviconHandler::OnDidDownloadFavicon( |
| 425 int id, | 422 int id, |
| 426 const GURL& image_url, | 423 const GURL& image_url, |
| 427 const std::vector<SkBitmap>& bitmaps, | 424 const std::vector<SkBitmap>& bitmaps, |
| 428 const std::vector<gfx::Size>& original_bitmap_sizes) { | 425 const std::vector<gfx::Size>& original_bitmap_sizes) { |
| 429 DownloadRequests::iterator i = download_requests_.find(id); | 426 DownloadRequests::iterator i = download_requests_.find(id); |
| 430 if (i == download_requests_.end()) { | 427 if (i == download_requests_.end()) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 467 | 464 |
| 468 if (!image_skia.isNull()) { | 465 if (!image_skia.isNull()) { |
| 469 gfx::Image image(image_skia); | 466 gfx::Image image(image_skia); |
| 470 // The downloaded icon is still valid when there is no FaviconURL update | 467 // The downloaded icon is still valid when there is no FaviconURL update |
| 471 // during the downloading. | 468 // during the downloading. |
| 472 if (!bitmaps.empty()) { | 469 if (!bitmaps.empty()) { |
| 473 request_next_icon = !UpdateFaviconCandidate( | 470 request_next_icon = !UpdateFaviconCandidate( |
| 474 i->second.url, image_url, image, score, i->second.icon_type); | 471 i->second.url, image_url, image, score, i->second.icon_type); |
| 475 } | 472 } |
| 476 } | 473 } |
| 477 if (request_next_icon && GetEntry() && image_urls_.size() > 1) { | 474 if (request_next_icon && NavigationEntryConcernsFavicon() && |
| 475 image_urls_.size() > 1) { | |
| 478 // Remove the first member of image_urls_ and process the remaining. | 476 // Remove the first member of image_urls_ and process the remaining. |
| 479 image_urls_.erase(image_urls_.begin()); | 477 image_urls_.erase(image_urls_.begin()); |
| 480 ProcessCurrentUrl(); | 478 ProcessCurrentUrl(); |
| 481 } else if (best_favicon_candidate_.icon_type != | 479 } else if (best_favicon_candidate_.icon_type != |
| 482 favicon_base::INVALID_ICON) { | 480 favicon_base::INVALID_ICON) { |
| 483 // No more icons to request, set the favicon from the candidate. | 481 // No more icons to request, set the favicon from the candidate. |
| 484 SetFavicon(best_favicon_candidate_.url, | 482 SetFavicon(best_favicon_candidate_.url, |
| 485 best_favicon_candidate_.image_url, | 483 best_favicon_candidate_.image_url, |
| 486 best_favicon_candidate_.image, | 484 best_favicon_candidate_.image, |
| 487 best_favicon_candidate_.icon_type); | 485 best_favicon_candidate_.icon_type); |
| 488 // Reset candidate. | 486 // Reset candidate. |
| 489 image_urls_.clear(); | 487 image_urls_.clear(); |
| 490 best_favicon_candidate_ = FaviconCandidate(); | 488 best_favicon_candidate_ = FaviconCandidate(); |
| 491 } | 489 } |
| 492 } | 490 } |
| 493 download_requests_.erase(i); | 491 download_requests_.erase(i); |
| 494 } | 492 } |
| 495 | 493 |
| 496 NavigationEntry* FaviconHandler::GetEntry() { | 494 bool FaviconHandler::NavigationEntryConcernsFavicon() { |
|
blundell
2014/05/06 15:04:00
I think this is just something like "PageHasChange
jif
2014/05/09 14:17:18
Done.
| |
| 497 NavigationEntry* entry = driver_->GetActiveEntry(); | 495 NavigationEntry* entry = driver_->GetActiveEntry(); |
|
blundell
2014/05/06 15:04:00
Could you get rid of all mentions of NavigationEnt
jif
2014/05/09 14:17:18
Yeah, just wanted to get to a state were it was bu
| |
| 498 if (entry && UrlMatches(entry->GetURL(), url_)) | 496 if (entry && UrlMatches(driver_->GetActiveURL(), url_)) |
| 499 return entry; | 497 return true; |
| 500 | 498 |
| 501 // If the URL has changed out from under us (as will happen with redirects) | 499 // If the URL has changed out from under us (as will happen with redirects) |
| 502 // return NULL. | 500 // return false. |
| 503 return NULL; | 501 return false; |
| 504 } | 502 } |
| 505 | 503 |
| 506 int FaviconHandler::DownloadFavicon(const GURL& image_url, | 504 int FaviconHandler::DownloadFavicon(const GURL& image_url, |
| 507 int max_bitmap_size) { | 505 int max_bitmap_size) { |
| 508 if (!image_url.is_valid()) { | 506 if (!image_url.is_valid()) { |
| 509 NOTREACHED(); | 507 NOTREACHED(); |
| 510 return 0; | 508 return 0; |
| 511 } | 509 } |
| 512 return driver_->StartDownload(image_url, max_bitmap_size); | 510 return driver_->StartDownload(image_url, max_bitmap_size); |
| 513 } | 511 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 563 return client_->IsBookmarked(url); | 561 return client_->IsBookmarked(url); |
| 564 } | 562 } |
| 565 | 563 |
| 566 void FaviconHandler::NotifyFaviconUpdated(bool icon_url_changed) { | 564 void FaviconHandler::NotifyFaviconUpdated(bool icon_url_changed) { |
| 567 driver_->NotifyFaviconUpdated(icon_url_changed); | 565 driver_->NotifyFaviconUpdated(icon_url_changed); |
| 568 } | 566 } |
| 569 | 567 |
| 570 void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService( | 568 void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService( |
| 571 const std::vector<favicon_base::FaviconBitmapResult>& | 569 const std::vector<favicon_base::FaviconBitmapResult>& |
| 572 favicon_bitmap_results) { | 570 favicon_bitmap_results) { |
| 573 NavigationEntry* entry = GetEntry(); | 571 if (!NavigationEntryConcernsFavicon()) |
|
blundell
2014/05/06 15:39:48
This code was previously getting the active Naviga
jam
2014/05/06 18:18:28
yep I don't see how that would change. the nav ent
| |
| 574 if (!entry) | |
| 575 return; | 572 return; |
| 576 | 573 |
| 577 got_favicon_from_history_ = true; | 574 got_favicon_from_history_ = true; |
| 578 history_results_ = favicon_bitmap_results; | 575 history_results_ = favicon_bitmap_results; |
| 579 | 576 |
| 580 bool has_results = !favicon_bitmap_results.empty(); | 577 bool has_results = !favicon_bitmap_results.empty(); |
| 581 favicon_expired_or_incomplete_ = has_results && HasExpiredOrIncompleteResult( | 578 favicon_expired_or_incomplete_ = has_results && HasExpiredOrIncompleteResult( |
| 582 preferred_icon_size(), favicon_bitmap_results); | 579 preferred_icon_size(), favicon_bitmap_results); |
| 583 | 580 |
| 584 if (has_results && icon_types_ == favicon_base::FAVICON && | 581 if (has_results && icon_types_ == favicon_base::FAVICON && |
| 585 !entry->GetFavicon().valid && | 582 !driver_->GetActiveFaviconValidity() && |
| 586 (!current_candidate() || | 583 (!current_candidate() || |
| 587 DoUrlsAndIconsMatch(*current_candidate(), favicon_bitmap_results))) { | 584 DoUrlsAndIconsMatch(*current_candidate(), favicon_bitmap_results))) { |
| 588 if (HasValidResult(favicon_bitmap_results)) { | 585 if (HasValidResult(favicon_bitmap_results)) { |
| 589 // The db knows the favicon (although it may be out of date) and the entry | 586 // 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 | 587 // 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 | 588 // 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. | 589 // user doesn't see a flash of the default favicon. |
| 593 SetFaviconOnNavigationEntry(entry, favicon_bitmap_results); | 590 SetFaviconOnNavigationEntry(favicon_bitmap_results); |
| 594 } else { | 591 } else { |
| 595 // If |favicon_bitmap_results| does not have any valid results, treat the | 592 // If |favicon_bitmap_results| does not have any valid results, treat the |
| 596 // favicon as if it's expired. | 593 // favicon as if it's expired. |
| 597 // TODO(pkotwicz): Do something better. | 594 // TODO(pkotwicz): Do something better. |
| 598 favicon_expired_or_incomplete_ = true; | 595 favicon_expired_or_incomplete_ = true; |
| 599 } | 596 } |
| 600 } | 597 } |
| 601 | 598 |
| 602 if (has_results && !favicon_expired_or_incomplete_) { | 599 if (has_results && !favicon_expired_or_incomplete_) { |
| 603 if (current_candidate() && | 600 if (current_candidate() && |
| 604 !DoUrlsAndIconsMatch(*current_candidate(), favicon_bitmap_results)) { | 601 !DoUrlsAndIconsMatch(*current_candidate(), favicon_bitmap_results)) { |
| 605 // Mapping in the database is wrong. DownloadFavIconOrAskHistory will | 602 // Mapping in the database is wrong. DownloadFavIconOrAskHistory will |
| 606 // update the mapping for this url and download the favicon if we don't | 603 // update the mapping for this url and download the favicon if we don't |
| 607 // already have it. | 604 // already have it. |
| 608 DownloadFaviconOrAskFaviconService( | 605 DownloadFaviconOrAskFaviconService( |
| 609 entry->GetURL(), current_candidate()->icon_url, | 606 driver_->GetActiveURL(), |
| 607 current_candidate()->icon_url, | |
| 610 ToChromeIconType(current_candidate()->icon_type)); | 608 ToChromeIconType(current_candidate()->icon_type)); |
| 611 } | 609 } |
| 612 } else if (current_candidate()) { | 610 } else if (current_candidate()) { |
| 613 // We know the official url for the favicon, but either don't have the | 611 // 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 | 612 // favicon or it's expired. Continue on to DownloadFaviconOrAskHistory to |
| 615 // either download or check history again. | 613 // either download or check history again. |
| 616 DownloadFaviconOrAskFaviconService( | 614 DownloadFaviconOrAskFaviconService( |
| 617 entry->GetURL(), current_candidate()->icon_url, | 615 driver_->GetActiveURL(), |
| 616 current_candidate()->icon_url, | |
| 618 ToChromeIconType(current_candidate()->icon_type)); | 617 ToChromeIconType(current_candidate()->icon_type)); |
| 619 } | 618 } |
| 620 // else we haven't got the icon url. When we get it we'll ask the | 619 // else we haven't got the icon url. When we get it we'll ask the |
| 621 // renderer to download the icon. | 620 // renderer to download the icon. |
| 622 } | 621 } |
| 623 | 622 |
| 624 void FaviconHandler::DownloadFaviconOrAskFaviconService( | 623 void FaviconHandler::DownloadFaviconOrAskFaviconService( |
| 625 const GURL& page_url, | 624 const GURL& page_url, |
| 626 const GURL& icon_url, | 625 const GURL& icon_url, |
| 627 favicon_base::IconType icon_type) { | 626 favicon_base::IconType icon_type) { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 646 UpdateFaviconMappingAndFetch( | 645 UpdateFaviconMappingAndFetch( |
| 647 page_url, icon_url, icon_type, | 646 page_url, icon_url, icon_type, |
| 648 base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)), | 647 base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)), |
| 649 &cancelable_task_tracker_); | 648 &cancelable_task_tracker_); |
| 650 } | 649 } |
| 651 } | 650 } |
| 652 } | 651 } |
| 653 | 652 |
| 654 void FaviconHandler::OnFaviconData(const std::vector< | 653 void FaviconHandler::OnFaviconData(const std::vector< |
| 655 favicon_base::FaviconBitmapResult>& favicon_bitmap_results) { | 654 favicon_base::FaviconBitmapResult>& favicon_bitmap_results) { |
| 656 NavigationEntry* entry = GetEntry(); | 655 if (!NavigationEntryConcernsFavicon()) |
| 657 if (!entry) | |
| 658 return; | 656 return; |
| 659 | 657 |
| 660 bool has_results = !favicon_bitmap_results.empty(); | 658 bool has_results = !favicon_bitmap_results.empty(); |
| 661 bool has_expired_or_incomplete_result = HasExpiredOrIncompleteResult( | 659 bool has_expired_or_incomplete_result = HasExpiredOrIncompleteResult( |
| 662 preferred_icon_size(), favicon_bitmap_results); | 660 preferred_icon_size(), favicon_bitmap_results); |
| 663 | 661 |
| 664 if (has_results && icon_types_ == favicon_base::FAVICON) { | 662 if (has_results && icon_types_ == favicon_base::FAVICON) { |
| 665 if (HasValidResult(favicon_bitmap_results)) { | 663 if (HasValidResult(favicon_bitmap_results)) { |
| 666 // There is a favicon, set it now. If expired we'll download the current | 664 // 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 | 665 // 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. | 666 // default and most likely the current one is fine anyway. |
| 669 SetFaviconOnNavigationEntry(entry, favicon_bitmap_results); | 667 SetFaviconOnNavigationEntry(favicon_bitmap_results); |
| 670 } | 668 } |
| 671 if (has_expired_or_incomplete_result) { | 669 if (has_expired_or_incomplete_result) { |
| 672 // The favicon is out of date. Request the current one. | 670 // The favicon is out of date. Request the current one. |
| 673 ScheduleDownload( | 671 ScheduleDownload(driver_->GetActiveURL(), |
| 674 entry->GetURL(), entry->GetFavicon().url, favicon_base::FAVICON); | 672 driver_->GetActiveFaviconURL(), |
| 673 favicon_base::FAVICON); | |
| 675 } | 674 } |
| 676 } else if (current_candidate() && | 675 } else if (current_candidate() && |
| 677 (!has_results || has_expired_or_incomplete_result || | 676 (!has_results || has_expired_or_incomplete_result || |
| 678 !(DoUrlsAndIconsMatch(*current_candidate(), favicon_bitmap_results)))) { | 677 !(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 | 678 // 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. | 679 // one got from page. Request the current one. |
| 681 ScheduleDownload(entry->GetURL(), current_candidate()->icon_url, | 680 ScheduleDownload(driver_->GetActiveURL(), |
| 681 current_candidate()->icon_url, | |
| 682 ToChromeIconType(current_candidate()->icon_type)); | 682 ToChromeIconType(current_candidate()->icon_type)); |
| 683 } | 683 } |
| 684 history_results_ = favicon_bitmap_results; | 684 history_results_ = favicon_bitmap_results; |
| 685 } | 685 } |
| 686 | 686 |
| 687 int FaviconHandler::ScheduleDownload(const GURL& url, | 687 int FaviconHandler::ScheduleDownload(const GURL& url, |
| 688 const GURL& image_url, | 688 const GURL& image_url, |
| 689 favicon_base::IconType icon_type) { | 689 favicon_base::IconType icon_type) { |
| 690 // A max bitmap size is specified to avoid receiving huge bitmaps in | 690 // A max bitmap size is specified to avoid receiving huge bitmaps in |
| 691 // OnDidDownloadFavicon(). See FaviconDriver::StartDownload() | 691 // OnDidDownloadFavicon(). See FaviconDriver::StartDownload() |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 716 } else { | 716 } else { |
| 717 gfx::Size largest = i->icon_sizes[index]; | 717 gfx::Size largest = i->icon_sizes[index]; |
| 718 i->icon_sizes.clear(); | 718 i->icon_sizes.clear(); |
| 719 i->icon_sizes.push_back(largest); | 719 i->icon_sizes.push_back(largest); |
| 720 ++i; | 720 ++i; |
| 721 } | 721 } |
| 722 } | 722 } |
| 723 std::stable_sort(image_urls_.begin(), image_urls_.end(), | 723 std::stable_sort(image_urls_.begin(), image_urls_.end(), |
| 724 CompareIconSize); | 724 CompareIconSize); |
| 725 } | 725 } |
| OLD | NEW |