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 /chrome | |
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 'chrome')
-rw-r--r-- | chrome/browser/browser_init.cc | 4 | ||||
-rw-r--r-- | chrome/browser/tab_contents/infobar_delegate.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/first_run_customize_view.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/first_run_customize_view.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/first_run_view_base.cc | 22 | ||||
-rw-r--r-- | chrome/browser/views/first_run_view_base.h | 4 | ||||
-rw-r--r-- | chrome/browser/views/infobars/infobars.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/options/general_page_view.cc | 1 |
8 files changed, 40 insertions, 2 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index 141e993..f8f4735 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -133,6 +133,10 @@ class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { l10n_util::GetString(IDS_DONT_ASK_AGAIN_INFOBAR_BUTTON_LABEL); } + virtual bool NeedElevation(InfoBarButton button) const { + return button == BUTTON_OK; + } + virtual bool Accept() { action_taken_ = true; UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.SetAsDefault", 1); diff --git a/chrome/browser/tab_contents/infobar_delegate.h b/chrome/browser/tab_contents/infobar_delegate.h index 4c72cca..9fdf554 100644 --- a/chrome/browser/tab_contents/infobar_delegate.h +++ b/chrome/browser/tab_contents/infobar_delegate.h @@ -233,6 +233,9 @@ class ConfirmInfoBarDelegate : public AlertInfoBarDelegate { // returns "OK" for the OK button and "Cancel" for the Cancel button. virtual std::wstring GetButtonLabel(InfoBarButton button) const; + // Return whether or not the specified button needs elevation. + virtual bool NeedElevation(InfoBarButton button) const { return false; } + // Called when the OK button is pressed. If the function returns true, the // InfoBarDelegate should be removed from the associated TabContents. virtual bool Accept() { return true; } diff --git a/chrome/browser/views/first_run_customize_view.cc b/chrome/browser/views/first_run_customize_view.cc index d2886ad..aad06a7 100644 --- a/chrome/browser/views/first_run_customize_view.cc +++ b/chrome/browser/views/first_run_customize_view.cc @@ -167,6 +167,9 @@ void FirstRunCustomizeView::ButtonPressed( // Disable the import combobox if the user unchecks the checkbox. import_from_combo_->SetEnabled(import_cbox_->checked()); } + + // Call the function of the base class to update its buttons. + FirstRunViewBase::ButtonPressed(sender, event); } int FirstRunCustomizeView::GetItemCount() { diff --git a/chrome/browser/views/first_run_customize_view.h b/chrome/browser/views/first_run_customize_view.h index dd1842e..dd9a28c 100644 --- a/chrome/browser/views/first_run_customize_view.h +++ b/chrome/browser/views/first_run_customize_view.h @@ -26,7 +26,6 @@ class Profile; // FirstRunCustomizeView implements the dialog that allows the user to do // some simple customizations during the first run. class FirstRunCustomizeView : public FirstRunViewBase, - public views::ButtonListener, public ComboboxModel { public: class CustomizeViewObserver { @@ -54,7 +53,7 @@ class FirstRunCustomizeView : public FirstRunViewBase, virtual bool Accept(); virtual bool Cancel(); - // Overridden form views::ButtonListener. + // Overridden form FirstRunViewBase. virtual void ButtonPressed(views::Button* sender, const views::Event& event); // Overridden form ComboboxModel. diff --git a/chrome/browser/views/first_run_view_base.cc b/chrome/browser/views/first_run_view_base.cc index 300d9c9..c29ab39 100644 --- a/chrome/browser/views/first_run_view_base.cc +++ b/chrome/browser/views/first_run_view_base.cc @@ -97,6 +97,7 @@ void FirstRunViewBase::SetupControls() { l10n_util::GetString(IDS_FR_CUSTOMIZE_DEFAULT_BROWSER)); default_browser_->SetMultiLine(true); AddChildView(default_browser_); + default_browser_->set_listener(this); } else { non_default_browser_label_ = new Label( l10n_util::GetStringF(IDS_OPTIONS_DEFAULTBROWSER_SXS, @@ -148,6 +149,15 @@ void FirstRunViewBase::Layout() { int width = canvas.width() - 2 * kPanelHorizMargin; if (default_browser_) { +#if defined(OS_WIN) + // Add or remove a shield icon before calculating the button width. + // (If a button has a shield icon, Windows automatically adds the icon width + // to the button width.) + views::DialogClientView* client_view = GetDialogClientView(); + if (client_view) + client_view->ok_button()->SetNeedElevation(default_browser_->checked()); +#endif + int height = default_browser_->GetHeightForWidth(width); default_browser_->SetBounds(kPanelHorizMargin, next_v_space, width, height); AdjustDialogWidth(default_browser_); @@ -159,6 +169,18 @@ void FirstRunViewBase::Layout() { } } +void FirstRunViewBase::ButtonPressed(views::Button* sender, + const views::Event& event) { +#if defined(OS_WIN) + if (default_browser_ && sender == default_browser_) { + // Update the elevation state of the "start chromium" button so we can add + // a shield icon when we need elevation. + views::DialogClientView* client_view = GetDialogClientView(); + client_view->ok_button()->SetNeedElevation(default_browser_->checked()); + } +#endif +} + bool FirstRunViewBase::CanResize() const { return false; } diff --git a/chrome/browser/views/first_run_view_base.h b/chrome/browser/views/first_run_view_base.h index b0d53d4..cefdd63 100644 --- a/chrome/browser/views/first_run_view_base.h +++ b/chrome/browser/views/first_run_view_base.h @@ -25,6 +25,7 @@ class ImporterHost; // first-run dialogs. This amounts to the bitmap, the two separators, the // progress throbber and some common resize code. class FirstRunViewBase : public views::View, + public views::ButtonListener, public views::DialogDelegate { public: explicit FirstRunViewBase(Profile* profile, bool homepage_defined, @@ -40,6 +41,9 @@ class FirstRunViewBase : public views::View, virtual bool IsAlwaysOnTop() const; virtual bool HasAlwaysOnTopMenu() const; + // Overridden form views::ButtonListener. + virtual void ButtonPressed(views::Button* sender, const views::Event& event); + // Overridden from views::DialogDelegate. std::wstring GetDialogButtonLabel(MessageBoxFlags::DialogButton button) const; diff --git a/chrome/browser/views/infobars/infobars.cc b/chrome/browser/views/infobars/infobars.cc index 37b4620..3c5504d 100644 --- a/chrome/browser/views/infobars/infobars.cc +++ b/chrome/browser/views/infobars/infobars.cc @@ -438,6 +438,8 @@ ConfirmInfoBar::ConfirmInfoBar(ConfirmInfoBarDelegate* delegate) this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_OK_DEFAULT) ok_button_->SetAppearsAsDefault(true); + if (delegate->NeedElevation(ConfirmInfoBarDelegate::BUTTON_OK)) + ok_button_->SetNeedElevation(true); cancel_button_ = new views::NativeButton( this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); diff --git a/chrome/browser/views/options/general_page_view.cc b/chrome/browser/views/options/general_page_view.cc index c1519f3..ecd0a1d 100644 --- a/chrome/browser/views/options/general_page_view.cc +++ b/chrome/browser/views/options/general_page_view.cc @@ -651,6 +651,7 @@ void GeneralPageView::SetDefaultBrowserUIState( ShellIntegration::DefaultBrowserUIState state) { bool button_enabled = state == ShellIntegration::STATE_NOT_DEFAULT; default_browser_use_as_default_button_->SetEnabled(button_enabled); + default_browser_use_as_default_button_->SetNeedElevation(true); if (state == ShellIntegration::STATE_IS_DEFAULT) { default_browser_status_label_->SetText( l10n_util::GetStringF(IDS_OPTIONS_DEFAULTBROWSER_DEFAULT, |