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

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

Issue 2873433002: Enable Feature Policy without experimental features or fullscreen (Closed)
Patch Set: Update webkit_unit_tests(vibrate is not valid feature name) and layout_tests for fp-fullscreen (exp… 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
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 (feature == WebFeaturePolicyFeature::kFullscreen)
114 override_fullscreen = true; 114 override_fullscreen = true;
115
116 WebParsedFeaturePolicyDeclaration whitelist; 115 WebParsedFeaturePolicyDeclaration whitelist;
117 whitelist.feature = feature; 116 whitelist.feature = feature;
118 whitelist.origins = Vector<WebSecurityOrigin>(1UL, {origin}); 117 whitelist.origins = Vector<WebSecurityOrigin>(1UL, {origin});
119 whitelists.push_back(whitelist); 118 whitelists.push_back(whitelist);
120 } 119 }
121 // If allowfullscreen attribute is present and no fullscreen policy is set, 120 // If allowfullscreen attribute is present and no fullscreen policy is set,
122 // enable the feature for all origins; similarly for allowpaymentrequest. 121 // enable the feature for all origins; similarly for allowpaymentrequest.
123 if (allowpayment && !override_payment) 122 if (allowpayment && !override_payment)
124 AddAllowFeatureToList(WebFeaturePolicyFeature::kPayment, whitelists); 123 AddAllowFeatureToList(WebFeaturePolicyFeature::kPayment, whitelists);
125 if (allowfullscreen && !override_fullscreen) 124 if (allowfullscreen && !override_fullscreen)
126 AddAllowFeatureToList(WebFeaturePolicyFeature::kFullscreen, whitelists); 125 AddAllowFeatureToList(WebFeaturePolicyFeature::kFullscreen, whitelists);
127 126
128 return whitelists; 127 return whitelists;
129 } 128 }
130 129
131 const FeatureNameMap& GetDefaultFeatureNameMap() { 130 const FeatureNameMap& GetDefaultFeatureNameMap() {
132 DEFINE_STATIC_LOCAL(FeatureNameMap, default_feature_name_map, ()); 131 DEFINE_STATIC_LOCAL(FeatureNameMap, default_feature_name_map, ());
133 if (default_feature_name_map.IsEmpty()) { 132 if (default_feature_name_map.IsEmpty()) {
133 default_feature_name_map.Set("payment", WebFeaturePolicyFeature::kPayment);
iclelland 2017/05/09 17:58:45 This change looks unintentional; I'd prefer to not
lunalu1 2017/05/09 19:07:31 Done.
134 default_feature_name_map.Set("fullscreen", 134 default_feature_name_map.Set("fullscreen",
135 WebFeaturePolicyFeature::kFullscreen); 135 WebFeaturePolicyFeature::kFullscreen);
136 default_feature_name_map.Set("payment", WebFeaturePolicyFeature::kPayment);
137 if (RuntimeEnabledFeatures::featurePolicyExperimentalFeaturesEnabled()) { 136 if (RuntimeEnabledFeatures::featurePolicyExperimentalFeaturesEnabled()) {
138 default_feature_name_map.Set("vibrate", 137 default_feature_name_map.Set("vibrate",
139 WebFeaturePolicyFeature::kVibrate); 138 WebFeaturePolicyFeature::kVibrate);
140 default_feature_name_map.Set("camera", WebFeaturePolicyFeature::kCamera); 139 default_feature_name_map.Set("camera", WebFeaturePolicyFeature::kCamera);
141 default_feature_name_map.Set("encrypted-media", 140 default_feature_name_map.Set("encrypted-media",
142 WebFeaturePolicyFeature::kEme); 141 WebFeaturePolicyFeature::kEme);
143 default_feature_name_map.Set("microphone", 142 default_feature_name_map.Set("microphone",
144 WebFeaturePolicyFeature::kMicrophone); 143 WebFeaturePolicyFeature::kMicrophone);
145 default_feature_name_map.Set("speaker", 144 default_feature_name_map.Set("speaker",
146 WebFeaturePolicyFeature::kSpeaker); 145 WebFeaturePolicyFeature::kSpeaker);
(...skipping 14 matching lines...) Expand all
161 WebFeaturePolicyFeature::kSyncScript); 160 WebFeaturePolicyFeature::kSyncScript);
162 default_feature_name_map.Set("sync-xhr", 161 default_feature_name_map.Set("sync-xhr",
163 WebFeaturePolicyFeature::kSyncXHR); 162 WebFeaturePolicyFeature::kSyncXHR);
164 default_feature_name_map.Set("webrtc", WebFeaturePolicyFeature::kWebRTC); 163 default_feature_name_map.Set("webrtc", WebFeaturePolicyFeature::kWebRTC);
165 } 164 }
166 } 165 }
167 return default_feature_name_map; 166 return default_feature_name_map;
168 } 167 }
169 168
170 } // namespace blink 169 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698