OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_ | 5 #ifndef CHROME_BROWSER_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_ |
6 #define CHROME_BROWSER_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_ | 6 #define CHROME_BROWSER_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "chrome/browser/prefs/pref_hash_filter.h" | 12 #include "chrome/browser/prefs/pref_hash_filter.h" |
13 #include "chrome/browser/prefs/tracked/tracked_preference.h" | 13 #include "chrome/browser/prefs/tracked/tracked_preference.h" |
14 #include "chrome/browser/prefs/tracked/tracked_preference_helper.h" | 14 #include "chrome/browser/prefs/tracked/tracked_preference_helper.h" |
15 | 15 |
| 16 class TrackedPreferenceValidationObserver; |
| 17 |
16 // A TrackedSplitPreference must be tracking a dictionary pref. Each top-level | 18 // A TrackedSplitPreference must be tracking a dictionary pref. Each top-level |
17 // entry in its dictionary is tracked and enforced independently. | 19 // entry in its dictionary is tracked and enforced independently. An optional |
| 20 // observer is notified of the status of the preference during enforcement. |
18 // Note: preferences using this strategy must be kept in sync with | 21 // Note: preferences using this strategy must be kept in sync with |
19 // TrackedSplitPreferences in histograms.xml. | 22 // TrackedSplitPreferences in histograms.xml. |
20 class TrackedSplitPreference : public TrackedPreference { | 23 class TrackedSplitPreference : public TrackedPreference { |
21 public: | 24 public: |
22 // Constructs a TrackedSplitPreference. |pref_path| must be a dictionary pref. | 25 // Constructs a TrackedSplitPreference. |pref_path| must be a dictionary pref. |
23 TrackedSplitPreference( | 26 TrackedSplitPreference(const std::string& pref_path, |
24 const std::string& pref_path, | 27 size_t reporting_id, |
25 size_t reporting_id, | 28 size_t reporting_ids_count, |
26 size_t reporting_ids_count, | 29 PrefHashFilter::EnforcementLevel enforcement_level, |
27 PrefHashFilter::EnforcementLevel enforcement_level); | 30 TrackedPreferenceValidationObserver* observer); |
28 | 31 |
29 // TrackedPreference implementation. | 32 // TrackedPreference implementation. |
30 virtual void OnNewValue(const base::Value* value, | 33 virtual void OnNewValue(const base::Value* value, |
31 PrefHashStoreTransaction* transaction) const OVERRIDE; | 34 PrefHashStoreTransaction* transaction) const OVERRIDE; |
32 virtual bool EnforceAndReport( | 35 virtual bool EnforceAndReport( |
33 base::DictionaryValue* pref_store_contents, | 36 base::DictionaryValue* pref_store_contents, |
34 PrefHashStoreTransaction* transaction) const OVERRIDE; | 37 PrefHashStoreTransaction* transaction) const OVERRIDE; |
35 | 38 |
36 private: | 39 private: |
37 const std::string pref_path_; | 40 const std::string pref_path_; |
38 const TrackedPreferenceHelper helper_; | 41 const TrackedPreferenceHelper helper_; |
| 42 TrackedPreferenceValidationObserver* observer_; |
39 | 43 |
40 DISALLOW_COPY_AND_ASSIGN(TrackedSplitPreference); | 44 DISALLOW_COPY_AND_ASSIGN(TrackedSplitPreference); |
41 }; | 45 }; |
42 | 46 |
43 #endif // CHROME_BROWSER_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_ | 47 #endif // CHROME_BROWSER_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_ |
OLD | NEW |