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

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

Issue 941133002: Update global error bubble view's boundary (position and size) after loading elevation icon. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
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/callback.h"
7 #include "base/task_runner_util.h" 8 #include "base/task_runner_util.h"
8 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
9 #include "ui/views/controls/button/label_button.h" 10 #include "ui/views/controls/button/label_button.h"
10 11
11 #if defined(OS_WIN) 12 #if defined(OS_WIN)
12 #include <windows.h> 13 #include <windows.h>
13 #include <shellapi.h> 14 #include <shellapi.h>
14 #include "base/win/win_util.h" 15 #include "base/win/win_util.h"
15 #include "base/win/windows_version.h" 16 #include "base/win/windows_version.h"
16 #include "ui/gfx/icon_util.h" 17 #include "ui/gfx/icon_util.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 DestroyIcon(icon_info.hIcon); 50 DestroyIcon(icon_info.hIcon);
50 #endif 51 #endif
51 return icon.Pass(); 52 return icon.Pass();
52 } 53 }
53 54
54 } // namespace 55 } // namespace
55 56
56 57
57 // ElevationIconSetter -------------------------------------------------------- 58 // ElevationIconSetter --------------------------------------------------------
58 59
59 ElevationIconSetter::ElevationIconSetter(views::LabelButton* button) 60 ElevationIconSetter::ElevationIconSetter(views::LabelButton* button,
61 const base::Closure& done_callback)
60 : button_(button), 62 : button_(button),
61 weak_factory_(this) { 63 weak_factory_(this) {
62 base::PostTaskAndReplyWithResult( 64 base::PostTaskAndReplyWithResult(
63 content::BrowserThread::GetBlockingPool(), 65 content::BrowserThread::GetBlockingPool(),
64 FROM_HERE, 66 FROM_HERE,
65 base::Bind(&GetElevationIcon), 67 base::Bind(&GetElevationIcon),
66 base::Bind(&ElevationIconSetter::SetButtonIcon, 68 base::Bind(&ElevationIconSetter::SetButtonIcon,
67 weak_factory_.GetWeakPtr())); 69 weak_factory_.GetWeakPtr(),
70 done_callback));
68 } 71 }
69 72
70 ElevationIconSetter::~ElevationIconSetter() { 73 ElevationIconSetter::~ElevationIconSetter() {
71 } 74 }
72 75
73 void ElevationIconSetter::SetButtonIcon(scoped_ptr<SkBitmap> icon) { 76 void ElevationIconSetter::SetButtonIcon(const base::Closure& done_callback,
77 scoped_ptr<SkBitmap> icon) {
74 if (icon) { 78 if (icon) {
75 float device_scale_factor = 1.0f; 79 float device_scale_factor = 1.0f;
76 #if defined(OS_WIN) 80 #if defined(OS_WIN)
77 // Windows gives us back a correctly-scaled image for the current DPI, so 81 // 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. 82 // mark this image as having been scaled for the current DPI already.
79 device_scale_factor = gfx::GetDPIScale(); 83 device_scale_factor = gfx::GetDPIScale();
80 #endif 84 #endif
81 button_->SetImage( 85 button_->SetImage(
82 views::Button::STATE_NORMAL, 86 views::Button::STATE_NORMAL,
83 gfx::ImageSkia(gfx::ImageSkiaRep(*icon, device_scale_factor))); 87 gfx::ImageSkia(gfx::ImageSkiaRep(*icon, device_scale_factor)));
84 button_->SizeToPreferredSize(); 88 button_->SizeToPreferredSize();
85 if (button_->parent()) 89 if (button_->parent())
86 button_->parent()->Layout(); 90 button_->parent()->Layout();
91 if (!done_callback.is_null())
92 done_callback.Run();
87 } 93 }
88 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698