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

Unified Diff: chrome/browser/protector/settings_change_global_error.cc

Issue 8586050: Revert 110684 - Protector strings and bubble/SettingsChange code refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/protector/settings_change_global_error.cc
===================================================================
--- chrome/browser/protector/settings_change_global_error.cc (revision 110688)
+++ chrome/browser/protector/settings_change_global_error.cc (working copy)
@@ -15,6 +15,9 @@
#include "chrome/browser/ui/global_error_service.h"
#include "chrome/browser/ui/global_error_service_factory.h"
#include "content/public/browser/browser_thread.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
using content::BrowserThread;
@@ -25,21 +28,58 @@
// Timeout before the global error is removed (wrench menu item disappears).
const int kMenuItemDisplayPeriodMs = 10*60*1000; // 10 min
+// IDs of menu item labels.
+const int kMenuItemLabelIDs[] = {
+ IDS_SEARCH_ENGINE_CHANGE_WRENCH_MENU_ITEM,
+ IDS_HOMEPAGE_CHANGE_WRENCH_MENU_ITEM
+};
+
+// IDs of bubble title messages.
+const int kBubbleTitleIDs[] = {
+ IDS_SEARCH_ENGINE_CHANGE_BUBBLE_TITLE,
+ IDS_HOMEPAGE_CHANGE_BUBBLE_TITLE
+};
+
+// IDs of bubble text messages.
+const int kBubbleMessageIDs[] = {
+ IDS_SEARCH_ENGINE_CHANGE_BUBBLE_TEXT,
+ IDS_HOMEPAGE_CHANGE_BUBBLE_TEXT
+};
+
+// IDs of bubble text messages when the old setting is unknown.
+const int kBubbleMessageOldUnknownIDs[] = {
+ IDS_SEARCH_ENGINE_CHANGE_UNKNOWN_BUBBLE_TEXT,
+ IDS_HOMEPAGE_CHANGE_UNKNOWN_BUBBLE_TEXT
+};
+
+// IDs of "Keep Setting" button titles.
+const int kBubbleKeepSettingIDs[] = {
+ IDS_SEARCH_ENGINE_CHANGE_RESTORE,
+ IDS_HOMEPAGE_CHANGE_RESTORE
+};
+
+// IDs of "Change Setting" button titles.
+const int kBubbleChangeSettingIDs[] = {
+ IDS_SEARCH_ENGINE_CHANGE_APPLY,
+ IDS_HOMEPAGE_CHANGE_APPLY
+};
+
} // namespace
SettingsChangeGlobalError::SettingsChangeGlobalError(
- SettingChange* change,
+ const SettingChangeVector& changes,
SettingsChangeGlobalErrorDelegate* delegate)
- : change_(change),
+ : changes_(changes),
delegate_(delegate),
profile_(NULL),
browser_(NULL),
closed_by_button_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
- DCHECK(delegate_);
+ DCHECK(changes.size() > 0);
}
SettingsChangeGlobalError::~SettingsChangeGlobalError() {
+ STLDeleteElements(&changes_);
}
bool SettingsChangeGlobalError::HasBadge() {
@@ -54,8 +94,12 @@
return IDC_SHOW_SETTINGS_CHANGES;
}
+// TODO(ivankr): Currently the menu item/bubble only displays a warning about
+// the first change. We want to fix this so that a single menu item/bubble
+// can display warning about multiple changes.
+
string16 SettingsChangeGlobalError::MenuItemLabel() {
- return change_->GetTitle();
+ return l10n_util::GetStringUTF16(kMenuItemLabelIDs[changes_.front()->type()]);
}
void SettingsChangeGlobalError::ExecuteMenuItem(Browser* browser) {
@@ -70,37 +114,58 @@
}
string16 SettingsChangeGlobalError::GetBubbleViewTitle() {
- return change_->GetTitle();
+ return l10n_util::GetStringUTF16(kBubbleTitleIDs[changes_.front()->type()]);
}
string16 SettingsChangeGlobalError::GetBubbleViewMessage() {
- return change_->GetMessage();
+ SettingChange* change = changes_.front();
+ const string16& old_setting = change->GetOldSetting();
+ if (old_setting.empty()) {
+ return l10n_util::GetStringFUTF16(
+ kBubbleMessageOldUnknownIDs[change->type()],
+ change->GetNewSetting());
+ } else {
+ return l10n_util::GetStringFUTF16(
+ kBubbleMessageIDs[change->type()],
+ old_setting,
+ change->GetNewSetting());
+ }
}
-// The Accept and Revert buttons are swapped like the 'server' and 'client'
-// concepts in X11. Accept button (the default one) discards changes
-// (keeps using previous setting) while cancel button applies changes
-// (switches to the new setting). This is sick and blows my mind. - ivankr
-
string16 SettingsChangeGlobalError::GetBubbleViewAcceptButtonLabel() {
- return change_->GetDiscardButtonText();
+ SettingChange* change = changes_.front();
+ string16 old_setting = change->GetOldSetting();
+ if (old_setting.empty()) {
+ return l10n_util::GetStringUTF16(IDS_SETTINGS_CHANGE_OPEN_SETTINGS);
+ } else {
+ return l10n_util::GetStringFUTF16(
+ kBubbleKeepSettingIDs[change->type()],
+ old_setting);
+ }
}
string16 SettingsChangeGlobalError::GetBubbleViewCancelButtonLabel() {
- return change_->GetApplyButtonText();
+ SettingChange* change = changes_.front();
+ return l10n_util::GetStringFUTF16(kBubbleChangeSettingIDs[change->type()],
+ change->GetNewSetting());
}
void SettingsChangeGlobalError::BubbleViewAcceptButtonPressed() {
closed_by_button_ = true;
- delegate_->OnDiscardChange();
+ DCHECK(delegate_);
+ VLOG(1) << "Discard changes";
+ delegate_->OnDiscardChanges();
}
void SettingsChangeGlobalError::BubbleViewCancelButtonPressed() {
closed_by_button_ = true;
- delegate_->OnApplyChange();
+ DCHECK(delegate_);
+ VLOG(1) << "Apply changes";
+ delegate_->OnApplyChanges();
}
void SettingsChangeGlobalError::RemoveFromProfile() {
+ DCHECK(delegate_);
if (profile_)
GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(this);
if (!closed_by_button_)

Powered by Google App Engine
This is Rietveld 408576698