OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_PROTECTOR_BASE_SETTING_CHANGE_H_ | 5 #ifndef CHROME_BROWSER_PROTECTOR_BASE_SETTING_CHANGE_H_ |
6 #define CHROME_BROWSER_PROTECTOR_BASE_SETTING_CHANGE_H_ | 6 #define CHROME_BROWSER_PROTECTOR_BASE_SETTING_CHANGE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 | 14 |
15 class TemplateURL; | 15 class TemplateURL; |
16 | 16 |
17 namespace protector { | 17 namespace protector { |
18 | 18 |
19 class Protector; | 19 class Protector; |
20 | 20 |
21 // Base class for setting change tracked by Protector. | 21 // Base class for setting change tracked by Protector. |
22 class BaseSettingChange { | 22 class BaseSettingChange { |
23 public: | 23 public: |
24 BaseSettingChange(); | 24 BaseSettingChange(); |
25 virtual ~BaseSettingChange(); | 25 virtual ~BaseSettingChange(); |
26 | 26 |
27 // Applies initial actions to the setting if needed. Must be called before | 27 // Applies initial actions to the setting if needed. Must be called before |
28 // any other calls are made, including text getters. Returns true if | 28 // any other calls are made, including text getters. |
29 // initialization was successful. | 29 // Returns true if initialization was successful. Otherwise, no other |
30 // calls should be made. | |
31 // Associates this change with |protector_| instance so overrides must | |
32 // call the base method. | |
whywhat
2011/11/21 14:51:21
This method cries to be a ctor...
Ivan Korotkov
2011/11/21 15:27:38
Kind of, but it's called asynchronously (to reset
| |
30 virtual bool Init(Protector* protector); | 33 virtual bool Init(Protector* protector); |
31 | 34 |
32 // Persists new setting if needed. | 35 // Persists new setting if needed. |
33 virtual void Apply(Protector* protector); | 36 virtual void Apply(); |
34 | 37 |
35 // Restores old setting if needed. | 38 // Restores old setting if needed. |
36 virtual void Discard(Protector* protector); | 39 virtual void Discard(); |
40 | |
41 // Called before the change is removed from the protector instance. | |
42 virtual void OnBeforeRemoved() = 0; | |
37 | 43 |
38 // Returns the wrench menu item and bubble title. | 44 // Returns the wrench menu item and bubble title. |
39 virtual string16 GetBubbleTitle() const = 0; | 45 virtual string16 GetBubbleTitle() const = 0; |
40 | 46 |
41 // Returns the bubble message text. | 47 // Returns the bubble message text. |
42 virtual string16 GetBubbleMessage() const = 0; | 48 virtual string16 GetBubbleMessage() const = 0; |
43 | 49 |
44 // Returns text for the button to apply the change with |Apply|. | 50 // Returns text for the button to apply the change with |Apply|. |
45 // Returns empty string if no apply button should be shown. | 51 // Returns empty string if no apply button should be shown. |
46 virtual string16 GetApplyButtonText() const = 0; | 52 virtual string16 GetApplyButtonText() const = 0; |
47 | 53 |
48 // Returns text for the button to discard the change with |Discard|. | 54 // Returns text for the button to discard the change with |Discard|. |
49 virtual string16 GetDiscardButtonText() const = 0; | 55 virtual string16 GetDiscardButtonText() const = 0; |
50 | 56 |
57 // Protector instance we've been associated with by an |Init| call. | |
58 Protector* protector() { return protector_; } | |
59 | |
51 private: | 60 private: |
61 Protector* protector_; | |
62 | |
52 DISALLOW_COPY_AND_ASSIGN(BaseSettingChange); | 63 DISALLOW_COPY_AND_ASSIGN(BaseSettingChange); |
53 }; | 64 }; |
54 | 65 |
55 // TODO(ivankr): CompositeSettingChange that incapsulates multiple | 66 // TODO(ivankr): CompositeSettingChange that incapsulates multiple |
56 // BaseSettingChange instances. | 67 // BaseSettingChange instances. |
57 | 68 |
58 // Allocates and initializes SettingChange implementation for default search | 69 // Allocates and initializes SettingChange implementation for default search |
59 // provider setting. Both |actual| and |backup| may be NULL if corresponding | 70 // provider setting. Both |actual| and |backup| may be NULL if corresponding |
60 // values are unknown or invalid. | 71 // values are unknown or invalid. |
61 BaseSettingChange* CreateDefaultSearchProviderChange( | 72 BaseSettingChange* CreateDefaultSearchProviderChange( |
62 const TemplateURL* actual, | 73 const TemplateURL* actual, |
63 const TemplateURL* backup); | 74 const TemplateURL* backup); |
64 | 75 |
65 } // namespace protector | 76 } // namespace protector |
66 | 77 |
67 #endif // CHROME_BROWSER_PROTECTOR_BASE_SETTING_CHANGE_H_ | 78 #endif // CHROME_BROWSER_PROTECTOR_BASE_SETTING_CHANGE_H_ |
OLD | NEW |