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

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: 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..0f9b26dce99358a259d8ed553b94d0745adb0998 100644
--- a/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.h
+++ b/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.h
@@ -7,9 +7,10 @@
#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"
+#include "wtf/Vector.h"
#include <memory>
@@ -123,6 +124,15 @@ class PLATFORM_EXPORT FeaturePolicy final {
using FeatureList = const Vector<const FeaturePolicy::Feature*>;
+ // Converts a list of JSON feature policy items into a mapping of features to
+ // whitelists. For future compatibility, unrecognized features are simply
+ // ignored, as are unparseable origins. 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* origin,
+ Vector<String>* messages);
+
static std::unique_ptr<FeaturePolicy> createFromParentPolicy(
const FeaturePolicy* parent,
RefPtr<SecurityOrigin>);
@@ -130,7 +140,7 @@ class PLATFORM_EXPORT FeaturePolicy final {
// 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);
+ 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