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

Side by Side Diff: components/content_settings/core/browser/website_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_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/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 "base/values.h" 14 #include "base/values.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 // This class stores WebsiteSettingsInfo objects for each website setting in the 22 // This class stores WebsiteSettingsInfo objects for each website setting in the
22 // system and provides access to them. Global instances can be fetched and 23 // system and provides access to them. Global instances can be fetched and
23 // methods called from from any thread because all of its public methods are 24 // methods called from from any thread because all of its public methods are
24 // const. 25 // const.
25 class WebsiteSettingsRegistry { 26 class WebsiteSettingsRegistry {
26 private:
27 // Helper class to iterate over only the values in a map.
28 template <typename IteratorType, typename ReferenceType>
29 class MapValueIterator {
30 public:
31 explicit MapValueIterator(IteratorType iterator) : iterator_(iterator) {}
32
33 bool operator!=(const MapValueIterator& other) const {
34 return iterator_ != other.iterator_;
35 }
36
37 MapValueIterator& operator++() {
38 ++iterator_;
39 return *this;
40 }
41
42 ReferenceType operator*() { return iterator_->second; }
43
44 private:
45 IteratorType iterator_;
46 };
47
48 public: 27 public:
49 typedef base::ScopedPtrMap<ContentSettingsType, 28 typedef base::ScopedPtrMap<ContentSettingsType,
50 scoped_ptr<WebsiteSettingsInfo>> Map; 29 scoped_ptr<WebsiteSettingsInfo>> Map;
51 typedef MapValueIterator<typename Map::const_iterator, 30 typedef MapValueIterator<typename Map::const_iterator,
52 const WebsiteSettingsInfo*> const_iterator; 31 const WebsiteSettingsInfo*> const_iterator;
53 32
54 static WebsiteSettingsRegistry* GetInstance(); 33 static WebsiteSettingsRegistry* GetInstance();
55 34
56 // Reset the instance for use inside tests. 35 // Reset the instance for use inside tests.
57 void ResetForTest(); 36 void ResetForTest();
(...skipping 25 matching lines...) Expand all
83 void Init(); 62 void Init();
84 63
85 Map website_settings_info_; 64 Map website_settings_info_;
86 65
87 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsRegistry); 66 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsRegistry);
88 }; 67 };
89 68
90 } // namespace content_settings 69 } // namespace content_settings
91 70
92 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_WEBSITE_SETTINGS_REGISTRY_H_ 71 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_WEBSITE_SETTINGS_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698