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_WEBSITE_SETTINGS_REGISTRY_H_ | 5 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_WEBSITE_SETTINGS_REGISTRY_H_ |
6 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_WEBSITE_SETTINGS_REGISTRY_H_ | 6 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_WEBSITE_SETTINGS_REGISTRY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
13 #include "components/content_settings/core/browser/website_settings_info.h" | 13 #include "components/content_settings/core/browser/website_settings_info.h" |
| 14 #include "components/content_settings/core/common/content_settings.h" |
14 #include "components/content_settings/core/common/content_settings_types.h" | 15 #include "components/content_settings/core/common/content_settings_types.h" |
15 | 16 |
16 namespace content_settings { | 17 namespace content_settings { |
17 | 18 |
18 // This class stores WebsiteSettingsInfo objects for each website setting in the | 19 // This class stores WebsiteSettingsInfo objects for each website setting in the |
19 // system and provides access to them. Global instances can be fetched and | 20 // system and provides access to them. Global instances can be fetched and |
20 // methods called from from any thread because all of its public methods are | 21 // methods called from from any thread because all of its public methods are |
21 // const. | 22 // const. |
22 class WebsiteSettingsRegistry { | 23 class WebsiteSettingsRegistry { |
23 public: | 24 public: |
24 static WebsiteSettingsRegistry* GetInstance(); | 25 static WebsiteSettingsRegistry* GetInstance(); |
25 | 26 |
26 const WebsiteSettingsInfo* Get(ContentSettingsType type) const; | 27 const WebsiteSettingsInfo* Get(ContentSettingsType type) const; |
27 const WebsiteSettingsInfo* GetByName(const std::string& name) const; | 28 const WebsiteSettingsInfo* GetByName(const std::string& name) const; |
28 | 29 |
29 private: | 30 private: |
| 31 friend class WebsiteSettingsRegistryTest; |
| 32 friend struct base::DefaultLazyInstanceTraits<WebsiteSettingsRegistry>; |
| 33 |
30 WebsiteSettingsRegistry(); | 34 WebsiteSettingsRegistry(); |
31 ~WebsiteSettingsRegistry(); | 35 ~WebsiteSettingsRegistry(); |
32 | 36 |
33 // Register a new WebsiteSettingsInfo. | 37 // Register a new website setting. This maps an arbitrary base::Value to an |
34 void Register(ContentSettingsType type, const std::string& name); | 38 // origin. |
| 39 void RegisterWebsiteSetting(ContentSettingsType type, |
| 40 const std::string& name); |
| 41 // Register a new content setting. This maps an ALLOW/ASK/BLOCK value (see the |
| 42 // ContentSetting enum) to an origin. |
| 43 void RegisterContentSetting(ContentSettingsType type, |
| 44 const std::string& name, |
| 45 ContentSetting initial_default_value); |
| 46 |
| 47 // Helper used by Register/RegisterPermission. |
| 48 void StoreWebsiteSettingsInfo(WebsiteSettingsInfo* info); |
35 | 49 |
36 ScopedVector<WebsiteSettingsInfo> website_settings_info_; | 50 ScopedVector<WebsiteSettingsInfo> website_settings_info_; |
37 | 51 |
38 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsRegistry); | 52 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsRegistry); |
39 friend class WebsiteSettingsRegistryTest; | |
40 friend struct base::DefaultLazyInstanceTraits<WebsiteSettingsRegistry>; | |
41 }; | 53 }; |
42 | 54 |
43 } // namespace content_settings | 55 } // namespace content_settings |
44 | 56 |
45 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_WEBSITE_SETTINGS_REGISTRY_H_ | 57 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_WEBSITE_SETTINGS_REGISTRY_H_ |
OLD | NEW |