| OLD | NEW |
| 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> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "components/content_settings/core/browser/content_settings_origin_ident
ifier_value_map.h" | 17 #include "components/content_settings/core/browser/content_settings_origin_ident
ifier_value_map.h" |
| 18 #include "components/content_settings/core/browser/content_settings_provider.h" | 18 #include "components/content_settings/core/browser/content_settings_provider.h" |
| 19 #include "components/content_settings/core/common/content_settings_pattern.h" | 19 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 20 #include "components/content_settings/core/common/content_settings_types.h" | 20 #include "components/content_settings/core/common/content_settings_types.h" |
| 21 | 21 |
| 22 class PrefService; | 22 class PrefService; |
| 23 class PrefChangeRegistrar; | 23 class PrefChangeRegistrar; |
| 24 | 24 |
| 25 namespace base { | 25 namespace base { |
| 26 class Clock; | |
| 27 class DictionaryValue; | 26 class DictionaryValue; |
| 28 } | 27 } |
| 29 | 28 |
| 30 namespace content_settings { | 29 namespace content_settings { |
| 31 | 30 |
| 32 class RuleIterator; | 31 class RuleIterator; |
| 33 | 32 |
| 34 // Represents a single pref for reading/writing content settings of one type. | 33 // Represents a single pref for reading/writing content settings of one type. |
| 35 class ContentSettingsPref { | 34 class ContentSettingsPref { |
| 36 public: | 35 public: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 54 | 53 |
| 55 bool SetWebsiteSetting(const ContentSettingsPattern& primary_pattern, | 54 bool SetWebsiteSetting(const ContentSettingsPattern& primary_pattern, |
| 56 const ContentSettingsPattern& secondary_pattern, | 55 const ContentSettingsPattern& secondary_pattern, |
| 57 const ResourceIdentifier& resource_identifier, | 56 const ResourceIdentifier& resource_identifier, |
| 58 base::Value* value); | 57 base::Value* value); |
| 59 | 58 |
| 60 void ClearPref(); | 59 void ClearPref(); |
| 61 | 60 |
| 62 void ClearAllContentSettingsRules(); | 61 void ClearAllContentSettingsRules(); |
| 63 | 62 |
| 64 void UpdateLastUsage(const ContentSettingsPattern& primary_pattern, | |
| 65 const ContentSettingsPattern& secondary_pattern, | |
| 66 base::Clock* clock); | |
| 67 | |
| 68 base::Time GetLastUsage(const ContentSettingsPattern& primary_pattern, | |
| 69 const ContentSettingsPattern& secondary_pattern); | |
| 70 | |
| 71 size_t GetNumExceptions(); | 63 size_t GetNumExceptions(); |
| 72 | 64 |
| 73 // Tries to lock |lock_|. If successful, returns true and releases the lock. | 65 // Tries to lock |lock_|. If successful, returns true and releases the lock. |
| 74 bool TryLockForTesting() const; | 66 bool TryLockForTesting() const; |
| 75 | 67 |
| 76 private: | 68 private: |
| 77 // Reads all content settings exceptions from the preference and loads them | 69 // Reads all content settings exceptions from the preference and loads them |
| 78 // into the |value_map_|. The |value_map_| is cleared first. | 70 // into the |value_map_|. The |value_map_| is cleared first. |
| 79 void ReadContentSettingsFromPref(); | 71 void ReadContentSettingsFromPref(); |
| 80 | 72 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 mutable base::Lock lock_; | 119 mutable base::Lock lock_; |
| 128 | 120 |
| 129 base::ThreadChecker thread_checker_; | 121 base::ThreadChecker thread_checker_; |
| 130 | 122 |
| 131 DISALLOW_COPY_AND_ASSIGN(ContentSettingsPref); | 123 DISALLOW_COPY_AND_ASSIGN(ContentSettingsPref); |
| 132 }; | 124 }; |
| 133 | 125 |
| 134 } // namespace content_settings | 126 } // namespace content_settings |
| 135 | 127 |
| 136 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_H_ | 128 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_H_ |
| OLD | NEW |