diff options
author | ivankr@chromium.org <ivankr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-19 12:16:12 +0000 |
---|---|---|
committer | ivankr@chromium.org <ivankr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-19 12:16:12 +0000 |
commit | fa025f27dac197b2e1afc97e4e44269b1939f50f (patch) | |
tree | e979ecac3254fcdab6389b9e50a2735d6475decb | |
parent | d51269fbfd9444f9ab0ca38c6197e9e000b3cd8e (diff) | |
download | chromium_src-fa025f27dac197b2e1afc97e4e44269b1939f50f.zip chromium_src-fa025f27dac197b2e1afc97e4e44269b1939f50f.tar.gz chromium_src-fa025f27dac197b2e1afc97e4e44269b1939f50f.tar.bz2 |
Swap 'Make changes' and 'Keep settings' buttons on 'Verify Settings Change' error bubble.
BUG=100585
TEST=manual
Review URL: http://codereview.chromium.org/8321015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106265 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/protector/settings_change_global_error.cc | 28 | ||||
-rw-r--r-- | chrome/browser/protector/settings_change_global_error.h | 13 | ||||
-rw-r--r-- | chrome/browser/ui/global_error.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/global_error.h | 3 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/global_error_bubble.cc | 7 | ||||
-rw-r--r-- | chrome/browser/ui/views/global_error_bubble_view.cc | 4 |
6 files changed, 39 insertions, 20 deletions
diff --git a/chrome/browser/protector/settings_change_global_error.cc b/chrome/browser/protector/settings_change_global_error.cc index cbeb056..a472d30 100644 --- a/chrome/browser/protector/settings_change_global_error.cc +++ b/chrome/browser/protector/settings_change_global_error.cc @@ -55,11 +55,11 @@ const int kBubbleChangeSettingIDs[] = { SettingsChangeGlobalError::SettingsChangeGlobalError( const ChangesVector& changes, - const base::Closure& make_changes_cb, - const base::Closure& restore_changes_cb) + const base::Closure& apply_changes_cb, + const base::Closure& revert_changes_cb) : changes_(changes), - make_changes_cb_(make_changes_cb), - restore_changes_cb_(restore_changes_cb), + apply_changes_cb_(apply_changes_cb), + revert_changes_cb_(revert_changes_cb), profile_(NULL), closed_by_button_(false), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { @@ -113,27 +113,31 @@ string16 SettingsChangeGlobalError::GetBubbleViewMessage() { string16 SettingsChangeGlobalError::GetBubbleViewAcceptButtonLabel() { const Change& change = changes_.front(); + return l10n_util::GetStringFUTF16(kBubbleChangeSettingIDs[change.type], + change.new_setting); +} + +string16 SettingsChangeGlobalError::GetBubbleViewCancelButtonLabel() { + const Change& change = changes_.front(); return change.old_setting.empty() ? l10n_util::GetStringUTF16(IDS_SETTINGS_CHANGE_OPEN_SETTINGS) : l10n_util::GetStringFUTF16(kBubbleKeepSettingIDs[change.type], change.old_setting); } -string16 SettingsChangeGlobalError::GetBubbleViewCancelButtonLabel() { - const Change& change = changes_.front(); - return l10n_util::GetStringFUTF16(kBubbleChangeSettingIDs[change.type], - change.new_setting); +bool SettingsChangeGlobalError::IsAcceptButtonDefault() { + return false; } void SettingsChangeGlobalError::BubbleViewAcceptButtonPressed() { - VLOG(1) << "Restore changes"; - restore_changes_cb_.Run(); + VLOG(1) << "Apply changes"; + apply_changes_cb_.Run(); closed_by_button_ = true; } void SettingsChangeGlobalError::BubbleViewCancelButtonPressed() { - VLOG(1) << "Make changes"; - make_changes_cb_.Run(); + VLOG(1) << "Revert changes"; + revert_changes_cb_.Run(); closed_by_button_ = true; } diff --git a/chrome/browser/protector/settings_change_global_error.h b/chrome/browser/protector/settings_change_global_error.h index 2c17075..9e08df8 100644 --- a/chrome/browser/protector/settings_change_global_error.h +++ b/chrome/browser/protector/settings_change_global_error.h @@ -34,11 +34,11 @@ class SettingsChangeGlobalError : public GlobalError { typedef std::vector<Change> ChangesVector; // Creates new global error about settings changes |changes|. - // If user decides to apply changes, |make_changes_cb| is called. - // If user decides to keep previous settings, |restore_changes_cb| is called. + // If user decides to apply changes, |apply_changes_cb| is called. + // If user decides to keep previous settings, |revert_changes_cb| is called. SettingsChangeGlobalError(const ChangesVector& changes, - const base::Closure& make_changes_cb, - const base::Closure& restore_changes_cb); + const base::Closure& apply_changes_cb, + const base::Closure& revert_changes_cb); virtual ~SettingsChangeGlobalError(); // Displays a global error bubble for the default browser profile. @@ -56,6 +56,7 @@ class SettingsChangeGlobalError : public GlobalError { virtual string16 GetBubbleViewMessage() OVERRIDE; virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; + virtual bool IsAcceptButtonDefault() OVERRIDE; virtual void BubbleViewDidClose() OVERRIDE; virtual void BubbleViewAcceptButtonPressed() OVERRIDE; virtual void BubbleViewCancelButtonPressed() OVERRIDE; @@ -63,8 +64,8 @@ class SettingsChangeGlobalError : public GlobalError { private: ChangesVector changes_; - base::Closure make_changes_cb_; - base::Closure restore_changes_cb_; + base::Closure apply_changes_cb_; + base::Closure revert_changes_cb_; // Profile that we have been added to. Profile* profile_; diff --git a/chrome/browser/ui/global_error.cc b/chrome/browser/ui/global_error.cc index f2cf17c..bd817e5 100644 --- a/chrome/browser/ui/global_error.cc +++ b/chrome/browser/ui/global_error.cc @@ -34,3 +34,7 @@ void GlobalError::ShowBubbleView(Browser* browser) { int GlobalError::GetBubbleViewIconResourceID() { return IDR_INPUT_ALERT; } + +bool GlobalError::IsAcceptButtonDefault() { + return true; +} diff --git a/chrome/browser/ui/global_error.h b/chrome/browser/ui/global_error.h index ffac75e..10594fc 100644 --- a/chrome/browser/ui/global_error.h +++ b/chrome/browser/ui/global_error.h @@ -50,6 +50,9 @@ class GlobalError { // Returns the cancel button label for the bubble view. To hide the cancel // button return an empty string. virtual string16 GetBubbleViewCancelButtonLabel() = 0; + // Returns true if the accept button should be the default one (activated by + // Enter). Otherwise, the cancel button is default. + virtual bool IsAcceptButtonDefault(); // Called when the bubble view is closed. virtual void BubbleViewDidClose() = 0; // Called when the user clicks on the accept button. diff --git a/chrome/browser/ui/gtk/global_error_bubble.cc b/chrome/browser/ui/gtk/global_error_bubble.cc index 5577aec..0ff485f 100644 --- a/chrome/browser/ui/gtk/global_error_bubble.cc +++ b/chrome/browser/ui/gtk/global_error_bubble.cc @@ -91,7 +91,12 @@ GlobalErrorBubble::GlobalErrorBubble(Profile* profile, gtk_box_pack_start(GTK_BOX(bottom), accept_button, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(content), bottom, FALSE, FALSE, 0); - gtk_widget_grab_focus(accept_button); + if (error_->IsAcceptButtonDefault()) + gtk_widget_grab_focus(accept_button); + else if (cancel_button) + gtk_widget_grab_focus(cancel_button); + else + NOTREACHED(); g_signal_connect(accept_button, "clicked", G_CALLBACK(OnAcceptButtonThunk), this); diff --git a/chrome/browser/ui/views/global_error_bubble_view.cc b/chrome/browser/ui/views/global_error_bubble_view.cc index 00d15db7..76a6501 100644 --- a/chrome/browser/ui/views/global_error_bubble_view.cc +++ b/chrome/browser/ui/views/global_error_bubble_view.cc @@ -53,10 +53,11 @@ GlobalErrorBubbleView::GlobalErrorBubbleView(Browser* browser, message_label_->SetMultiLine(true); message_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); + bool accept_default = error_->IsAcceptButtonDefault(); string16 accept_string(error_->GetBubbleViewAcceptButtonLabel()); scoped_ptr<views::TextButton> accept_button( new views::NativeTextButton(this, UTF16ToWideHack(accept_string))); - accept_button->SetIsDefault(true); + accept_button->SetIsDefault(accept_default); accept_button->set_tag(TAG_ACCEPT_BUTTON); string16 cancel_string(error_->GetBubbleViewCancelButtonLabel()); @@ -64,6 +65,7 @@ GlobalErrorBubbleView::GlobalErrorBubbleView(Browser* browser, if (!cancel_string.empty()) { cancel_button.reset( new views::NativeTextButton(this, UTF16ToWideHack(cancel_string))); + cancel_button->SetIsDefault(!accept_default); cancel_button->set_tag(TAG_CANCEL_BUTTON); } |