OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PREFS_CHANGE_H_ | 5 #ifndef CHROME_BROWSER_PROTECTOR_BASE_PREFS_CHANGE_H_ |
6 #define CHROME_BROWSER_PROTECTOR_BASE_PREFS_CHANGE_H_ | 6 #define CHROME_BROWSER_PROTECTOR_BASE_PREFS_CHANGE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/prefs/public/pref_change_registrar.h" | 11 #include "base/prefs/public/pref_change_registrar.h" |
| 12 #include "base/prefs/public/pref_observer.h" |
12 #include "chrome/browser/protector/base_setting_change.h" | 13 #include "chrome/browser/protector/base_setting_change.h" |
13 #include "content/public/browser/notification_observer.h" | |
14 | 14 |
15 namespace protector { | 15 namespace protector { |
16 | 16 |
17 // BaseSettingChange subclass for PrefService-managed settings changes. | 17 // BaseSettingChange subclass for PrefService-managed settings changes. |
18 class BasePrefsChange : public BaseSettingChange, | 18 class BasePrefsChange : public BaseSettingChange, |
19 public content::NotificationObserver { | 19 public PrefObserver { |
20 public: | 20 public: |
21 BasePrefsChange(); | 21 BasePrefsChange(); |
22 virtual ~BasePrefsChange(); | 22 virtual ~BasePrefsChange(); |
23 | 23 |
24 // BaseSettingChange overrides: | 24 // BaseSettingChange overrides: |
25 virtual bool Init(Profile* profile) OVERRIDE; | 25 virtual bool Init(Profile* profile) OVERRIDE; |
26 virtual void InitWhenDisabled(Profile* profile) OVERRIDE; | 26 virtual void InitWhenDisabled(Profile* profile) OVERRIDE; |
27 | 27 |
28 protected: | 28 protected: |
29 // Marks |this| to be dismissed when |pref_name| is changed. Should only be | 29 // Marks |this| to be dismissed when |pref_name| is changed. Should only be |
30 // called after Init. | 30 // called after Init. |
31 void DismissOnPrefChange(const std::string& pref_name); | 31 void DismissOnPrefChange(const std::string& pref_name); |
32 | 32 |
33 // Ignores any further changes to prefs. No further DismissOnPrefChange calls | 33 // Ignores any further changes to prefs. No further DismissOnPrefChange calls |
34 // can be made. | 34 // can be made. |
35 void IgnorePrefChanges(); | 35 void IgnorePrefChanges(); |
36 | 36 |
37 private: | 37 private: |
38 // content::NotificationObserver overrides: | 38 // PrefObserver overrides: |
39 virtual void Observe(int type, | 39 virtual void OnPreferenceChanged(PrefServiceBase* service, |
40 const content::NotificationSource& source, | 40 const std::string& pref_name) OVERRIDE; |
41 const content::NotificationDetails& details) OVERRIDE; | |
42 | 41 |
43 PrefChangeRegistrar pref_observer_; | 42 PrefChangeRegistrar pref_observer_; |
44 | 43 |
45 DISALLOW_COPY_AND_ASSIGN(BasePrefsChange); | 44 DISALLOW_COPY_AND_ASSIGN(BasePrefsChange); |
46 }; | 45 }; |
47 | 46 |
48 } // namespace protector | 47 } // namespace protector |
49 | 48 |
50 #endif // CHROME_BROWSER_PROTECTOR_BASE_PREFS_CHANGE_H_ | 49 #endif // CHROME_BROWSER_PROTECTOR_BASE_PREFS_CHANGE_H_ |
OLD | NEW |