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

Side by Side Diff: third_party/WebKit/Source/modules/geolocation/Geolocation.cpp

Issue 1485973002: Removal of geolocation APIs on insecure origins (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fix WebView tests Created 5 years 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
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009 Torch Mobile, Inc. 3 * Copyright (C) 2009 Torch Mobile, Inc.
4 * Copyright 2010, The Android Open Source Project 4 * Copyright 2010, The Android Open Source Project
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 UseCounter::countDeprecation(document, UseCounter::GeolocationInsecureOr igin); 162 UseCounter::countDeprecation(document, UseCounter::GeolocationInsecureOr igin);
163 OriginsUsingFeatures::countAnyWorld(*document, OriginsUsingFeatures::Fea ture::GeolocationInsecureOrigin); 163 OriginsUsingFeatures::countAnyWorld(*document, OriginsUsingFeatures::Fea ture::GeolocationInsecureOrigin);
164 } 164 }
165 } 165 }
166 166
167 void Geolocation::getCurrentPosition(PositionCallback* successCallback, Position ErrorCallback* errorCallback, const PositionOptions& options) 167 void Geolocation::getCurrentPosition(PositionCallback* successCallback, Position ErrorCallback* errorCallback, const PositionOptions& options)
168 { 168 {
169 if (!frame()) 169 if (!frame())
170 return; 170 return;
171 171
172 recordOriginTypeAccess();
173
174 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall back, options); 172 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall back, options);
175 startRequest(notifier); 173 startRequest(notifier);
176 174
177 m_oneShots.add(notifier); 175 m_oneShots.add(notifier);
178 } 176 }
179 177
180 int Geolocation::watchPosition(PositionCallback* successCallback, PositionErrorC allback* errorCallback, const PositionOptions& options) 178 int Geolocation::watchPosition(PositionCallback* successCallback, PositionErrorC allback* errorCallback, const PositionOptions& options)
181 { 179 {
182 if (!frame()) 180 if (!frame())
183 return 0; 181 return 0;
184 182
185 recordOriginTypeAccess();
186
187 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall back, options); 183 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall back, options);
188 startRequest(notifier); 184 startRequest(notifier);
189 185
190 int watchID; 186 int watchID;
191 // Keep asking for the next id until we're given one that we don't already h ave. 187 // Keep asking for the next id until we're given one that we don't already h ave.
192 do { 188 do {
193 watchID = executionContext()->circularSequentialID(); 189 watchID = executionContext()->circularSequentialID();
194 } while (!m_watchers.add(watchID, notifier)); 190 } while (!m_watchers.add(watchID, notifier));
195 return watchID; 191 return watchID;
196 } 192 }
197 193
198 void Geolocation::startRequest(GeoNotifier *notifier) 194 void Geolocation::startRequest(GeoNotifier *notifier)
199 { 195 {
200 if (frame()->settings()->strictPowerfulFeatureRestrictions()) { 196 recordOriginTypeAccess();
201 String errorMessage; 197 String errorMessage;
202 if (!executionContext()->isSecureContext(errorMessage)) { 198 if (!executionContext()->isSecureContext(errorMessage)) {
203 notifier->setFatalError(PositionError::create(PositionError::POSITIO N_UNAVAILABLE, errorMessage)); 199 notifier->setFatalError(PositionError::create(PositionError::POSITION_UN AVAILABLE, errorMessage));
204 return; 200 return;
205 }
206 } 201 }
207 202
208 if (RuntimeEnabledFeatures::restrictIFramePermissionsEnabled()) { 203 if (RuntimeEnabledFeatures::restrictIFramePermissionsEnabled()) {
209 // TODO(keenanb): kill the request if the parent is blocking the request er 204 // TODO(keenanb): kill the request if the parent is blocking the request er
210 Element* owner = document()->ownerElement(); 205 Element* owner = document()->ownerElement();
211 if (owner && owner->hasAttribute(HTMLNames::permissionsAttr)) { 206 if (owner && owner->hasAttribute(HTMLNames::permissionsAttr)) {
212 String errorMessage = "A cross-origin iframe needs its permissions a ttribute properly set in order to use the geolocation API."; 207 String errorMessage = "A cross-origin iframe needs its permissions a ttribute properly set in order to use the geolocation API.";
213 notifier->setFatalError(PositionError::create(PositionError::POSITIO N_UNAVAILABLE, errorMessage)); 208 notifier->setFatalError(PositionError::create(PositionError::POSITIO N_UNAVAILABLE, errorMessage));
214 return; 209 return;
215 } 210 }
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 notifier->startTimer(); 546 notifier->startTimer();
552 else 547 else
553 notifier->setFatalError(PositionError::create(PositionError::POS ITION_UNAVAILABLE, failedToStartServiceErrorMessage)); 548 notifier->setFatalError(PositionError::create(PositionError::POS ITION_UNAVAILABLE, failedToStartServiceErrorMessage));
554 } else { 549 } else {
555 notifier->setFatalError(PositionError::create(PositionError::PERMISS ION_DENIED, permissionDeniedErrorMessage)); 550 notifier->setFatalError(PositionError::create(PositionError::PERMISS ION_DENIED, permissionDeniedErrorMessage));
556 } 551 }
557 } 552 }
558 } 553 }
559 554
560 } // namespace blink 555 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698