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

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

Issue 849543003: Make elevation icon size correct in different DPI settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added comment Created 5 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/elevation_icon_setter.h" 5 #include "chrome/browser/ui/views/elevation_icon_setter.h"
6 6
7 #include "base/task_runner_util.h" 7 #include "base/task_runner_util.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "ui/views/controls/button/label_button.h" 9 #include "ui/views/controls/button/label_button.h"
10 10
11 #if defined(OS_WIN) 11 #if defined(OS_WIN)
12 #include <windows.h> 12 #include <windows.h>
13 #include <shellapi.h> 13 #include <shellapi.h>
14 #include "base/win/win_util.h" 14 #include "base/win/win_util.h"
15 #include "base/win/windows_version.h" 15 #include "base/win/windows_version.h"
16 #include "ui/gfx/icon_util.h" 16 #include "ui/gfx/icon_util.h"
17 #include "ui/gfx/win/dpi.h"
17 #endif 18 #endif
18 19
19 20
20 // Helpers -------------------------------------------------------------------- 21 // Helpers --------------------------------------------------------------------
21 22
22 namespace { 23 namespace {
23 24
24 scoped_ptr<SkBitmap> GetElevationIcon() { 25 scoped_ptr<SkBitmap> GetElevationIcon() {
25 scoped_ptr<SkBitmap> icon; 26 scoped_ptr<SkBitmap> icon;
26 #if defined(OS_WIN) 27 #if defined(OS_WIN)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 base::Bind(&GetElevationIcon), 65 base::Bind(&GetElevationIcon),
65 base::Bind(&ElevationIconSetter::SetButtonIcon, 66 base::Bind(&ElevationIconSetter::SetButtonIcon,
66 weak_factory_.GetWeakPtr())); 67 weak_factory_.GetWeakPtr()));
67 } 68 }
68 69
69 ElevationIconSetter::~ElevationIconSetter() { 70 ElevationIconSetter::~ElevationIconSetter() {
70 } 71 }
71 72
72 void ElevationIconSetter::SetButtonIcon(scoped_ptr<SkBitmap> icon) { 73 void ElevationIconSetter::SetButtonIcon(scoped_ptr<SkBitmap> icon) {
73 if (icon) { 74 if (icon) {
74 button_->SetImage(views::Button::STATE_NORMAL, 75 float device_scale_factor = 1.0f;
75 gfx::ImageSkia::CreateFrom1xBitmap(*icon)); 76 #if defined(OS_WIN)
77 // Windows gives us back a correctly-scaled image for the current DPI, so
78 // mark this image as having been scaled for the current DPI already.
79 device_scale_factor = gfx::GetDPIScale();
80 #endif
81 button_->SetImage(
82 views::Button::STATE_NORMAL,
83 gfx::ImageSkia(gfx::ImageSkiaRep(*icon, device_scale_factor)));
76 button_->SizeToPreferredSize(); 84 button_->SizeToPreferredSize();
77 if (button_->parent()) 85 if (button_->parent())
78 button_->parent()->Layout(); 86 button_->parent()->Layout();
79 } 87 }
80 } 88 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698