| 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);
|
|
|