OLD | NEW |
---|---|
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 "core/frame/Deprecation.h" | 5 #include "core/frame/Deprecation.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
9 #include "core/frame/FrameConsole.h" | 9 #include "core/frame/FrameConsole.h" |
10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
11 #include "core/inspector/ConsoleMessage.h" | 11 #include "core/inspector/ConsoleMessage.h" |
12 #include "core/page/Page.h" | 12 #include "core/page/Page.h" |
13 #include "core/workers/WorkerOrWorkletGlobalScope.h" | 13 #include "core/workers/WorkerOrWorkletGlobalScope.h" |
14 #include "public/platform/WebFeaturePolicyFeature.h" | |
ddorwin
2017/07/05 20:29:20
In this file, the URL is out of date. It should be
raymes
2017/07/06 03:48:03
Done.
| |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 enum Milestone { | 18 enum Milestone { |
18 M60, | 19 M60, |
19 M61, | 20 M61, |
20 M62, | 21 M62, |
21 M63, | 22 M63, |
22 M64, | 23 M64, |
23 M65, | 24 M65, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 String replacedWillBeRemoved(const char* feature, | 64 String replacedWillBeRemoved(const char* feature, |
64 const char* replacement, | 65 const char* replacement, |
65 Milestone milestone, | 66 Milestone milestone, |
66 const char* details) { | 67 const char* details) { |
67 return String::Format( | 68 return String::Format( |
68 "%s is deprecated and will be removed in %s. Please use %s instead. See " | 69 "%s is deprecated and will be removed in %s. Please use %s instead. See " |
69 "https://www.chromestatus.com/features/%s for more details.", | 70 "https://www.chromestatus.com/features/%s for more details.", |
70 feature, milestoneString(milestone), replacement, details); | 71 feature, milestoneString(milestone), replacement, details); |
71 } | 72 } |
72 | 73 |
74 String iframePermissionsWarning(const char* function, | |
dcheng
2017/07/05 20:18:02
2 nits:
- please use UpperCamelCase for function n
raymes
2017/07/06 03:48:03
Done.
| |
75 const char* allow_string, | |
76 Milestone milestone) { | |
77 return String::Format( | |
78 "%s usage in cross-origin iframes is deprecated and will be disabled in " | |
79 "%s. To continue to use this feature, it must be enabled by the " | |
80 "embedding document using Feature Policy, e.g. " | |
81 "<iframe allow=\"%s\" ...>. See https://goo.gl/EuHzyv for more details.", | |
82 function, milestoneString(milestone), allow_string); | |
83 } | |
84 | |
73 } // anonymous namespace | 85 } // anonymous namespace |
74 | 86 |
75 namespace blink { | 87 namespace blink { |
76 | 88 |
77 Deprecation::Deprecation() : mute_count_(0) { | 89 Deprecation::Deprecation() : mute_count_(0) { |
78 css_property_deprecation_bits_.EnsureSize(numCSSPropertyIDs); | 90 css_property_deprecation_bits_.EnsureSize(numCSSPropertyIDs); |
79 } | 91 } |
80 | 92 |
81 Deprecation::~Deprecation() {} | 93 Deprecation::~Deprecation() {} |
82 | 94 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 } | 185 } |
174 | 186 |
175 void Deprecation::CountDeprecationCrossOriginIframe(const Document& document, | 187 void Deprecation::CountDeprecationCrossOriginIframe(const Document& document, |
176 WebFeature feature) { | 188 WebFeature feature) { |
177 LocalFrame* frame = document.GetFrame(); | 189 LocalFrame* frame = document.GetFrame(); |
178 if (!frame) | 190 if (!frame) |
179 return; | 191 return; |
180 CountDeprecationCrossOriginIframe(frame, feature); | 192 CountDeprecationCrossOriginIframe(frame, feature); |
181 } | 193 } |
182 | 194 |
195 void Deprecation::CountDeprecationFeaturePolicy( | |
196 const Document& document, | |
197 WebFeaturePolicyFeature feature) { | |
198 LocalFrame* frame = document.GetFrame(); | |
199 if (!frame) | |
200 return; | |
201 | |
202 // If the feature is allowed, don't log a warning. | |
203 if (frame->IsFeatureEnabled(feature)) | |
204 return; | |
205 | |
206 // If the feature is disabled, log a warning but only if the request is from a | |
207 // cross-origin iframe. Ideally we would check here if the feature is actually | |
208 // disabled due to the parent frame's policy (as opposed to the current frame | |
209 // disabling the feature on itself) but that can't happen right now anyway | |
210 // (until the general syntax is shipped) and this is also a good enough | |
211 // approximation for deprecation messages. | |
212 switch (feature) { | |
213 case WebFeaturePolicyFeature::kEme: | |
ddorwin
2017/07/05 20:29:20
nit: I suggest making this kEncryptedMedia as that
raymes
2017/07/06 03:48:03
That would be ok, but I'd prefer not to do it in t
| |
214 CountDeprecationCrossOriginIframe( | |
215 frame, WebFeature::kEncryptedMediaDisabledCrossOriginIframe); | |
216 break; | |
217 case WebFeaturePolicyFeature::kGeolocation: | |
218 CountDeprecationCrossOriginIframe( | |
219 frame, WebFeature::kGeolocationDisabledCrossOriginIframe); | |
220 break; | |
221 case WebFeaturePolicyFeature::kMicrophone: | |
222 CountDeprecationCrossOriginIframe( | |
223 frame, WebFeature::kGetUserMediaMicDisabledCrossOriginIframe); | |
224 break; | |
225 case WebFeaturePolicyFeature::kCamera: | |
226 CountDeprecationCrossOriginIframe( | |
227 frame, WebFeature::kGetUserMediaCameraDisabledCrossOriginIframe); | |
228 break; | |
229 case WebFeaturePolicyFeature::kMidiFeature: | |
230 CountDeprecationCrossOriginIframe( | |
231 frame, WebFeature::kRequestMIDIAccessDisabledCrossOriginIframe); | |
232 break; | |
233 default: | |
234 NOTREACHED(); | |
235 } | |
236 } | |
237 | |
183 String Deprecation::DeprecationMessage(WebFeature feature) { | 238 String Deprecation::DeprecationMessage(WebFeature feature) { |
184 switch (feature) { | 239 switch (feature) { |
185 // Quota | 240 // Quota |
186 case WebFeature::kPrefixedStorageInfo: | 241 case WebFeature::kPrefixedStorageInfo: |
187 return replacedBy("'window.webkitStorageInfo'", | 242 return replacedBy("'window.webkitStorageInfo'", |
188 "'navigator.webkitTemporaryStorage' or " | 243 "'navigator.webkitTemporaryStorage' or " |
189 "'navigator.webkitPersistentStorage'"); | 244 "'navigator.webkitPersistentStorage'"); |
190 | 245 |
191 case WebFeature::kConsoleMarkTimeline: | 246 case WebFeature::kConsoleMarkTimeline: |
192 return replacedBy("'console.markTimeline'", "'console.timeStamp'"); | 247 return replacedBy("'console.markTimeline'", "'console.timeStamp'"); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 case WebFeature::kDeprecatedTimingFunctionStepMiddle: | 497 case WebFeature::kDeprecatedTimingFunctionStepMiddle: |
443 return replacedWillBeRemoved( | 498 return replacedWillBeRemoved( |
444 "The step timing function with step position 'middle'", | 499 "The step timing function with step position 'middle'", |
445 "the frames timing function", M62, "5189363944128512"); | 500 "the frames timing function", M62, "5189363944128512"); |
446 case WebFeature::kHTMLImportsHasStyleSheets: | 501 case WebFeature::kHTMLImportsHasStyleSheets: |
447 return String::Format( | 502 return String::Format( |
448 "Styling master document from stylesheets defined in HTML Imports " | 503 "Styling master document from stylesheets defined in HTML Imports " |
449 "is deprecated, and is planned to be removed in %s. Please refer to " | 504 "is deprecated, and is planned to be removed in %s. Please refer to " |
450 "https://goo.gl/EGXzpw for possible migration paths.", | 505 "https://goo.gl/EGXzpw for possible migration paths.", |
451 milestoneString(M65)); | 506 milestoneString(M65)); |
507 case WebFeature::kEncryptedMediaDisabledCrossOriginIframe: | |
508 return iframePermissionsWarning("requestMediaKeySystemAccess", | |
509 "encrypted-media", M63); | |
510 case WebFeature::kGeolocationDisabledCrossOriginIframe: | |
511 return iframePermissionsWarning("getCurrentPosition and watchPosition", | |
512 "geolocation", M63); | |
513 case WebFeature::kGetUserMediaMicDisabledCrossOriginIframe: | |
514 return iframePermissionsWarning("getUserMedia (microphone)", "microphone", | |
515 M63); | |
516 case WebFeature::kGetUserMediaCameraDisabledCrossOriginIframe: | |
517 return iframePermissionsWarning("getUserMedia (camera)", "camera", M63); | |
518 case WebFeature::kRequestMIDIAccessDisabledCrossOriginIframe: | |
519 return iframePermissionsWarning("requestMIDIAccess", "midi", M63); | |
452 | 520 |
453 // Features that aren't deprecated don't have a deprecation message. | 521 // Features that aren't deprecated don't have a deprecation message. |
454 default: | 522 default: |
455 return String(); | 523 return String(); |
456 } | 524 } |
457 } | 525 } |
458 | 526 |
459 } // namespace blink | 527 } // namespace blink |
OLD | NEW |