| OLD | NEW |
| 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 Loading... |
| 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 |
| 172 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall
back, options); | 174 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall
back, options); |
| 173 startRequest(notifier); | 175 startRequest(notifier); |
| 174 | 176 |
| 175 m_oneShots.add(notifier); | 177 m_oneShots.add(notifier); |
| 176 } | 178 } |
| 177 | 179 |
| 178 int Geolocation::watchPosition(PositionCallback* successCallback, PositionErrorC
allback* errorCallback, const PositionOptions& options) | 180 int Geolocation::watchPosition(PositionCallback* successCallback, PositionErrorC
allback* errorCallback, const PositionOptions& options) |
| 179 { | 181 { |
| 180 if (!frame()) | 182 if (!frame()) |
| 181 return 0; | 183 return 0; |
| 182 | 184 |
| 185 recordOriginTypeAccess(); |
| 186 |
| 183 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall
back, options); | 187 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall
back, options); |
| 184 startRequest(notifier); | 188 startRequest(notifier); |
| 185 | 189 |
| 186 int watchID; | 190 int watchID; |
| 187 // Keep asking for the next id until we're given one that we don't already h
ave. | 191 // Keep asking for the next id until we're given one that we don't already h
ave. |
| 188 do { | 192 do { |
| 189 watchID = executionContext()->circularSequentialID(); | 193 watchID = executionContext()->circularSequentialID(); |
| 190 } while (!m_watchers.add(watchID, notifier)); | 194 } while (!m_watchers.add(watchID, notifier)); |
| 191 return watchID; | 195 return watchID; |
| 192 } | 196 } |
| 193 | 197 |
| 194 void Geolocation::startRequest(GeoNotifier *notifier) | 198 void Geolocation::startRequest(GeoNotifier *notifier) |
| 195 { | 199 { |
| 196 recordOriginTypeAccess(); | 200 if (frame()->settings()->strictPowerfulFeatureRestrictions()) { |
| 197 String errorMessage; | 201 String errorMessage; |
| 198 if (!executionContext()->isSecureContext(errorMessage)) { | 202 if (!executionContext()->isSecureContext(errorMessage)) { |
| 199 notifier->setFatalError(PositionError::create(PositionError::POSITION_UN
AVAILABLE, errorMessage)); | 203 notifier->setFatalError(PositionError::create(PositionError::POSITIO
N_UNAVAILABLE, errorMessage)); |
| 200 return; | 204 return; |
| 205 } |
| 201 } | 206 } |
| 202 | 207 |
| 203 if (RuntimeEnabledFeatures::restrictIFramePermissionsEnabled()) { | 208 if (RuntimeEnabledFeatures::restrictIFramePermissionsEnabled()) { |
| 204 // TODO(keenanb): kill the request if the parent is blocking the request
er | 209 // TODO(keenanb): kill the request if the parent is blocking the request
er |
| 205 Element* owner = document()->ownerElement(); | 210 Element* owner = document()->ownerElement(); |
| 206 if (owner && owner->hasAttribute(HTMLNames::permissionsAttr)) { | 211 if (owner && owner->hasAttribute(HTMLNames::permissionsAttr)) { |
| 207 String errorMessage = "A cross-origin iframe needs its permissions a
ttribute properly set in order to use the geolocation API."; | 212 String errorMessage = "A cross-origin iframe needs its permissions a
ttribute properly set in order to use the geolocation API."; |
| 208 notifier->setFatalError(PositionError::create(PositionError::POSITIO
N_UNAVAILABLE, errorMessage)); | 213 notifier->setFatalError(PositionError::create(PositionError::POSITIO
N_UNAVAILABLE, errorMessage)); |
| 209 return; | 214 return; |
| 210 } | 215 } |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 notifier->startTimer(); | 551 notifier->startTimer(); |
| 547 else | 552 else |
| 548 notifier->setFatalError(PositionError::create(PositionError::POS
ITION_UNAVAILABLE, failedToStartServiceErrorMessage)); | 553 notifier->setFatalError(PositionError::create(PositionError::POS
ITION_UNAVAILABLE, failedToStartServiceErrorMessage)); |
| 549 } else { | 554 } else { |
| 550 notifier->setFatalError(PositionError::create(PositionError::PERMISS
ION_DENIED, permissionDeniedErrorMessage)); | 555 notifier->setFatalError(PositionError::create(PositionError::PERMISS
ION_DENIED, permissionDeniedErrorMessage)); |
| 551 } | 556 } |
| 552 } | 557 } |
| 553 } | 558 } |
| 554 | 559 |
| 555 } // namespace blink | 560 } // namespace blink |
| OLD | NEW |