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

Unified Diff: chrome/browser/protector/setting_change.h

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
« no previous file with comments | « chrome/browser/protector/protector.cc ('k') | chrome/browser/protector/settings_change_global_error.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/protector/setting_change.h
===================================================================
--- chrome/browser/protector/setting_change.h (revision 110688)
+++ chrome/browser/protector/setting_change.h (working copy)
@@ -21,43 +21,49 @@
// Base class for setting change tracked by Protector.
class SettingChange {
public:
- SettingChange() {}
+ // IDs of changes Protector currently tracks.
+ enum Type {
+ // Default search engine has been changed.
+ kSearchEngineChanged,
+
+ // Home page has been changed.
+ kHomePageChanged,
+ };
+
+ explicit SettingChange(Type type) : type_(type) {}
virtual ~SettingChange() {}
- // Applies initial actions to the setting if needed. Must be called before
- // any other calls are made, including text getters. Returns true if
- // initialization was successful.
- virtual bool Init(Protector* protector) { return true; }
+ Type type() const { return type_; }
- // Persists new setting if needed.
- virtual void Apply(Protector* protector) {}
+ // Returns the old setting presentation to be shown to user.
+ // Returns empty string if the old setting is unavailable.
+ virtual string16 GetOldSetting() const = 0;
- // Restores old setting if needed.
- virtual void Discard(Protector* protector) {}
+ // Returns the new setting presentation to be shown to user.
+ virtual string16 GetNewSetting() const = 0;
- // Returns the wrench menu item and bubble title.
- virtual string16 GetTitle() const = 0;
+ // Persists new setting if needed.
+ virtual void Accept(Protector* protector) {}
- // Returns the bubble message text.
- virtual string16 GetMessage() const = 0;
+ // Restores old setting value if needed.
+ virtual void Revert(Protector* protector) {}
- // Returns text for the button to apply the change with |Apply|.
- // Returns empty string if no apply button should be shown.
- virtual string16 GetApplyButtonText() const = 0;
+ // Called when user ignored the change.
+ virtual void DoDefault(Protector* protector) {}
- // Returns text for the button to discard the change with |Discard|.
- virtual string16 GetDiscardButtonText() const = 0;
+ private:
+ // Type of the change. Used for strings lookup by UI.
+ // TODO(avayvod): Refactor string selection logic via polymorphism.
+ Type type_;
- private:
DISALLOW_COPY_AND_ASSIGN(SettingChange);
};
-// TODO(ivankr): CompositeSettingChange that incapsulates multiple
-// SettingChange instances.
+typedef std::vector<SettingChange*> SettingChangeVector;
+typedef void (SettingChange::*SettingChangeAction)(Protector*);
// Allocates and initializes SettingChange implementation for default search
-// provider setting. Both |actual| and |backup| may be NULL if corresponding
-// values are unknown or invalid.
+// provider setting.
SettingChange* CreateDefaultSearchProviderChange(
const TemplateURL* actual,
const TemplateURL* backup);
« no previous file with comments | « chrome/browser/protector/protector.cc ('k') | chrome/browser/protector/settings_change_global_error.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698