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

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

Issue 2938163002: Store base::Value in ContentSettingPatternSource instead of an enum (Closed)
Patch Set: rebased Created 3 years, 5 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 (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>
9 #include <string> 8 #include <string>
10 #include <utility> 9 #include <utility>
11 10
12 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
13 #include "components/content_settings/core/common/content_settings.h" 12 #include "components/content_settings/core/common/content_settings.h"
14 #include "components/content_settings/core/common/content_settings_pattern.h" 13 #include "components/content_settings/core/common/content_settings_pattern.h"
15 #include "components/content_settings/core/common/content_settings_types.h" 14 #include "components/content_settings/core/common/content_settings_types.h"
16 15
17 namespace base {
18 class Value;
19 }
20
21 class HostContentSettingsMap; 16 class HostContentSettingsMap;
22 17
23 namespace content_settings { 18 namespace content_settings {
24 19
25 typedef std::pair<ContentSettingsPattern, ContentSettingsPattern> PatternPair; 20 typedef std::pair<ContentSettingsPattern, ContentSettingsPattern> PatternPair;
26 21
27 // Helper class to iterate over only the values in a map. 22 // Helper class to iterate over only the values in a map.
28 template <typename IteratorType, typename ReferenceType> 23 template <typename IteratorType, typename ReferenceType>
29 class MapValueIterator { 24 class MapValueIterator {
30 public: 25 public:
(...skipping 20 matching lines...) Expand all
51 const char kChromeDevToolsScheme[] = "chrome-devtools"; 46 const char kChromeDevToolsScheme[] = "chrome-devtools";
52 const char kChromeUIScheme[] = "chrome"; 47 const char kChromeUIScheme[] = "chrome";
53 const char kExtensionScheme[] = "chrome-extension"; 48 const char kExtensionScheme[] = "chrome-extension";
54 49
55 std::string ContentSettingToString(ContentSetting setting); 50 std::string ContentSettingToString(ContentSetting setting);
56 51
57 // Converts a content setting string to the corresponding ContentSetting. 52 // Converts a content setting string to the corresponding ContentSetting.
58 // Returns true if |name| specifies a valid content setting, false otherwise. 53 // Returns true if |name| specifies a valid content setting, false otherwise.
59 bool ContentSettingFromString(const std::string& name, ContentSetting* setting); 54 bool ContentSettingFromString(const std::string& name, ContentSetting* setting);
60 55
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); 56 PatternPair ParsePatternString(const std::string& pattern_str);
71 57
72 std::string CreatePatternString( 58 std::string CreatePatternString(
73 const ContentSettingsPattern& item_pattern, 59 const ContentSettingsPattern& item_pattern,
74 const ContentSettingsPattern& top_level_frame_pattern); 60 const ContentSettingsPattern& top_level_frame_pattern);
75 61
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 62 // Populates |rules| with content setting rules for content types that are
81 // handled by the renderer. 63 // handled by the renderer.
82 void GetRendererContentSettingRules(const HostContentSettingsMap* map, 64 void GetRendererContentSettingRules(const HostContentSettingsMap* map,
83 RendererContentSettingRules* rules); 65 RendererContentSettingRules* rules);
84 66
85 // Returns true if setting |a| is more permissive than setting |b|. 67 // Returns true if setting |a| is more permissive than setting |b|.
86 bool IsMorePermissive(ContentSetting a, ContentSetting b); 68 bool IsMorePermissive(ContentSetting a, ContentSetting b);
87 69
88 } // namespace content_settings 70 } // namespace content_settings
89 71
90 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_UTILS_H_ 72 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698