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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.h
diff --git a/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.h b/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.h
index b73ee051f93638fc155300776afc08d881ab8afe..abf5c95af19d6efa6176ac2444fe3d19b3c144cb 100644
--- a/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.h
+++ b/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.h
@@ -7,6 +7,7 @@
#include "platform/PlatformExport.h"
#include "platform/weborigin/SecurityOrigin.h"
+#include "public/platform/WebFeaturePolicy.h"
#include "wtf/RefPtr.h"
#include "wtf/Vector.h"
#include "wtf/text/WTFString.h"
@@ -123,14 +124,23 @@ class PLATFORM_EXPORT FeaturePolicy final {
using FeatureList = const Vector<const FeaturePolicy::Feature*>;
+ // Converts a JSON feature policy string into a vector of whitelists, one for
+ // each feature specified. Unrecognized features are parsed and included
+ // but will be filtered out when the policy is constructed. If |messages| is
+ // not null, then any errors in the input will cause an error message to be
+ // appended to it.
+ static WebVector<WebFeaturePolicy::ParsedWhitelist> parseFeaturePolicy(
+ const String& policy,
+ const SecurityOrigin*,
+ Vector<String>* messages);
+
static std::unique_ptr<FeaturePolicy> createFromParentPolicy(
const FeaturePolicy* parent,
RefPtr<SecurityOrigin>);
- // Sets the declared policy from the Feature-Policy HTTP header. If the header
- // cannot be parsed, errors will be appended to the |messages| vector, if not
- // null.
- void setHeaderPolicy(const String&, Vector<String>* messages);
+ // Sets the declared policy from the parsed Feature-Policy HTTP header.
+ // Unrecognized features will be ignored.
+ void setHeaderPolicy(const WebVector<WebFeaturePolicy::ParsedWhitelist>&);
// Returns whether or not the given feature is enabled by this policy.
bool isFeatureEnabledForOrigin(const Feature&, const SecurityOrigin&) const;

Powered by Google App Engine
This is Rietveld 408576698