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

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

Issue 8590036: Protector strings and bubble/SettingsChange code refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile fix. 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/setting_change.h
diff --git a/chrome/browser/protector/setting_change.h b/chrome/browser/protector/setting_change.h
index 0a1e1d2910bebd3e7117d16202c40548da56be73..4b5ee84ea0bd15b4571a0287a069068159178b98 100644
--- a/chrome/browser/protector/setting_change.h
+++ b/chrome/browser/protector/setting_change.h
@@ -21,49 +21,42 @@ class Protector;
// Base class for setting change tracked by Protector.
class SettingChange {
public:
- // 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) {}
+ SettingChange() {}
virtual ~SettingChange() {}
- Type type() const { return type_; }
+ // Applies initial actions to the setting if needed. Must be called before
+ // any other calls are made, including text getters.
+ virtual void Init(Protector* protector) {}
+
+ // 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_;
-
DISALLOW_COPY_AND_ASSIGN(SettingChange);
};
-typedef std::vector<SettingChange*> SettingChangeVector;
-typedef void (SettingChange::*SettingChangeAction)(Protector*);
+// TODO(ivankr): CompositeSettingChange that incapsulates multiple
+// SettingChange instances.
// Allocates and initializes SettingChange implementation for default search
-// provider setting.
+// provider setting. Both |actual| and |backup| may be NULL if corresponding
+// values are unknown or invalid.
SettingChange* CreateDefaultSearchProviderChange(
const TemplateURL* actual,
const TemplateURL* backup);

Powered by Google App Engine
This is Rietveld 408576698