| 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 | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..0ed236675160f8bf15c31ac6c659cc2d5518389f | 
| --- /dev/null | 
| +++ b/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.h | 
| @@ -0,0 +1,96 @@ | 
| +// Copyright 2016 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#ifndef FeaturePolicy_h | 
| +#define FeaturePolicy_h | 
| + | 
| +#include "platform/PlatformExport.h" | 
| +#include "platform/heap/Handle.h" | 
| +#include "platform/weborigin/SecurityOrigin.h" | 
| +#include "wtf/RefPtr.h" | 
| +#include "wtf/text/WTFString.h" | 
| + | 
| +namespace blink { | 
| + | 
| +struct FeaturePolicyFeature { | 
| +    const char* featureName; | 
| +    bool enabledByDefault; | 
| +    bool enabledInNestedContext; | 
| +}; | 
| + | 
| +extern const PLATFORM_EXPORT FeaturePolicyFeature kDocumentCookie; | 
| +extern const PLATFORM_EXPORT FeaturePolicyFeature kDocumentDomain; | 
| +extern const PLATFORM_EXPORT FeaturePolicyFeature kDocumentWrite; | 
| +extern const PLATFORM_EXPORT FeaturePolicyFeature kVibrate; | 
| +extern const PLATFORM_EXPORT FeaturePolicyFeature kWebRTC; | 
| +extern const PLATFORM_EXPORT FeaturePolicyFeature kNoSuchFeature; | 
| + | 
| +class PLATFORM_EXPORT FeaturePolicy final : public GarbageCollectedFinalized<FeaturePolicy> { | 
| +public: | 
| +    static FeaturePolicy* createFromParentPolicy(const FeaturePolicy* parent, RefPtr<SecurityOrigin>); | 
| + | 
| +    // Adds a policy to a frame, taking into account any existing or default | 
| +    // policy which applies. | 
| +    void addPolicyFromString(const String& policy); | 
| + | 
| +    // Returns whether or not the given feature is enabled by this policy. | 
| +    bool isFeatureEnabledForOrigin(const FeaturePolicyFeature*, const SecurityOrigin*); | 
| + | 
| +    // Returns whether or not the given feature is enabled for the policy's | 
| +    // origin. | 
| +    bool isFeatureEnabled(const FeaturePolicyFeature*); | 
| + | 
| +    // Returns whether or not the named feature is enabled by default. | 
| +    static bool isFeatureEnabledByDefault(const FeaturePolicyFeature*, bool isTopLevel); | 
| + | 
| +    // Track whether the feature policy-controlled V8 bindings have been | 
| +    // installed already. | 
| +    void setFeaturePolicyBindingsInstalled(); | 
| +    bool featurePolicyBindingsInstalled(); | 
| + | 
| +    DECLARE_VIRTUAL_TRACE(); | 
| + | 
| +private: | 
| +    class Whitelist final { | 
| +    public: | 
| +        Whitelist(); | 
| + | 
| +        // Adds a single origin to the whitelist. | 
| +        void add(RefPtr<SecurityOrigin>); | 
| + | 
| +        // Adds all origins to the whitelist. | 
| +        void addAll(); | 
| + | 
| +        // Returns true if the given origin has been added to the whitelist. | 
| +        bool targets(const SecurityOrigin*) const; | 
| + | 
| +    private: | 
| +        bool m_matchesAllOrigins; | 
| +        Vector<RefPtr<SecurityOrigin>> origins; | 
| +    }; | 
| + | 
| +    FeaturePolicy(PassRefPtr<SecurityOrigin>, bool isTopLevel); | 
| + | 
| +    HashMap<const FeaturePolicyFeature*, Whitelist> parse(const String&); | 
| + | 
| +    RefPtr<SecurityOrigin> m_origin; | 
| + | 
| +    // True if this policy is attached to a top-level frame (and the top-level | 
| +    // defaults should be used when necessary) | 
| +    bool m_isTopLevel; | 
| + | 
| +    // Map of feature names to whitelists. Any feature which is missing from | 
| +    // this map should use the defaults. | 
| +    HashMap<const FeaturePolicyFeature*, Whitelist> m_whitelists; | 
| + | 
| +    // Records whether the V8 bindings have been installed into the document's | 
| +    // V8 context. | 
| +    bool m_bindingsInstalled; | 
| + | 
| +    DISALLOW_COPY_AND_ASSIGN(FeaturePolicy); | 
| +}; | 
| + | 
| +} // namespace blink | 
| + | 
| +#endif // FeaturePolicy_h | 
|  |