Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: chrome/browser/ui/views/create_application_shortcut_view.cc

Issue 335233003: Convert ui::ScaleFactor -> float in favicon/history code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 19 matching lines...) Expand all
30 #include "grit/generated_resources.h" 30 #include "grit/generated_resources.h"
31 #include "grit/locale_settings.h" 31 #include "grit/locale_settings.h"
32 #include "grit/theme_resources.h" 32 #include "grit/theme_resources.h"
33 #include "net/base/load_flags.h" 33 #include "net/base/load_flags.h"
34 #include "net/url_request/url_request.h" 34 #include "net/url_request/url_request.h"
35 #include "skia/ext/image_operations.h" 35 #include "skia/ext/image_operations.h"
36 #include "third_party/skia/include/core/SkBitmap.h" 36 #include "third_party/skia/include/core/SkBitmap.h"
37 #include "third_party/skia/include/core/SkPaint.h" 37 #include "third_party/skia/include/core/SkPaint.h"
38 #include "third_party/skia/include/core/SkRect.h" 38 #include "third_party/skia/include/core/SkRect.h"
39 #include "ui/base/l10n/l10n_util.h" 39 #include "ui/base/l10n/l10n_util.h"
40 #include "ui/base/layout.h"
41 #include "ui/base/resource/resource_bundle.h" 40 #include "ui/base/resource/resource_bundle.h"
42 #include "ui/gfx/canvas.h" 41 #include "ui/gfx/canvas.h"
43 #include "ui/gfx/codec/png_codec.h" 42 #include "ui/gfx/codec/png_codec.h"
44 #include "ui/gfx/image/image_family.h" 43 #include "ui/gfx/image/image_family.h"
45 #include "ui/gfx/image/image_skia.h" 44 #include "ui/gfx/image/image_skia.h"
46 #include "ui/views/controls/button/checkbox.h" 45 #include "ui/views/controls/button/checkbox.h"
47 #include "ui/views/controls/image_view.h" 46 #include "ui/views/controls/image_view.h"
48 #include "ui/views/controls/label.h" 47 #include "ui/views/controls/label.h"
49 #include "ui/views/layout/grid_layout.h" 48 #include "ui/views/layout/grid_layout.h"
50 #include "ui/views/layout/layout_constants.h" 49 #include "ui/views/layout/layout_constants.h"
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 int requested_size, 486 int requested_size,
488 int id, 487 int id,
489 int http_status_code, 488 int http_status_code,
490 const GURL& image_url, 489 const GURL& image_url,
491 const std::vector<SkBitmap>& bitmaps, 490 const std::vector<SkBitmap>& bitmaps,
492 const std::vector<gfx::Size>& original_bitmap_sizes) { 491 const std::vector<gfx::Size>& original_bitmap_sizes) {
493 if (id != pending_download_id_) 492 if (id != pending_download_id_)
494 return; 493 return;
495 pending_download_id_ = -1; 494 pending_download_id_ = -1;
496 495
497 SkBitmap image; 496 SkBitmap bitmap;
498 497
499 if (!bitmaps.empty()) { 498 if (!bitmaps.empty()) {
500 std::vector<ui::ScaleFactor> scale_factors; 499 std::vector<float> scales;
501 ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactor( 500 scales.push_back(ui::GetScaleFactorForNativeView(
502 ui::GetScaleFactorForNativeView( 501 web_contents_->GetRenderViewHost()->GetView()->GetNativeView()));
503 web_contents_->GetRenderViewHost()->GetView()->GetNativeView()));
504 scale_factors.push_back(scale_factor);
505 std::vector<size_t> closest_indices; 502 std::vector<size_t> closest_indices;
506 SelectFaviconFrameIndices(original_bitmap_sizes, 503 SelectFaviconFrameIndices(
507 scale_factors, 504 original_bitmap_sizes, scales, requested_size, &closest_indices, NULL);
508 requested_size,
509 &closest_indices,
510 NULL);
511 size_t closest_index = closest_indices[0]; 505 size_t closest_index = closest_indices[0];
512 image = bitmaps[closest_index]; 506 bitmap = bitmaps[closest_index];
513 } 507 }
514 508
515 if (!image.isNull()) { 509 if (!bitmap.isNull()) {
516 shortcut_info_.favicon.Add(gfx::ImageSkia::CreateFrom1xBitmap(image)); 510 shortcut_info_.favicon.Add(gfx::ImageSkia::CreateFrom1xBitmap(bitmap));
517 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); 511 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon);
518 } else { 512 } else {
519 FetchIcon(); 513 FetchIcon();
520 } 514 }
521 } 515 }
522 516
523 CreateChromeApplicationShortcutView::CreateChromeApplicationShortcutView( 517 CreateChromeApplicationShortcutView::CreateChromeApplicationShortcutView(
524 Profile* profile, 518 Profile* profile,
525 const extensions::Extension* app, 519 const extensions::Extension* app,
526 const base::Callback<void(bool)>& close_callback) 520 const base::Callback<void(bool)>& close_callback)
(...skipping 12 matching lines...) Expand all
539 if (!close_callback_.is_null()) 533 if (!close_callback_.is_null())
540 close_callback_.Run(true); 534 close_callback_.Run(true);
541 return CreateApplicationShortcutView::Accept(); 535 return CreateApplicationShortcutView::Accept();
542 } 536 }
543 537
544 bool CreateChromeApplicationShortcutView::Cancel() { 538 bool CreateChromeApplicationShortcutView::Cancel() {
545 if (!close_callback_.is_null()) 539 if (!close_callback_.is_null())
546 close_callback_.Run(false); 540 close_callback_.Run(false);
547 return CreateApplicationShortcutView::Cancel(); 541 return CreateApplicationShortcutView::Cancel();
548 } 542 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698