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

Side by Side Diff: third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.h

Issue 2520223002: Replicate a parsed feature policy representation so it doesn't need to be parsed in the browser pro… (Closed)
Patch Set: Fp2 Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 FeaturePolicy_h 5 #ifndef FeaturePolicy_h
6 #define FeaturePolicy_h 6 #define FeaturePolicy_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/weborigin/SecurityOrigin.h" 9 #include "platform/weborigin/SecurityOrigin.h"
10 #include "public/platform/WebFeaturePolicy.h"
10 #include "wtf/RefPtr.h" 11 #include "wtf/RefPtr.h"
11 #include "wtf/Vector.h" 12 #include "wtf/Vector.h"
12 #include "wtf/text/WTFString.h" 13 #include "wtf/text/WTFString.h"
13 14
14 #include <memory> 15 #include <memory>
15 16
16 namespace blink { 17 namespace blink {
17 18
18 // Feature Policy is a mechanism for controlling the availability of web 19 // Feature Policy is a mechanism for controlling the availability of web
19 // platform features in a frame, including all embedded frames. It can be used 20 // platform features in a frame, including all embedded frames. It can be used
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // The name of the feature, as it should appear in a policy string 117 // The name of the feature, as it should appear in a policy string
117 const char* const featureName; 118 const char* const featureName;
118 119
119 // Controls whether the feature should be available in the platform by 120 // Controls whether the feature should be available in the platform by
120 // default, in the absence of any declared policy. 121 // default, in the absence of any declared policy.
121 FeatureDefault defaultPolicy; 122 FeatureDefault defaultPolicy;
122 }; 123 };
123 124
124 using FeatureList = const Vector<const FeaturePolicy::Feature*>; 125 using FeatureList = const Vector<const FeaturePolicy::Feature*>;
125 126
127 // Converts a JSON feature policy string into a vector of whitelists, one for
128 // each feature specified. Unrecognized features are parsed and included
129 // but will be filtered out when the policy is constructed. If |messages| is
130 // not null, then any errors in the input will cause an error message to be
131 // appended to it.
132 static WebVector<WebFeaturePolicy::ParsedWhitelist> parseFeaturePolicy(
133 const String& policy,
134 const SecurityOrigin*,
135 Vector<String>* messages);
136
126 static std::unique_ptr<FeaturePolicy> createFromParentPolicy( 137 static std::unique_ptr<FeaturePolicy> createFromParentPolicy(
127 const FeaturePolicy* parent, 138 const FeaturePolicy* parent,
128 RefPtr<SecurityOrigin>); 139 RefPtr<SecurityOrigin>);
129 140
130 // Sets the declared policy from the Feature-Policy HTTP header. If the header 141 // Sets the declared policy from the parsed Feature-Policy HTTP header.
131 // cannot be parsed, errors will be appended to the |messages| vector, if not 142 // Unrecognized features will be ignored.
132 // null. 143 void setHeaderPolicy(const WebVector<WebFeaturePolicy::ParsedWhitelist>&);
133 void setHeaderPolicy(const String&, Vector<String>* messages);
134 144
135 // Returns whether or not the given feature is enabled by this policy. 145 // Returns whether or not the given feature is enabled by this policy.
136 bool isFeatureEnabledForOrigin(const Feature&, const SecurityOrigin&) const; 146 bool isFeatureEnabledForOrigin(const Feature&, const SecurityOrigin&) const;
137 147
138 // Returns whether or not the given feature is enabled for the frame that owns 148 // Returns whether or not the given feature is enabled for the frame that owns
139 // the policy. 149 // the policy.
140 bool isFeatureEnabled(const Feature&) const; 150 bool isFeatureEnabled(const Feature&) const;
141 151
142 // Returns the list of features which can be controlled by Feature Policy. 152 // Returns the list of features which can be controlled by Feature Policy.
143 static FeatureList& getDefaultFeatureList(); 153 static FeatureList& getDefaultFeatureList();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 extern const PLATFORM_EXPORT FeaturePolicy::Feature kPushFeature; 195 extern const PLATFORM_EXPORT FeaturePolicy::Feature kPushFeature;
186 extern const PLATFORM_EXPORT FeaturePolicy::Feature kSyncScript; 196 extern const PLATFORM_EXPORT FeaturePolicy::Feature kSyncScript;
187 extern const PLATFORM_EXPORT FeaturePolicy::Feature kSyncXHR; 197 extern const PLATFORM_EXPORT FeaturePolicy::Feature kSyncXHR;
188 extern const PLATFORM_EXPORT FeaturePolicy::Feature kUsermedia; 198 extern const PLATFORM_EXPORT FeaturePolicy::Feature kUsermedia;
189 extern const PLATFORM_EXPORT FeaturePolicy::Feature kVibrateFeature; 199 extern const PLATFORM_EXPORT FeaturePolicy::Feature kVibrateFeature;
190 extern const PLATFORM_EXPORT FeaturePolicy::Feature kWebRTC; 200 extern const PLATFORM_EXPORT FeaturePolicy::Feature kWebRTC;
191 201
192 } // namespace blink 202 } // namespace blink
193 203
194 #endif // FeaturePolicy_h 204 #endif // FeaturePolicy_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698