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

Side by Side Diff: components/content_settings/core/browser/content_settings_pref.h

Issue 2812113004: Write last_modified date to Content Settings in the PrefProvider (Closed)
Patch Set: Fix Android compilation Created 3 years, 8 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_H_ 5 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_H_
6 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_H_ 6 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 25 matching lines...) Expand all
36 typedef base::Callback<void(const ContentSettingsPattern&, 36 typedef base::Callback<void(const ContentSettingsPattern&,
37 const ContentSettingsPattern&, 37 const ContentSettingsPattern&,
38 ContentSettingsType, 38 ContentSettingsType,
39 const std::string&)> NotifyObserversCallback; 39 const std::string&)> NotifyObserversCallback;
40 40
41 ContentSettingsPref(ContentSettingsType content_type, 41 ContentSettingsPref(ContentSettingsType content_type,
42 PrefService* prefs, 42 PrefService* prefs,
43 PrefChangeRegistrar* registrar, 43 PrefChangeRegistrar* registrar,
44 const std::string& pref_name, 44 const std::string& pref_name,
45 bool incognito, 45 bool incognito,
46 bool store_last_modified,
46 NotifyObserversCallback notify_callback); 47 NotifyObserversCallback notify_callback);
47 ~ContentSettingsPref(); 48 ~ContentSettingsPref();
48 49
49 // Returns nullptr to indicate the RuleIterator is empty. 50 // Returns nullptr to indicate the RuleIterator is empty.
50 std::unique_ptr<RuleIterator> GetRuleIterator( 51 std::unique_ptr<RuleIterator> GetRuleIterator(
51 const ResourceIdentifier& resource_identifier, 52 const ResourceIdentifier& resource_identifier,
52 bool incognito) const; 53 bool incognito) const;
53 54
54 bool SetWebsiteSetting(const ContentSettingsPattern& primary_pattern, 55 bool SetWebsiteSetting(const ContentSettingsPattern& primary_pattern,
55 const ContentSettingsPattern& secondary_pattern, 56 const ContentSettingsPattern& secondary_pattern,
(...skipping 14 matching lines...) Expand all
70 // into the |value_map_|. The |value_map_| is cleared first. 71 // into the |value_map_|. The |value_map_| is cleared first.
71 void ReadContentSettingsFromPref(); 72 void ReadContentSettingsFromPref();
72 73
73 // Callback for changes in the pref with the same name. 74 // Callback for changes in the pref with the same name.
74 void OnPrefChanged(); 75 void OnPrefChanged();
75 76
76 // Update the preference that stores content settings exceptions and syncs the 77 // Update the preference that stores content settings exceptions and syncs the
77 // value to the obsolete preference. When calling this function, |lock_| 78 // value to the obsolete preference. When calling this function, |lock_|
78 // should not be held, since this function will send out notifications of 79 // should not be held, since this function will send out notifications of
79 // preference changes. 80 // preference changes.
80 void UpdatePref( 81 void UpdatePref(const ContentSettingsPattern& primary_pattern,
81 const ContentSettingsPattern& primary_pattern, 82 const ContentSettingsPattern& secondary_pattern,
82 const ContentSettingsPattern& secondary_pattern, 83 const ResourceIdentifier& resource_identifier,
83 const ResourceIdentifier& resource_identifier, 84 const base::Time last_modified,
84 const base::Value* value); 85 const base::Value* value);
85 86
86 static void CanonicalizeContentSettingsExceptions( 87 static void CanonicalizeContentSettingsExceptions(
87 base::DictionaryValue* all_settings_dictionary); 88 base::DictionaryValue* all_settings_dictionary);
88 89
89 // In the debug mode, asserts that |lock_| is not held by this thread. It's 90 // In the debug mode, asserts that |lock_| is not held by this thread. It's
90 // ok if some other thread holds |lock_|, as long as it will eventually 91 // ok if some other thread holds |lock_|, as long as it will eventually
91 // release it. 92 // release it.
92 void AssertLockNotHeld() const; 93 void AssertLockNotHeld() const;
93 94
94 // The type of content settings stored in this pref. 95 // The type of content settings stored in this pref.
95 ContentSettingsType content_type_; 96 ContentSettingsType content_type_;
96 97
97 // Weak; owned by the Profile and reset in ShutdownOnUIThread. 98 // Weak; owned by the Profile and reset in ShutdownOnUIThread.
98 PrefService* prefs_; 99 PrefService* prefs_;
99 100
100 // Owned by the PrefProvider. 101 // Owned by the PrefProvider.
101 PrefChangeRegistrar* registrar_; 102 PrefChangeRegistrar* registrar_;
102 103
103 // Name of the dictionary preference managed by this class. 104 // Name of the dictionary preference managed by this class.
104 const std::string& pref_name_; 105 const std::string& pref_name_;
105 106
106 bool is_incognito_; 107 bool is_incognito_;
107 108
109 bool store_last_modified_;
110
108 // Whether we are currently updating preferences, this is used to ignore 111 // Whether we are currently updating preferences, this is used to ignore
109 // notifications from the preferences service that we triggered ourself. 112 // notifications from the preferences service that we triggered ourself.
110 bool updating_preferences_; 113 bool updating_preferences_;
111 114
112 OriginIdentifierValueMap value_map_; 115 OriginIdentifierValueMap value_map_;
113 116
114 OriginIdentifierValueMap incognito_value_map_; 117 OriginIdentifierValueMap incognito_value_map_;
115 118
116 NotifyObserversCallback notify_callback_; 119 NotifyObserversCallback notify_callback_;
117 120
118 // Used around accesses to the value map objects to guarantee thread safety. 121 // Used around accesses to the value map objects to guarantee thread safety.
119 mutable base::Lock lock_; 122 mutable base::Lock lock_;
120 123
121 base::ThreadChecker thread_checker_; 124 base::ThreadChecker thread_checker_;
122 125
123 DISALLOW_COPY_AND_ASSIGN(ContentSettingsPref); 126 DISALLOW_COPY_AND_ASSIGN(ContentSettingsPref);
124 }; 127 };
125 128
126 } // namespace content_settings 129 } // namespace content_settings
127 130
128 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_H_ 131 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698