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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 const GURL& image_url, | 491 const GURL& image_url, |
492 const std::vector<SkBitmap>& bitmaps, | 492 const std::vector<SkBitmap>& bitmaps, |
493 const std::vector<gfx::Size>& original_bitmap_sizes) { | 493 const std::vector<gfx::Size>& original_bitmap_sizes) { |
494 if (id != pending_download_id_) | 494 if (id != pending_download_id_) |
495 return; | 495 return; |
496 pending_download_id_ = -1; | 496 pending_download_id_ = -1; |
497 | 497 |
498 SkBitmap image; | 498 SkBitmap image; |
499 | 499 |
500 if (!bitmaps.empty()) { | 500 if (!bitmaps.empty()) { |
501 std::vector<ui::ScaleFactor> scale_factors; | 501 std::vector<int> requested_sizes_in_pixel; |
502 ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactor( | 502 float scale = ui::GetScaleFactorForNativeView( |
503 ui::GetScaleFactorForNativeView( | 503 web_contents_->GetRenderViewHost()->GetView()->GetNativeView()); |
504 web_contents_->GetRenderViewHost()->GetView()->GetNativeView())); | 504 requested_sizes_in_pixel.push_back( |
505 scale_factors.push_back(scale_factor); | 505 static_cast<int>(requested_size * scale + 0.5f)); |
506 std::vector<size_t> closest_indices; | 506 std::vector<size_t> closest_indices; |
507 SelectFaviconFrameIndices(original_bitmap_sizes, | 507 SelectFaviconFrameIndices(original_bitmap_sizes, |
508 scale_factors, | 508 requested_sizes_in_pixel, |
509 requested_size, | |
510 &closest_indices, | 509 &closest_indices, |
511 NULL); | 510 NULL); |
512 size_t closest_index = closest_indices[0]; | 511 size_t closest_index = closest_indices[0]; |
513 image = bitmaps[closest_index]; | 512 image = bitmaps[closest_index]; |
514 } | 513 } |
515 | 514 |
516 if (!image.isNull()) { | 515 if (!image.isNull()) { |
517 shortcut_info_.favicon.Add(gfx::ImageSkia::CreateFrom1xBitmap(image)); | 516 shortcut_info_.favicon.Add(gfx::ImageSkia::CreateFrom1xBitmap(image)); |
518 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); | 517 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); |
519 } else { | 518 } else { |
(...skipping 20 matching lines...) Expand all Loading... |
540 if (!close_callback_.is_null()) | 539 if (!close_callback_.is_null()) |
541 close_callback_.Run(true); | 540 close_callback_.Run(true); |
542 return CreateApplicationShortcutView::Accept(); | 541 return CreateApplicationShortcutView::Accept(); |
543 } | 542 } |
544 | 543 |
545 bool CreateChromeApplicationShortcutView::Cancel() { | 544 bool CreateChromeApplicationShortcutView::Cancel() { |
546 if (!close_callback_.is_null()) | 545 if (!close_callback_.is_null()) |
547 close_callback_.Run(false); | 546 close_callback_.Run(false); |
548 return CreateApplicationShortcutView::Cancel(); | 547 return CreateApplicationShortcutView::Cancel(); |
549 } | 548 } |
OLD | NEW |