OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UTILS_H_ | 5 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_UTILS_H_ |
6 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_UTILS_H_ | 6 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_UTILS_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
lazyboy
2017/06/30 18:11:40
Remove since std::unique_ptr is gone.
tbansal1
2017/06/30 18:32:31
Done.
| |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "components/content_settings/core/common/content_settings.h" | 13 #include "components/content_settings/core/common/content_settings.h" |
14 #include "components/content_settings/core/common/content_settings_pattern.h" | 14 #include "components/content_settings/core/common/content_settings_pattern.h" |
15 #include "components/content_settings/core/common/content_settings_types.h" | 15 #include "components/content_settings/core/common/content_settings_types.h" |
16 | 16 |
17 namespace base { | |
18 class Value; | |
19 } | |
20 | |
21 class HostContentSettingsMap; | 17 class HostContentSettingsMap; |
22 | 18 |
23 namespace content_settings { | 19 namespace content_settings { |
24 | 20 |
25 typedef std::pair<ContentSettingsPattern, ContentSettingsPattern> PatternPair; | 21 typedef std::pair<ContentSettingsPattern, ContentSettingsPattern> PatternPair; |
26 | 22 |
27 // Helper class to iterate over only the values in a map. | 23 // Helper class to iterate over only the values in a map. |
28 template <typename IteratorType, typename ReferenceType> | 24 template <typename IteratorType, typename ReferenceType> |
29 class MapValueIterator { | 25 class MapValueIterator { |
30 public: | 26 public: |
(...skipping 20 matching lines...) Expand all Loading... | |
51 const char kChromeDevToolsScheme[] = "chrome-devtools"; | 47 const char kChromeDevToolsScheme[] = "chrome-devtools"; |
52 const char kChromeUIScheme[] = "chrome"; | 48 const char kChromeUIScheme[] = "chrome"; |
53 const char kExtensionScheme[] = "chrome-extension"; | 49 const char kExtensionScheme[] = "chrome-extension"; |
54 | 50 |
55 std::string ContentSettingToString(ContentSetting setting); | 51 std::string ContentSettingToString(ContentSetting setting); |
56 | 52 |
57 // Converts a content setting string to the corresponding ContentSetting. | 53 // Converts a content setting string to the corresponding ContentSetting. |
58 // Returns true if |name| specifies a valid content setting, false otherwise. | 54 // Returns true if |name| specifies a valid content setting, false otherwise. |
59 bool ContentSettingFromString(const std::string& name, ContentSetting* setting); | 55 bool ContentSettingFromString(const std::string& name, ContentSetting* setting); |
60 | 56 |
61 // Converts |Value| to |ContentSetting|. | |
62 ContentSetting ValueToContentSetting(const base::Value* value); | |
63 | |
64 // Converts a |Value| to a |ContentSetting|. Returns true if |value| encodes | |
65 // a valid content setting, false otherwise. Note that |CONTENT_SETTING_DEFAULT| | |
66 // is encoded as a NULL value, so it is not allowed as an integer value. | |
67 bool ParseContentSettingValue(const base::Value* value, | |
68 ContentSetting* setting); | |
69 | |
70 PatternPair ParsePatternString(const std::string& pattern_str); | 57 PatternPair ParsePatternString(const std::string& pattern_str); |
71 | 58 |
72 std::string CreatePatternString( | 59 std::string CreatePatternString( |
73 const ContentSettingsPattern& item_pattern, | 60 const ContentSettingsPattern& item_pattern, |
74 const ContentSettingsPattern& top_level_frame_pattern); | 61 const ContentSettingsPattern& top_level_frame_pattern); |
75 | 62 |
76 // Returns a |base::Value*| representation of |setting| if |setting| is | |
77 // a valid content setting. Otherwise, returns a nullptr. | |
78 std::unique_ptr<base::Value> ContentSettingToValue(ContentSetting setting); | |
79 | |
80 // Populates |rules| with content setting rules for content types that are | 63 // Populates |rules| with content setting rules for content types that are |
81 // handled by the renderer. | 64 // handled by the renderer. |
82 void GetRendererContentSettingRules(const HostContentSettingsMap* map, | 65 void GetRendererContentSettingRules(const HostContentSettingsMap* map, |
83 RendererContentSettingRules* rules); | 66 RendererContentSettingRules* rules); |
84 | 67 |
85 // Returns true if setting |a| is more permissive than setting |b|. | 68 // Returns true if setting |a| is more permissive than setting |b|. |
86 bool IsMorePermissive(ContentSetting a, ContentSetting b); | 69 bool IsMorePermissive(ContentSetting a, ContentSetting b); |
87 | 70 |
88 } // namespace content_settings | 71 } // namespace content_settings |
89 | 72 |
90 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_UTILS_H_ | 73 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_UTILS_H_ |
OLD | NEW |