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/ui/views/create_application_shortcut_view.h" | 5 #include "chrome/browser/ui/views/create_application_shortcut_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 unprocessed_icons_.back().height), | 445 unprocessed_icons_.back().height), |
446 base::Bind(&CreateUrlApplicationShortcutView::DidDownloadFavicon, | 446 base::Bind(&CreateUrlApplicationShortcutView::DidDownloadFavicon, |
447 base::Unretained(this))); | 447 base::Unretained(this))); |
448 | 448 |
449 unprocessed_icons_.pop_back(); | 449 unprocessed_icons_.pop_back(); |
450 } | 450 } |
451 | 451 |
452 void CreateUrlApplicationShortcutView::DidDownloadFavicon( | 452 void CreateUrlApplicationShortcutView::DidDownloadFavicon( |
453 int id, | 453 int id, |
454 const GURL& image_url, | 454 const GURL& image_url, |
455 bool errored, | |
456 int requested_size, | 455 int requested_size, |
457 const std::vector<SkBitmap>& bitmaps) { | 456 const std::vector<SkBitmap>& bitmaps) { |
458 if (id != pending_download_id_) | 457 if (id != pending_download_id_) |
459 return; | 458 return; |
460 pending_download_id_ = -1; | 459 pending_download_id_ = -1; |
461 | 460 |
462 SkBitmap image; | 461 SkBitmap image; |
463 | 462 |
464 if (!bitmaps.empty()) { | 463 if (!bitmaps.empty()) { |
465 std::vector<ui::ScaleFactor> scale_factors; | 464 std::vector<ui::ScaleFactor> scale_factors; |
466 ui::ScaleFactor scale_factor = ui::GetScaleFactorForNativeView( | 465 ui::ScaleFactor scale_factor = ui::GetScaleFactorForNativeView( |
467 web_contents_->GetRenderViewHost()->GetView()->GetNativeView()); | 466 web_contents_->GetRenderViewHost()->GetView()->GetNativeView()); |
468 scale_factors.push_back(scale_factor); | 467 scale_factors.push_back(scale_factor); |
469 size_t closest_index = FaviconUtil::SelectBestFaviconFromBitmaps( | 468 size_t closest_index = FaviconUtil::SelectBestFaviconFromBitmaps( |
470 bitmaps, | 469 bitmaps, |
471 scale_factors, | 470 scale_factors, |
472 requested_size); | 471 requested_size); |
473 image = bitmaps[closest_index]; | 472 image = bitmaps[closest_index]; |
474 } | 473 } |
475 | 474 |
476 if (!errored && !image.isNull()) { | 475 if (!image.isNull()) { |
477 shortcut_info_.favicon = gfx::Image(image); | 476 shortcut_info_.favicon = gfx::Image(image); |
478 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); | 477 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); |
479 } else { | 478 } else { |
480 FetchIcon(); | 479 FetchIcon(); |
481 } | 480 } |
482 } | 481 } |
483 | 482 |
484 CreateChromeApplicationShortcutView::CreateChromeApplicationShortcutView( | 483 CreateChromeApplicationShortcutView::CreateChromeApplicationShortcutView( |
485 Profile* profile, | 484 Profile* profile, |
486 const extensions::Extension* app) : | 485 const extensions::Extension* app) : |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 if (image.IsEmpty()) { | 528 if (image.IsEmpty()) { |
530 shortcut_info_.favicon = ui::ResourceBundle::GetSharedInstance(). | 529 shortcut_info_.favicon = ui::ResourceBundle::GetSharedInstance(). |
531 GetImageNamed(IDR_APP_DEFAULT_ICON); | 530 GetImageNamed(IDR_APP_DEFAULT_ICON); |
532 } else { | 531 } else { |
533 shortcut_info_.favicon = image; | 532 shortcut_info_.favicon = image; |
534 } | 533 } |
535 | 534 |
536 CHECK(app_info_); | 535 CHECK(app_info_); |
537 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); | 536 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); |
538 } | 537 } |
OLD | NEW |