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

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

Issue 1318083005: Remove HostContentSettingsMap::ContentTypeHasCompoundValue function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-num-types-enum-3
Patch Set: Created 5 years, 2 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_REGISTRY_H_ 5 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_REGISTRY_H_
6 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_REGISTRY_H_ 6 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_REGISTRY_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/containers/scoped_ptr_map.h" 10 #include "base/containers/scoped_ptr_map.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "components/content_settings/core/browser/content_settings_info.h" 14 #include "components/content_settings/core/browser/content_settings_info.h"
15 #include "components/content_settings/core/browser/content_settings_utils.h"
15 #include "components/content_settings/core/browser/website_settings_info.h" 16 #include "components/content_settings/core/browser/website_settings_info.h"
16 #include "components/content_settings/core/common/content_settings.h" 17 #include "components/content_settings/core/common/content_settings.h"
17 #include "components/content_settings/core/common/content_settings_types.h" 18 #include "components/content_settings/core/common/content_settings_types.h"
18 19
19 namespace content_settings { 20 namespace content_settings {
20 21
21 class WebsiteSettingsRegistry; 22 class WebsiteSettingsRegistry;
22 23
23 // This class stores ContentSettingsInfo objects for each content setting in the 24 // This class stores ContentSettingsInfo objects for each content setting in the
24 // system and provides access to them. Global instances can be fetched and 25 // system and provides access to them. Global instances can be fetched and
25 // methods called from from any thread because all of its public methods are 26 // methods called from from any thread because all of its public methods are
26 // const. 27 // const.
27 class ContentSettingsRegistry { 28 class ContentSettingsRegistry {
28 public: 29 public:
30 using Map =
31 base::ScopedPtrMap<ContentSettingsType, scoped_ptr<ContentSettingsInfo>>;
32 using const_iterator = MapValueIterator<typename Map::const_iterator,
33 const ContentSettingsInfo*>;
34
29 static ContentSettingsRegistry* GetInstance(); 35 static ContentSettingsRegistry* GetInstance();
30 36
31 // Reset the instance for use inside tests. 37 // Reset the instance for use inside tests.
32 void ResetForTest(); 38 void ResetForTest();
33 39
34 const ContentSettingsInfo* Get(ContentSettingsType type) const; 40 const ContentSettingsInfo* Get(ContentSettingsType type) const;
35 41
42 const_iterator begin() const;
43 const_iterator end() const;
44
36 private: 45 private:
37 friend class ContentSettingsRegistryTest; 46 friend class ContentSettingsRegistryTest;
38 friend struct base::DefaultLazyInstanceTraits<ContentSettingsRegistry>; 47 friend struct base::DefaultLazyInstanceTraits<ContentSettingsRegistry>;
39 48
40 ContentSettingsRegistry(); 49 ContentSettingsRegistry();
41 ContentSettingsRegistry(WebsiteSettingsRegistry* website_settings_registry); 50 ContentSettingsRegistry(WebsiteSettingsRegistry* website_settings_registry);
42 ~ContentSettingsRegistry(); 51 ~ContentSettingsRegistry();
43 52
44 void Init(); 53 void Init();
45 54
46 // Register a new content setting. This maps an origin to an ALLOW/ASK/BLOCK 55 // Register a new content setting. This maps an origin to an ALLOW/ASK/BLOCK
47 // value (see the ContentSetting enum). 56 // value (see the ContentSetting enum).
48 void Register(ContentSettingsType type, 57 void Register(ContentSettingsType type,
49 const std::string& name, 58 const std::string& name,
50 ContentSetting initial_default_value, 59 ContentSetting initial_default_value,
51 WebsiteSettingsInfo::SyncStatus sync_status, 60 WebsiteSettingsInfo::SyncStatus sync_status,
52 const std::vector<std::string>& whitelisted_schemes); 61 const std::vector<std::string>& whitelisted_schemes);
53 62
54 base::ScopedPtrMap<ContentSettingsType, scoped_ptr<ContentSettingsInfo>> 63 Map content_settings_info_;
55 content_settings_info_;
56 WebsiteSettingsRegistry* website_settings_registry_; 64 WebsiteSettingsRegistry* website_settings_registry_;
57 65
58 DISALLOW_COPY_AND_ASSIGN(ContentSettingsRegistry); 66 DISALLOW_COPY_AND_ASSIGN(ContentSettingsRegistry);
59 }; 67 };
60 68
61 } // namespace content_settings 69 } // namespace content_settings
62 70
63 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_REGISTRY_H_ 71 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698