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

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: Replicate a parsed feature policy representation so it doesn't need to be parsed in the browser pro… 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 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..062d6e5f552736a201ca4dc786396280aa958843 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"
@@ -73,6 +74,9 @@ class PLATFORM_EXPORT FeaturePolicy final {
// will always return true.
class Whitelist final {
public:
+ static std::unique_ptr<Whitelist> from(
+ const WebFeaturePolicy::ParsedWhitelist&);
+
Whitelist();
// Adds a single origin to the whitelist.
@@ -123,14 +127,22 @@ 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 WebParsedFeaturePolicy parseFeaturePolicy(const String& policy,
+ RefPtr<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 WebParsedFeaturePolicy&);
// 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