Chromium Code Reviews| Index: third_party/WebKit/Source/core/frame/Deprecation.cpp |
| diff --git a/third_party/WebKit/Source/core/frame/Deprecation.cpp b/third_party/WebKit/Source/core/frame/Deprecation.cpp |
| index 348a1e23f61178b7fbf1ed8ec6ba4f67c7c417e2..3b6bc3d180687f921f27b1c06c3a77c3edd98971 100644 |
| --- a/third_party/WebKit/Source/core/frame/Deprecation.cpp |
| +++ b/third_party/WebKit/Source/core/frame/Deprecation.cpp |
| @@ -11,6 +11,7 @@ |
| #include "core/inspector/ConsoleMessage.h" |
| #include "core/page/Page.h" |
| #include "core/workers/WorkerOrWorkletGlobalScope.h" |
| +#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.
|
| namespace { |
| @@ -70,6 +71,17 @@ String replacedWillBeRemoved(const char* feature, |
| feature, milestoneString(milestone), replacement, details); |
| } |
| +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.
|
| + const char* allow_string, |
| + Milestone milestone) { |
| + return String::Format( |
| + "%s usage in cross-origin iframes is deprecated and will be disabled in " |
| + "%s. To continue to use this feature, it must be enabled by the " |
| + "embedding document using Feature Policy, e.g. " |
| + "<iframe allow=\"%s\" ...>. See https://goo.gl/EuHzyv for more details.", |
| + function, milestoneString(milestone), allow_string); |
| +} |
| + |
| } // anonymous namespace |
| namespace blink { |
| @@ -180,6 +192,49 @@ void Deprecation::CountDeprecationCrossOriginIframe(const Document& document, |
| CountDeprecationCrossOriginIframe(frame, feature); |
| } |
| +void Deprecation::CountDeprecationFeaturePolicy( |
| + const Document& document, |
| + WebFeaturePolicyFeature feature) { |
| + LocalFrame* frame = document.GetFrame(); |
| + if (!frame) |
| + return; |
| + |
| + // If the feature is allowed, don't log a warning. |
| + if (frame->IsFeatureEnabled(feature)) |
| + return; |
| + |
| + // If the feature is disabled, log a warning but only if the request is from a |
| + // cross-origin iframe. Ideally we would check here if the feature is actually |
| + // disabled due to the parent frame's policy (as opposed to the current frame |
| + // disabling the feature on itself) but that can't happen right now anyway |
| + // (until the general syntax is shipped) and this is also a good enough |
| + // approximation for deprecation messages. |
| + switch (feature) { |
| + 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
|
| + CountDeprecationCrossOriginIframe( |
| + frame, WebFeature::kEncryptedMediaDisabledCrossOriginIframe); |
| + break; |
| + case WebFeaturePolicyFeature::kGeolocation: |
| + CountDeprecationCrossOriginIframe( |
| + frame, WebFeature::kGeolocationDisabledCrossOriginIframe); |
| + break; |
| + case WebFeaturePolicyFeature::kMicrophone: |
| + CountDeprecationCrossOriginIframe( |
| + frame, WebFeature::kGetUserMediaMicDisabledCrossOriginIframe); |
| + break; |
| + case WebFeaturePolicyFeature::kCamera: |
| + CountDeprecationCrossOriginIframe( |
| + frame, WebFeature::kGetUserMediaCameraDisabledCrossOriginIframe); |
| + break; |
| + case WebFeaturePolicyFeature::kMidiFeature: |
| + CountDeprecationCrossOriginIframe( |
| + frame, WebFeature::kRequestMIDIAccessDisabledCrossOriginIframe); |
| + break; |
| + default: |
| + NOTREACHED(); |
| + } |
| +} |
| + |
| String Deprecation::DeprecationMessage(WebFeature feature) { |
| switch (feature) { |
| // Quota |
| @@ -449,6 +504,19 @@ String Deprecation::DeprecationMessage(WebFeature feature) { |
| "is deprecated, and is planned to be removed in %s. Please refer to " |
| "https://goo.gl/EGXzpw for possible migration paths.", |
| milestoneString(M65)); |
| + case WebFeature::kEncryptedMediaDisabledCrossOriginIframe: |
| + return iframePermissionsWarning("requestMediaKeySystemAccess", |
| + "encrypted-media", M63); |
| + case WebFeature::kGeolocationDisabledCrossOriginIframe: |
| + return iframePermissionsWarning("getCurrentPosition and watchPosition", |
| + "geolocation", M63); |
| + case WebFeature::kGetUserMediaMicDisabledCrossOriginIframe: |
| + return iframePermissionsWarning("getUserMedia (microphone)", "microphone", |
| + M63); |
| + case WebFeature::kGetUserMediaCameraDisabledCrossOriginIframe: |
| + return iframePermissionsWarning("getUserMedia (camera)", "camera", M63); |
| + case WebFeature::kRequestMIDIAccessDisabledCrossOriginIframe: |
| + return iframePermissionsWarning("requestMIDIAccess", "midi", M63); |
| // Features that aren't deprecated don't have a deprecation message. |
| default: |