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