| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_PROTECTOR_SETTING_CHANGE_H_ |
| 6 #define CHROME_BROWSER_PROTECTOR_SETTING_CHANGE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "base/string16.h" |
| 14 |
| 15 class TemplateURL; |
| 16 |
| 17 namespace protector { |
| 18 |
| 19 class Protector; |
| 20 |
| 21 // Base class for setting change tracked by Protector. |
| 22 class SettingChange { |
| 23 public: |
| 24 // IDs of changes Protector currently tracks. |
| 25 enum Type { |
| 26 // Default search engine has been changed. |
| 27 kSearchEngineChanged, |
| 28 |
| 29 // Home page has been changed. |
| 30 kHomePageChanged, |
| 31 }; |
| 32 |
| 33 explicit SettingChange(Type type) : type_(type) {} |
| 34 virtual ~SettingChange() {} |
| 35 |
| 36 Type type() const { return type_; } |
| 37 |
| 38 // Returns the old setting presentation to be shown to user. |
| 39 // Returns empty string if the old setting is unavailable. |
| 40 virtual string16 GetOldSetting() const = 0; |
| 41 |
| 42 // Returns the new setting presentation to be shown to user. |
| 43 virtual string16 GetNewSetting() const = 0; |
| 44 |
| 45 // Persists new setting if needed. |
| 46 virtual void Accept(Protector* protector) {} |
| 47 |
| 48 // Restores old setting value if needed. |
| 49 virtual void Revert(Protector* protector) {} |
| 50 |
| 51 // Called when user ignored the change. |
| 52 virtual void DoDefault(Protector* protector) {} |
| 53 |
| 54 private: |
| 55 // Type of the change. Used for strings lookup by UI. |
| 56 // TODO(avayvod): Refactor string selection logic via polymorphism. |
| 57 Type type_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(SettingChange); |
| 60 }; |
| 61 |
| 62 typedef std::vector<SettingChange*> SettingChangeVector; |
| 63 typedef void (SettingChange::*SettingChangeAction)(Protector*); |
| 64 |
| 65 // Allocates and initializes SettingChange implementation for default search |
| 66 // provider setting. |
| 67 SettingChange* CreateDefaultSearchProviderChange( |
| 68 const TemplateURL* actual, |
| 69 const TemplateURL* backup); |
| 70 |
| 71 } // namespace protector |
| 72 |
| 73 #endif // CHROME_BROWSER_PROTECTOR_SETTING_CHANGE_H_ |
| OLD | NEW |