// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_PERMISSIONS_POLICY_DOCUMENT_POLICY_H_ #define THIRD_PARTY_BLINK_PUBLIC_COMMON_PERMISSIONS_POLICY_DOCUMENT_POLICY_H_ #include <memory> #include "base/containers/flat_map.h" #include "third_party/blink/public/common/common_export.h" #include "third_party/blink/public/common/permissions_policy/document_policy_features.h" #include "third_party/blink/public/common/permissions_policy/policy_value.h" #include "third_party/blink/public/mojom/permissions_policy/document_policy_feature.mojom.h" #include "third_party/blink/public/mojom/permissions_policy/policy_value.mojom.h" namespace blink { // Document Policy is a mechanism for controlling the behaviour of web platform // features in a document, and for requesting such changes in embedded frames. // (The specific changes which are made depend on the feature; see the // specification for details). // // Policies can be defined in the HTTP header stream, with the |Document-Policy| // HTTP header, or can be set by the |policy| attributes on the iframe element // which embeds the document. // // See // https://github.com/w3c/webappsec-permissions-policy/blob/master/document-policy-explainer.md // // Key concepts: // // Features // -------- // Features which can be controlled by policy are defined by instances of enum // mojom::DocumentPolicyFeature, declared in |document_policy_feature.mojom|. // // Declarations // ------------ // A document policy declaration is a mapping of a feature name to a policy // value. A set of such declarations is a declared policy. The declared policy // is attached to a document. // // Required Policy // ---------------- // In addition to the declared policy (which may be empty), every frame has // an required policy, which is set by the embedding document (or inherited // from its parent). Any document loaded into a frame with a required policy // must have a declared policy which is compatible with it. Frames may add new // requirements to their own subframes, but cannot relax any existing ones. // // Advertised Policy // ----------------- // If a frame has a non-empty required policy, the requirements will be // advertised on the outgoing HTTP request for any document to be loaded in that // frame, in the Sec-Required-Document-Policy HTTP header. // // Defaults // -------- // Each defined feature has a default policy, which determines the threshold // value to use when no policy has been declared. class BLINK_COMMON_EXPORT DocumentPolicy { … }; bool inline operator==(const DocumentPolicy::ParsedDocumentPolicy& lhs, const DocumentPolicy::ParsedDocumentPolicy& rhs) { … } } // namespace blink #endif // THIRD_PARTY_BLINK_PUBLIC_COMMON_PERMISSIONS_POLICY_DOCUMENT_POLICY_H_