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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 } | 363 } |
364 | 364 |
365 if (got_favicon_from_history_) | 365 if (got_favicon_from_history_) |
366 DownloadFaviconOrAskHistory(entry->GetURL(), current_candidate()->icon_url, | 366 DownloadFaviconOrAskHistory(entry->GetURL(), current_candidate()->icon_url, |
367 ToHistoryIconType(current_candidate()->icon_type)); | 367 ToHistoryIconType(current_candidate()->icon_type)); |
368 } | 368 } |
369 | 369 |
370 void FaviconHandler::OnDidDownloadFavicon( | 370 void FaviconHandler::OnDidDownloadFavicon( |
371 int id, | 371 int id, |
372 const GURL& image_url, | 372 const GURL& image_url, |
373 bool errored, | |
374 int requested_size, | 373 int requested_size, |
375 const std::vector<SkBitmap>& bitmaps) { | 374 const std::vector<SkBitmap>& bitmaps) { |
376 DownloadRequests::iterator i = download_requests_.find(id); | 375 DownloadRequests::iterator i = download_requests_.find(id); |
377 if (i == download_requests_.end()) { | 376 if (i == download_requests_.end()) { |
378 // Currently WebContents notifies us of ANY downloads so that it is | 377 // Currently WebContents notifies us of ANY downloads so that it is |
379 // possible to get here. | 378 // possible to get here. |
380 return; | 379 return; |
381 } | 380 } |
382 | 381 |
383 if (current_candidate() && | 382 if (current_candidate() && |
384 DoUrlAndIconMatch(*current_candidate(), image_url, i->second.icon_type)) { | 383 DoUrlAndIconMatch(*current_candidate(), image_url, i->second.icon_type)) { |
385 float score = 0.0f; | 384 float score = 0.0f; |
386 std::vector<ui::ScaleFactor> scale_factors = | 385 std::vector<ui::ScaleFactor> scale_factors = |
387 FaviconUtil::GetFaviconScaleFactors(); | 386 FaviconUtil::GetFaviconScaleFactors(); |
388 gfx::Image image(SelectFaviconFrames(bitmaps, scale_factors, requested_size, | 387 gfx::Image image(SelectFaviconFrames(bitmaps, scale_factors, requested_size, |
389 &score)); | 388 &score)); |
390 | 389 |
391 // The downloaded icon is still valid when there is no FaviconURL update | 390 // The downloaded icon is still valid when there is no FaviconURL update |
392 // during the downloading. | 391 // during the downloading. |
393 bool request_next_icon = true; | 392 bool request_next_icon = true; |
394 if (!errored) { | 393 if (!bitmaps.empty()) { |
395 request_next_icon = !UpdateFaviconCandidate( | 394 request_next_icon = !UpdateFaviconCandidate( |
396 i->second.url, image_url, image, score, i->second.icon_type); | 395 i->second.url, image_url, image, score, i->second.icon_type); |
397 } | 396 } |
398 if (request_next_icon && GetEntry() && image_urls_.size() > 1) { | 397 if (request_next_icon && GetEntry() && image_urls_.size() > 1) { |
399 // Remove the first member of image_urls_ and process the remaining. | 398 // Remove the first member of image_urls_ and process the remaining. |
400 image_urls_.pop_front(); | 399 image_urls_.pop_front(); |
401 ProcessCurrentUrl(); | 400 ProcessCurrentUrl(); |
402 } else if (favicon_candidate_.icon_type != history::INVALID_ICON) { | 401 } else if (favicon_candidate_.icon_type != history::INVALID_ICON) { |
403 // No more icons to request, set the favicon from the candidate. | 402 // No more icons to request, set the favicon from the candidate. |
404 SetFavicon(favicon_candidate_.url, | 403 SetFavicon(favicon_candidate_.url, |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 const int download_id = DownloadFavicon(image_url, image_size); | 612 const int download_id = DownloadFavicon(image_url, image_size); |
614 if (download_id) { | 613 if (download_id) { |
615 // Download ids should be unique. | 614 // Download ids should be unique. |
616 DCHECK(download_requests_.find(download_id) == download_requests_.end()); | 615 DCHECK(download_requests_.find(download_id) == download_requests_.end()); |
617 download_requests_[download_id] = | 616 download_requests_[download_id] = |
618 DownloadRequest(url, image_url, icon_type); | 617 DownloadRequest(url, image_url, icon_type); |
619 } | 618 } |
620 | 619 |
621 return download_id; | 620 return download_id; |
622 } | 621 } |
OLD | NEW |