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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 const GURL& image_url, | 490 const GURL& image_url, |
491 const std::vector<SkBitmap>& bitmaps, | 491 const std::vector<SkBitmap>& bitmaps, |
492 const std::vector<gfx::Size>& original_bitmap_sizes) { | 492 const std::vector<gfx::Size>& original_bitmap_sizes) { |
493 if (id != pending_download_id_) | 493 if (id != pending_download_id_) |
494 return; | 494 return; |
495 pending_download_id_ = -1; | 495 pending_download_id_ = -1; |
496 | 496 |
497 SkBitmap image; | 497 SkBitmap image; |
498 | 498 |
499 if (!bitmaps.empty()) { | 499 if (!bitmaps.empty()) { |
500 std::vector<ui::ScaleFactor> scale_factors; | 500 std::vector<int> requested_sizes_in_pixel; |
501 ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactor( | 501 float scale = ui::GetScaleFactorForNativeView( |
502 ui::GetScaleFactorForNativeView( | 502 web_contents_->GetRenderViewHost()->GetView()->GetNativeView()); |
503 web_contents_->GetRenderViewHost()->GetView()->GetNativeView())); | 503 requested_sizes_in_pixel.push_back( |
504 scale_factors.push_back(scale_factor); | 504 static_cast<int>(requested_size * scale + 0.5f)); |
sky
2014/06/18 22:16:51
Same question about the .5 here.
| |
505 std::vector<size_t> closest_indices; | 505 std::vector<size_t> closest_indices; |
506 SelectFaviconFrameIndices(original_bitmap_sizes, | 506 SelectFaviconFrameIndices(original_bitmap_sizes, |
507 scale_factors, | 507 requested_sizes_in_pixel, |
508 requested_size, | |
509 &closest_indices, | 508 &closest_indices, |
510 NULL); | 509 NULL); |
511 size_t closest_index = closest_indices[0]; | 510 size_t closest_index = closest_indices[0]; |
512 image = bitmaps[closest_index]; | 511 image = bitmaps[closest_index]; |
513 } | 512 } |
514 | 513 |
515 if (!image.isNull()) { | 514 if (!image.isNull()) { |
516 shortcut_info_.favicon.Add(gfx::ImageSkia::CreateFrom1xBitmap(image)); | 515 shortcut_info_.favicon.Add(gfx::ImageSkia::CreateFrom1xBitmap(image)); |
517 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); | 516 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); |
518 } else { | 517 } else { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
553 if (!close_callback_.is_null()) | 552 if (!close_callback_.is_null()) |
554 close_callback_.Run(false); | 553 close_callback_.Run(false); |
555 return CreateApplicationShortcutView::Cancel(); | 554 return CreateApplicationShortcutView::Cancel(); |
556 } | 555 } |
557 | 556 |
558 // Called when the app's ShortcutInfo (with icon) is loaded. | 557 // Called when the app's ShortcutInfo (with icon) is loaded. |
559 void CreateChromeApplicationShortcutView::OnShortcutInfoLoaded( | 558 void CreateChromeApplicationShortcutView::OnShortcutInfoLoaded( |
560 const web_app::ShortcutInfo& shortcut_info) { | 559 const web_app::ShortcutInfo& shortcut_info) { |
561 shortcut_info_ = shortcut_info; | 560 shortcut_info_ = shortcut_info; |
562 } | 561 } |
OLD | NEW |