From f08d3200d37b28a9de02d28f7396e99966827551 Mon Sep 17 00:00:00 2001 From: jww Date: Fri, 6 May 2016 12:35:17 -0700 Subject: [PATCH] Fix geolocation removal from insecure contexts console message The console message when the geolocation API is used in insecure messages ambiguously says it is deprecated when, in fact, it has been removed at this point. This updates the message to match getUserMedia() and say it is removed. BUG=605938 R=rbyers@chromium.org Review-Url: https://codereview.chromium.org/1942003002 Cr-Commit-Position: refs/heads/master@{#392126} --- .../old-powerful-features-on-insecure-origin-expected.txt | 2 +- third_party/WebKit/Source/core/frame/Deprecation.cpp | 8 ++++---- third_party/WebKit/Source/core/frame/UseCounter.h | 2 ++ .../WebKit/Source/modules/geolocation/Geolocation.cpp | 8 ++++++++ tools/metrics/histograms/histograms.xml | 3 +++ 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/third_party/WebKit/LayoutTests/http/tests/security/powerfulFeatureRestrictions/old-powerful-features-on-insecure-origin-expected.txt b/third_party/WebKit/LayoutTests/http/tests/security/powerfulFeatureRestrictions/old-powerful-features-on-insecure-origin-expected.txt index 714d878176b72..b7f3b78201364 100644 --- a/third_party/WebKit/LayoutTests/http/tests/security/powerfulFeatureRestrictions/old-powerful-features-on-insecure-origin-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/security/powerfulFeatureRestrictions/old-powerful-features-on-insecure-origin-expected.txt @@ -1,7 +1,7 @@ CONSOLE WARNING: Use of the Application Cache is deprecated on insecure origins. Support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details. CONSOLE WARNING: The devicemotion event is deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details. CONSOLE WARNING: The deviceorientation event is deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details. -CONSOLE WARNING: getCurrentPosition() and watchPosition() are deprecated on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details. +CONSOLE WARNING: getCurrentPosition() and watchPosition() no longer work on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details. CONSOLE WARNING: getUserMedia() no longer works on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details. CONSOLE WARNING: requestMediaKeySystemAccess() is deprecated on insecure origins in the specification. Support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details. This is a testharness.js-based test. diff --git a/third_party/WebKit/Source/core/frame/Deprecation.cpp b/third_party/WebKit/Source/core/frame/Deprecation.cpp index 7b2d9093f0aec..95971c49bb899 100644 --- a/third_party/WebKit/Source/core/frame/Deprecation.cpp +++ b/third_party/WebKit/Source/core/frame/Deprecation.cpp @@ -292,10 +292,10 @@ String Deprecation::deprecationMessage(UseCounter::Feature feature) case UseCounter::GeolocationInsecureOrigin: case UseCounter::GeolocationInsecureOriginIframe: - // TODO(jww): This message should be made less ambigous after WebView - // is fixed so geolocation can be removed there. After that, this - // should be updated to read similarly to GetUserMediaInsecureOrigin's - // message. + return "getCurrentPosition() and watchPosition() no longer work on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details."; + + case UseCounter::GeolocationInsecureOriginDeprecatedNotRemoved: + case UseCounter::GeolocationInsecureOriginIframeDeprecatedNotRemoved: return "getCurrentPosition() and watchPosition() are deprecated on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details."; case UseCounter::GetUserMediaInsecureOrigin: diff --git a/third_party/WebKit/Source/core/frame/UseCounter.h b/third_party/WebKit/Source/core/frame/UseCounter.h index 7998a0dc35626..9a61d77c74718 100644 --- a/third_party/WebKit/Source/core/frame/UseCounter.h +++ b/third_party/WebKit/Source/core/frame/UseCounter.h @@ -1158,6 +1158,8 @@ class CORE_EXPORT UseCounter { URLMethodRevokeObjectURLServiceWorker = 1340, DocumentCreateEventPaymentRequestUpdateEvent = 1341, CredentialManagerGetReturnedCredential = 1342, + GeolocationInsecureOriginDeprecatedNotRemoved = 1343, + GeolocationInsecureOriginIframeDeprecatedNotRemoved = 1344, // Add new features immediately above this line. Don't change assigned // numbers of any item, and don't reuse removed slots. diff --git a/third_party/WebKit/Source/modules/geolocation/Geolocation.cpp b/third_party/WebKit/Source/modules/geolocation/Geolocation.cpp index 036b29e820c6a..efdb860a03b60 100644 --- a/third_party/WebKit/Source/modules/geolocation/Geolocation.cpp +++ b/third_party/WebKit/Source/modules/geolocation/Geolocation.cpp @@ -155,6 +155,14 @@ void Geolocation::recordOriginTypeAccess() const if (document->isSecureContext(insecureOriginMsg)) { UseCounter::count(document, UseCounter::GeolocationSecureOrigin); UseCounter::countCrossOriginIframe(*document, UseCounter::GeolocationSecureOriginIframe); + } else if (frame()->settings()->allowGeolocationOnInsecureOrigins()) { + // TODO(jww): This should be removed after WebView is fixed so that it + // disallows geolocation in insecure contexts. + // + // See https://crbug.com/603574. + Deprecation::countDeprecation(document, UseCounter::GeolocationInsecureOriginDeprecatedNotRemoved); + Deprecation::countDeprecationCrossOriginIframe(*document, UseCounter::GeolocationInsecureOriginIframeDeprecatedNotRemoved); + OriginsUsingFeatures::countAnyWorld(*document, OriginsUsingFeatures::Feature::GeolocationInsecureOrigin); } else { Deprecation::countDeprecation(document, UseCounter::GeolocationInsecureOrigin); Deprecation::countDeprecationCrossOriginIframe(*document, UseCounter::GeolocationInsecureOriginIframe); diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 2d9baf6a6298c..bcf3c289817fb 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -72277,6 +72277,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. + +