diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 07:09:30 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 07:09:30 +0000 |
commit | 2891839ea6e7748abba4c7b822b68342dc84cec2 (patch) | |
tree | 319dd7e421e3707cb8196a14a0ad17ec1df1d3ac /views | |
parent | 2e3b520ff4318342b027ea8aa303e5981ea9ce79 (diff) | |
download | chromium_src-2891839ea6e7748abba4c7b822b68342dc84cec2.zip chromium_src-2891839ea6e7748abba4c7b822b68342dc84cec2.tar.gz chromium_src-2891839ea6e7748abba4c7b822b68342dc84cec2.tar.bz2 |
This change adds shield icons to the buttons that need elevation to fix Issue 29631. This change adds a bool flag |need_elevation_| to notify when a button needs elevation to the NativeButton class and add shield icons to the following buttons.
- on the "Start Chromium" button on the first-run dialog when the "Make Chromium the default browser" checkbox is enabled.
- on the "Set as Default" button on the default browser infobar.
- on the "Make Google Chrome my default browser" button on the Basics tab of options.
BUG=29631
TEST=Launch Chrome when it is not set as a default browser and see the "Set as Default" button has a shield icon.
TEST=Launch Chrome when it is not set as a default browser and open the "Options" dialog, and see its "Make Google Chrome my default browser" button has a shield icon.
TEST=Launch Chrome with a '--first-run' option when it is not set as a default browser, and see its "Launch Chrome" button has a shield icon.
Review URL: http://codereview.chromium.org/661165
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42322 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/button/native_button.cc | 14 | ||||
-rw-r--r-- | views/controls/button/native_button.h | 16 | ||||
-rw-r--r-- | views/controls/button/native_button_win.cc | 15 |
3 files changed, 35 insertions, 10 deletions
diff --git a/views/controls/button/native_button.cc b/views/controls/button/native_button.cc index 5bdc9c73..7086008 100644 --- a/views/controls/button/native_button.cc +++ b/views/controls/button/native_button.cc @@ -1,6 +1,6 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this -// source code is governed by a BSD-style license that can be found in the -// LICENSE file. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #include "views/controls/button/native_button.h" @@ -40,6 +40,7 @@ NativeButton::NativeButton(ButtonListener* listener) : Button(listener), native_wrapper_(NULL), is_default_(false), + need_elevation_(false), ignore_minimum_size_(false) { InitBorder(); SetFocusable(true); @@ -49,6 +50,7 @@ NativeButton::NativeButton(ButtonListener* listener, const std::wstring& label) : Button(listener), native_wrapper_(NULL), is_default_(false), + need_elevation_(false), ignore_minimum_size_(false) { SetLabel(label); // SetLabel takes care of label layout in RTL UI. InitBorder(); @@ -89,6 +91,12 @@ void NativeButton::SetIsDefault(bool is_default) { SetAppearsAsDefault(is_default); } +void NativeButton::SetNeedElevation(bool need_elevation) { + need_elevation_ = need_elevation; + if (native_wrapper_) + native_wrapper_->UpdateLabel(); +} + void NativeButton::SetAppearsAsDefault(bool appears_as_default) { is_default_ = appears_as_default; if (native_wrapper_) diff --git a/views/controls/button/native_button.h b/views/controls/button/native_button.h index 4b6d06f..74e7cf2 100644 --- a/views/controls/button/native_button.h +++ b/views/controls/button/native_button.h @@ -1,6 +1,6 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this -// source code is governed by a BSD-style license that can be found in the -// LICENSE file. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #ifndef VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_H_ #define VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_H_ @@ -37,12 +37,16 @@ class NativeButton : public Button { void SetIsDefault(bool default_button); bool is_default() const { return is_default_; } + // Sets/Gets whether or not pressing this button requires elevation. + void SetNeedElevation(bool need_elevation); + bool need_elevation() const { return need_elevation_; } + // Sets whether or not the button appears as the default button. This does // not make it behave as the default (i.e. no enter key accelerator is // registered, use SetIsDefault for that). void SetAppearsAsDefault(bool default_button); - void set_ignore_minimum_size(bool ignore_minimum_size) { + void set_ignore_minimum_size(bool ignore_minimum_size) {1 ignore_minimum_size_ = ignore_minimum_size; } @@ -82,6 +86,10 @@ class NativeButton : public Button { // True if the button is the default button in its context. bool is_default_; + // True if this button requires elevation (or sudo). This flag is currently + // used for adding a shield icon on Windows Vista or later. + bool need_elevation_; + // The font used to render the button label. gfx::Font font_; diff --git a/views/controls/button/native_button_win.cc b/views/controls/button/native_button_win.cc index d138833..57be88c 100644 --- a/views/controls/button/native_button_win.cc +++ b/views/controls/button/native_button_win.cc @@ -1,12 +1,13 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this -// source code is governed by a BSD-style license that can be found in the -// LICENSE file. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #include "views/controls/button/native_button_win.h" #include <commctrl.h> #include "base/logging.h" +#include "base/win_util.h" #include "views/controls/button/checkbox.h" #include "views/controls/button/native_button.h" #include "views/controls/button/radio_button.h" @@ -32,6 +33,14 @@ NativeButtonWin::~NativeButtonWin() { // NativeButtonWin, NativeButtonWrapper implementation: void NativeButtonWin::UpdateLabel() { + // Show or hide the shield icon of Windows onto this button every time when we + // update the button text so Windows can lay out the shield icon and the + // button text correctly. + if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { + Button_SetElevationRequiredState(native_view(), + native_button_->need_elevation()); + } + SetWindowText(native_view(), native_button_->label().c_str()); } |