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

Side by Side Diff: third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp

Issue 2864723002: Enable Feature policy without experimental features or fullscreen (Closed)
Patch Set: Update layout test expectations Created 3 years, 7 months 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/RuntimeEnabledFeatures.json5 ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "platform/feature_policy/FeaturePolicy.h" 5 #include "platform/feature_policy/FeaturePolicy.h"
6 6
7 #include "platform/RuntimeEnabledFeatures.h" 7 #include "platform/RuntimeEnabledFeatures.h"
8 #include "platform/json/JSONValues.h" 8 #include "platform/json/JSONValues.h"
9 #include "platform/network/HTTPParsers.h" 9 #include "platform/network/HTTPParsers.h"
10 #include "platform/weborigin/SecurityOrigin.h" 10 #include "platform/weborigin/SecurityOrigin.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 bool allowpayment, 103 bool allowpayment,
104 RefPtr<SecurityOrigin> origin) { 104 RefPtr<SecurityOrigin> origin) {
105 Vector<WebParsedFeaturePolicyDeclaration> whitelists; 105 Vector<WebParsedFeaturePolicyDeclaration> whitelists;
106 bool override_payment = false; 106 bool override_payment = false;
107 bool override_fullscreen = false; 107 bool override_fullscreen = false;
108 for (const WebFeaturePolicyFeature feature : features) { 108 for (const WebFeaturePolicyFeature feature : features) {
109 // Container policy should override "allowfullscreen" and 109 // Container policy should override "allowfullscreen" and
110 // "allowpaymentrequest" policies. 110 // "allowpaymentrequest" policies.
111 if (feature == WebFeaturePolicyFeature::kPayment) 111 if (feature == WebFeaturePolicyFeature::kPayment)
112 override_payment = true; 112 override_payment = true;
113 if (feature == WebFeaturePolicyFeature::kFullscreen) 113 if (RuntimeEnabledFeatures::fullscreenInFeaturePolicyEnabled()) {
114 override_fullscreen = true; 114 if (feature == WebFeaturePolicyFeature::kFullscreen)
115 115 override_fullscreen = true;
116 }
116 WebParsedFeaturePolicyDeclaration whitelist; 117 WebParsedFeaturePolicyDeclaration whitelist;
117 whitelist.feature = feature; 118 whitelist.feature = feature;
118 whitelist.origins = Vector<WebSecurityOrigin>(1UL, {origin}); 119 whitelist.origins = Vector<WebSecurityOrigin>(1UL, {origin});
119 whitelists.push_back(whitelist); 120 whitelists.push_back(whitelist);
120 } 121 }
121 // If allowfullscreen attribute is present and no fullscreen policy is set, 122 // If allowfullscreen attribute is present and no fullscreen policy is set,
122 // enable the feature for all origins; similarly for allowpaymentrequest. 123 // enable the feature for all origins; similarly for allowpaymentrequest.
123 if (allowpayment && !override_payment) 124 if (allowpayment && !override_payment)
124 AddAllowFeatureToList(WebFeaturePolicyFeature::kPayment, whitelists); 125 AddAllowFeatureToList(WebFeaturePolicyFeature::kPayment, whitelists);
125 if (allowfullscreen && !override_fullscreen) 126 if (RuntimeEnabledFeatures::fullscreenInFeaturePolicyEnabled()) {
126 AddAllowFeatureToList(WebFeaturePolicyFeature::kFullscreen, whitelists); 127 if (allowfullscreen && !override_fullscreen)
128 AddAllowFeatureToList(WebFeaturePolicyFeature::kFullscreen, whitelists);
129 }
127 130
128 return whitelists; 131 return whitelists;
129 } 132 }
130 133
131 const FeatureNameMap& GetDefaultFeatureNameMap() { 134 const FeatureNameMap& GetDefaultFeatureNameMap() {
132 DEFINE_STATIC_LOCAL(FeatureNameMap, default_feature_name_map, ()); 135 DEFINE_STATIC_LOCAL(FeatureNameMap, default_feature_name_map, ());
133 if (default_feature_name_map.IsEmpty()) { 136 if (default_feature_name_map.IsEmpty()) {
134 default_feature_name_map.Set("fullscreen",
135 WebFeaturePolicyFeature::kFullscreen);
136 default_feature_name_map.Set("payment", WebFeaturePolicyFeature::kPayment); 137 default_feature_name_map.Set("payment", WebFeaturePolicyFeature::kPayment);
138 if (RuntimeEnabledFeatures::fullscreenInFeaturePolicyEnabled()) {
139 default_feature_name_map.Set("fullscreen",
140 WebFeaturePolicyFeature::kFullscreen);
141 }
137 if (RuntimeEnabledFeatures::featurePolicyExperimentalFeaturesEnabled()) { 142 if (RuntimeEnabledFeatures::featurePolicyExperimentalFeaturesEnabled()) {
138 default_feature_name_map.Set("vibrate", 143 default_feature_name_map.Set("vibrate",
139 WebFeaturePolicyFeature::kVibrate); 144 WebFeaturePolicyFeature::kVibrate);
140 default_feature_name_map.Set("camera", WebFeaturePolicyFeature::kCamera); 145 default_feature_name_map.Set("camera", WebFeaturePolicyFeature::kCamera);
141 default_feature_name_map.Set("encrypted-media", 146 default_feature_name_map.Set("encrypted-media",
142 WebFeaturePolicyFeature::kEme); 147 WebFeaturePolicyFeature::kEme);
143 default_feature_name_map.Set("microphone", 148 default_feature_name_map.Set("microphone",
144 WebFeaturePolicyFeature::kMicrophone); 149 WebFeaturePolicyFeature::kMicrophone);
145 default_feature_name_map.Set("speaker", 150 default_feature_name_map.Set("speaker",
146 WebFeaturePolicyFeature::kSpeaker); 151 WebFeaturePolicyFeature::kSpeaker);
(...skipping 14 matching lines...) Expand all
161 WebFeaturePolicyFeature::kSyncScript); 166 WebFeaturePolicyFeature::kSyncScript);
162 default_feature_name_map.Set("sync-xhr", 167 default_feature_name_map.Set("sync-xhr",
163 WebFeaturePolicyFeature::kSyncXHR); 168 WebFeaturePolicyFeature::kSyncXHR);
164 default_feature_name_map.Set("webrtc", WebFeaturePolicyFeature::kWebRTC); 169 default_feature_name_map.Set("webrtc", WebFeaturePolicyFeature::kWebRTC);
165 } 170 }
166 } 171 }
167 return default_feature_name_map; 172 return default_feature_name_map;
168 } 173 }
169 174
170 } // namespace blink 175 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/RuntimeEnabledFeatures.json5 ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698