| 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" |
| 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 DeprecatedWillBeDisabledByFeaturePolicyInCrossOriginIframe( |
| 75 const char* function, |
| 76 const char* allow_string, |
| 77 Milestone milestone) { |
| 78 return String::Format( |
| 79 "%s usage in cross-origin iframes is deprecated and will be disabled in " |
| 80 "%s. To continue to use this feature, it must be enabled by the " |
| 81 "embedding document using Feature Policy, e.g. " |
| 82 "<iframe allow=\"%s\" ...>. See https://goo.gl/EuHzyv for more details.", |
| 83 function, milestoneString(milestone), allow_string); |
| 84 } |
| 85 |
| 73 } // anonymous namespace | 86 } // anonymous namespace |
| 74 | 87 |
| 75 namespace blink { | 88 namespace blink { |
| 76 | 89 |
| 77 Deprecation::Deprecation() : mute_count_(0) { | 90 Deprecation::Deprecation() : mute_count_(0) { |
| 78 css_property_deprecation_bits_.EnsureSize(numCSSPropertyIDs); | 91 css_property_deprecation_bits_.EnsureSize(numCSSPropertyIDs); |
| 79 } | 92 } |
| 80 | 93 |
| 81 Deprecation::~Deprecation() {} | 94 Deprecation::~Deprecation() {} |
| 82 | 95 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 } | 186 } |
| 174 | 187 |
| 175 void Deprecation::CountDeprecationCrossOriginIframe(const Document& document, | 188 void Deprecation::CountDeprecationCrossOriginIframe(const Document& document, |
| 176 WebFeature feature) { | 189 WebFeature feature) { |
| 177 LocalFrame* frame = document.GetFrame(); | 190 LocalFrame* frame = document.GetFrame(); |
| 178 if (!frame) | 191 if (!frame) |
| 179 return; | 192 return; |
| 180 CountDeprecationCrossOriginIframe(frame, feature); | 193 CountDeprecationCrossOriginIframe(frame, feature); |
| 181 } | 194 } |
| 182 | 195 |
| 196 void Deprecation::CountDeprecationFeaturePolicy( |
| 197 const Document& document, |
| 198 WebFeaturePolicyFeature feature) { |
| 199 LocalFrame* frame = document.GetFrame(); |
| 200 if (!frame) |
| 201 return; |
| 202 |
| 203 // If the feature is allowed, don't log a warning. |
| 204 if (frame->IsFeatureEnabled(feature)) |
| 205 return; |
| 206 |
| 207 // If the feature is disabled, log a warning but only if the request is from a |
| 208 // cross-origin iframe. Ideally we would check here if the feature is actually |
| 209 // disabled due to the parent frame's policy (as opposed to the current frame |
| 210 // disabling the feature on itself) but that can't happen right now anyway |
| 211 // (until the general syntax is shipped) and this is also a good enough |
| 212 // approximation for deprecation messages. |
| 213 switch (feature) { |
| 214 case WebFeaturePolicyFeature::kEme: |
| 215 CountDeprecationCrossOriginIframe( |
| 216 frame, |
| 217 WebFeature:: |
| 218 kEncryptedMediaDisallowedByFeaturePolicyInCrossOriginIframe); |
| 219 break; |
| 220 case WebFeaturePolicyFeature::kGeolocation: |
| 221 CountDeprecationCrossOriginIframe( |
| 222 frame, |
| 223 WebFeature::kGeolocationDisallowedByFeaturePolicyInCrossOriginIframe); |
| 224 break; |
| 225 case WebFeaturePolicyFeature::kMicrophone: |
| 226 CountDeprecationCrossOriginIframe( |
| 227 frame, |
| 228 WebFeature:: |
| 229 kGetUserMediaMicDisallowedByFeaturePolicyInCrossOriginIframe); |
| 230 break; |
| 231 case WebFeaturePolicyFeature::kCamera: |
| 232 CountDeprecationCrossOriginIframe( |
| 233 frame, |
| 234 WebFeature:: |
| 235 kGetUserMediaCameraDisallowedByFeaturePolicyInCrossOriginIframe); |
| 236 break; |
| 237 case WebFeaturePolicyFeature::kMidiFeature: |
| 238 CountDeprecationCrossOriginIframe( |
| 239 frame, |
| 240 WebFeature:: |
| 241 kRequestMIDIAccessDisallowedByFeaturePolicyInCrossOriginIframe); |
| 242 break; |
| 243 default: |
| 244 NOTREACHED(); |
| 245 } |
| 246 } |
| 247 |
| 183 String Deprecation::DeprecationMessage(WebFeature feature) { | 248 String Deprecation::DeprecationMessage(WebFeature feature) { |
| 184 switch (feature) { | 249 switch (feature) { |
| 185 // Quota | 250 // Quota |
| 186 case WebFeature::kPrefixedStorageInfo: | 251 case WebFeature::kPrefixedStorageInfo: |
| 187 return replacedBy("'window.webkitStorageInfo'", | 252 return replacedBy("'window.webkitStorageInfo'", |
| 188 "'navigator.webkitTemporaryStorage' or " | 253 "'navigator.webkitTemporaryStorage' or " |
| 189 "'navigator.webkitPersistentStorage'"); | 254 "'navigator.webkitPersistentStorage'"); |
| 190 | 255 |
| 191 case WebFeature::kConsoleMarkTimeline: | 256 case WebFeature::kConsoleMarkTimeline: |
| 192 return replacedBy("'console.markTimeline'", "'console.timeStamp'"); | 257 return replacedBy("'console.markTimeline'", "'console.timeStamp'"); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 case WebFeature::kDeprecatedTimingFunctionStepMiddle: | 507 case WebFeature::kDeprecatedTimingFunctionStepMiddle: |
| 443 return replacedWillBeRemoved( | 508 return replacedWillBeRemoved( |
| 444 "The step timing function with step position 'middle'", | 509 "The step timing function with step position 'middle'", |
| 445 "the frames timing function", M62, "5189363944128512"); | 510 "the frames timing function", M62, "5189363944128512"); |
| 446 case WebFeature::kHTMLImportsHasStyleSheets: | 511 case WebFeature::kHTMLImportsHasStyleSheets: |
| 447 return String::Format( | 512 return String::Format( |
| 448 "Styling master document from stylesheets defined in HTML Imports " | 513 "Styling master document from stylesheets defined in HTML Imports " |
| 449 "is deprecated, and is planned to be removed in %s. Please refer to " | 514 "is deprecated, and is planned to be removed in %s. Please refer to " |
| 450 "https://goo.gl/EGXzpw for possible migration paths.", | 515 "https://goo.gl/EGXzpw for possible migration paths.", |
| 451 milestoneString(M65)); | 516 milestoneString(M65)); |
| 517 case WebFeature:: |
| 518 kEncryptedMediaDisallowedByFeaturePolicyInCrossOriginIframe: |
| 519 return DeprecatedWillBeDisabledByFeaturePolicyInCrossOriginIframe( |
| 520 "requestMediaKeySystemAccess", "encrypted-media", M63); |
| 521 case WebFeature::kGeolocationDisallowedByFeaturePolicyInCrossOriginIframe: |
| 522 return DeprecatedWillBeDisabledByFeaturePolicyInCrossOriginIframe( |
| 523 "getCurrentPosition and watchPosition", "geolocation", M63); |
| 524 case WebFeature:: |
| 525 kGetUserMediaMicDisallowedByFeaturePolicyInCrossOriginIframe: |
| 526 return DeprecatedWillBeDisabledByFeaturePolicyInCrossOriginIframe( |
| 527 "getUserMedia (microphone)", "microphone", M63); |
| 528 case WebFeature:: |
| 529 kGetUserMediaCameraDisallowedByFeaturePolicyInCrossOriginIframe: |
| 530 return DeprecatedWillBeDisabledByFeaturePolicyInCrossOriginIframe( |
| 531 "getUserMedia (camera)", "camera", M63); |
| 532 case WebFeature:: |
| 533 kRequestMIDIAccessDisallowedByFeaturePolicyInCrossOriginIframe: |
| 534 return DeprecatedWillBeDisabledByFeaturePolicyInCrossOriginIframe( |
| 535 "requestMIDIAccess", "midi", M63); |
| 452 | 536 |
| 453 // Features that aren't deprecated don't have a deprecation message. | 537 // Features that aren't deprecated don't have a deprecation message. |
| 454 default: | 538 default: |
| 455 return String(); | 539 return String(); |
| 456 } | 540 } |
| 457 } | 541 } |
| 458 | 542 |
| 459 } // namespace blink | 543 } // namespace blink |
| OLD | NEW |