OLD | NEW |
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 #ifndef CHROME_BROWSER_UI_VIEWS_ELEVATION_ICON_SETTER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_ELEVATION_ICON_SETTER_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_ELEVATION_ICON_SETTER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_ELEVATION_ICON_SETTER_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
12 | 13 |
13 class SkBitmap; | 14 class SkBitmap; |
14 | 15 |
15 namespace views { | 16 namespace views { |
16 class LabelButton; | 17 class LabelButton; |
17 } | 18 } |
18 | 19 |
19 // On Windows, badges a button with a "UAC shield" icon to indicate that | 20 // On Windows, badges a button with a "UAC shield" icon to indicate that |
20 // clicking will trigger a UAC elevation prompt. Does nothing on other | 21 // clicking will trigger a UAC elevation prompt. Does nothing on other |
21 // platforms. | 22 // platforms. |
22 class ElevationIconSetter { | 23 class ElevationIconSetter { |
23 public: | 24 public: |
24 // |button| must be guaranteed to be alive throughout this class' lifetime! | 25 // |button| must be guaranteed to be alive throughout this class' lifetime! |
25 // |callback| will be called if the button icon is actually changed; callers | 26 // |callback| will be called if the button icon is actually changed; callers |
26 // should pass a function which does a relayout on the view containing the | 27 // should pass a function which does a relayout on the view containing the |
27 // button, to ensure the button is correctly resized as necessary. | 28 // button, to ensure the button is correctly resized as necessary. |
28 ElevationIconSetter(views::LabelButton* button, | 29 ElevationIconSetter(views::LabelButton* button, |
29 const base::Closure& callback); | 30 const base::Closure& callback); |
30 ~ElevationIconSetter(); | 31 ~ElevationIconSetter(); |
31 | 32 |
32 private: | 33 private: |
33 void SetButtonIcon(const base::Closure& callback, scoped_ptr<SkBitmap> icon); | 34 void SetButtonIcon(const base::Closure& callback, |
| 35 std::unique_ptr<SkBitmap> icon); |
34 | 36 |
35 views::LabelButton* button_; | 37 views::LabelButton* button_; |
36 base::WeakPtrFactory<ElevationIconSetter> weak_factory_; | 38 base::WeakPtrFactory<ElevationIconSetter> weak_factory_; |
37 | 39 |
38 DISALLOW_COPY_AND_ASSIGN(ElevationIconSetter); | 40 DISALLOW_COPY_AND_ASSIGN(ElevationIconSetter); |
39 }; | 41 }; |
40 | 42 |
41 #endif // CHROME_BROWSER_UI_VIEWS_ELEVATION_ICON_SETTER_H_ | 43 #endif // CHROME_BROWSER_UI_VIEWS_ELEVATION_ICON_SETTER_H_ |
OLD | NEW |