OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_COMMON_FEATURE_POLICY_FEATURE_POLICY_H_ | 5 #ifndef CONTENT_COMMON_FEATURE_POLICY_FEATURE_POLICY_H_ |
6 #define CONTENT_COMMON_FEATURE_POLICY_FEATURE_POLICY_H_ | 6 #define CONTENT_COMMON_FEATURE_POLICY_FEATURE_POLICY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 // Returns whether or not the given feature is enabled by this policy for a | 170 // Returns whether or not the given feature is enabled by this policy for a |
171 // specific origin. | 171 // specific origin. |
172 bool IsFeatureEnabledForOrigin(blink::WebFeaturePolicyFeature feature, | 172 bool IsFeatureEnabledForOrigin(blink::WebFeaturePolicyFeature feature, |
173 const url::Origin& origin) const; | 173 const url::Origin& origin) const; |
174 | 174 |
175 // Sets the declared policy from the parsed Feature-Policy HTTP header. | 175 // Sets the declared policy from the parsed Feature-Policy HTTP header. |
176 // Unrecognized features will be ignored. | 176 // Unrecognized features will be ignored. |
177 void SetHeaderPolicy(const ParsedFeaturePolicyHeader& parsed_header); | 177 void SetHeaderPolicy(const ParsedFeaturePolicyHeader& parsed_header); |
178 | 178 |
| 179 // Returns true if a header policy has already been set on this feature |
| 180 // policy. |
| 181 bool HasSetHeaderPolicy() const; |
| 182 |
179 private: | 183 private: |
180 friend class FeaturePolicyTest; | 184 friend class FeaturePolicyTest; |
181 FRIEND_TEST_ALL_PREFIXES(NavigatorTestWithBrowserSideNavigation, | 185 FRIEND_TEST_ALL_PREFIXES(NavigatorTestWithBrowserSideNavigation, |
182 FeaturePolicyNewChild); | 186 FeaturePolicyNewChild); |
183 | 187 |
184 explicit FeaturePolicy(url::Origin origin); | 188 explicit FeaturePolicy(url::Origin origin); |
185 FeaturePolicy(url::Origin origin, const FeatureList& feature_list); | 189 FeaturePolicy(url::Origin origin, const FeatureList& feature_list); |
186 static std::unique_ptr<FeaturePolicy> CreateFromParentPolicy( | 190 static std::unique_ptr<FeaturePolicy> CreateFromParentPolicy( |
187 const FeaturePolicy* parent_policy, | 191 const FeaturePolicy* parent_policy, |
188 const ParsedFeaturePolicyHeader& container_policy, | 192 const ParsedFeaturePolicyHeader& container_policy, |
(...skipping 22 matching lines...) Expand all Loading... |
211 std::map<blink::WebFeaturePolicyFeature, bool> inherited_policies_; | 215 std::map<blink::WebFeaturePolicyFeature, bool> inherited_policies_; |
212 | 216 |
213 const FeatureList& feature_list_; | 217 const FeatureList& feature_list_; |
214 | 218 |
215 DISALLOW_COPY_AND_ASSIGN(FeaturePolicy); | 219 DISALLOW_COPY_AND_ASSIGN(FeaturePolicy); |
216 }; | 220 }; |
217 | 221 |
218 } // namespace content | 222 } // namespace content |
219 | 223 |
220 #endif // CONTENT_COMMON_FEATURE_POLICY_FEATURE_POLICY_H_ | 224 #endif // CONTENT_COMMON_FEATURE_POLICY_FEATURE_POLICY_H_ |
OLD | NEW |