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 11 matching lines...) Expand all Loading... |
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include "config.h" | 28 #include "config.h" |
29 #include "modules/geolocation/Geolocation.h" | 29 #include "modules/geolocation/Geolocation.h" |
30 | 30 |
31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
| 32 #include "core/frame/UseCounter.h" |
32 #include "modules/geolocation/Coordinates.h" | 33 #include "modules/geolocation/Coordinates.h" |
33 #include "modules/geolocation/GeolocationController.h" | 34 #include "modules/geolocation/GeolocationController.h" |
34 #include "modules/geolocation/GeolocationError.h" | 35 #include "modules/geolocation/GeolocationError.h" |
35 #include "modules/geolocation/GeolocationPosition.h" | 36 #include "modules/geolocation/GeolocationPosition.h" |
36 #include "wtf/CurrentTime.h" | 37 #include "wtf/CurrentTime.h" |
37 | 38 |
38 namespace blink { | 39 namespace blink { |
39 | 40 |
40 static const char permissionDeniedErrorMessage[] = "User denied Geolocation"; | 41 static const char permissionDeniedErrorMessage[] = "User denied Geolocation"; |
41 static const char failedToStartServiceErrorMessage[] = "Failed to start Geolocat
ion service"; | 42 static const char failedToStartServiceErrorMessage[] = "Failed to start Geolocat
ion service"; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 { | 131 { |
131 LocalFrame* frame = this->frame(); | 132 LocalFrame* frame = this->frame(); |
132 if (!frame) | 133 if (!frame) |
133 return 0; | 134 return 0; |
134 | 135 |
135 m_lastPosition = createGeoposition(GeolocationController::from(frame)->lastP
osition()); | 136 m_lastPosition = createGeoposition(GeolocationController::from(frame)->lastP
osition()); |
136 | 137 |
137 return m_lastPosition.get(); | 138 return m_lastPosition.get(); |
138 } | 139 } |
139 | 140 |
| 141 void Geolocation::recordOriginTypeAccess() const |
| 142 { |
| 143 ASSERT(frame()); |
| 144 |
| 145 Document* document = this->document(); |
| 146 ASSERT(document); |
| 147 |
| 148 // It is required by canAccessFeatureRequiringSecureOrigin() but isn't |
| 149 // actually used. This could be used later if a warning is shown in the |
| 150 // developer console. |
| 151 String insecureOriginMsg; |
| 152 UseCounter::Feature counter = document->securityOrigin()->canAccessFeatureRe
quiringSecureOrigin(insecureOriginMsg) |
| 153 ? UseCounter::GeolocationSecureOrigin : UseCounter::GeolocationInsecureO
rigin; |
| 154 UseCounter::count(document, counter); |
| 155 } |
| 156 |
140 void Geolocation::getCurrentPosition(PositionCallback* successCallback, Position
ErrorCallback* errorCallback, const Dictionary& options) | 157 void Geolocation::getCurrentPosition(PositionCallback* successCallback, Position
ErrorCallback* errorCallback, const Dictionary& options) |
141 { | 158 { |
142 if (!frame()) | 159 if (!frame()) |
143 return; | 160 return; |
144 | 161 |
| 162 recordOriginTypeAccess(); |
| 163 |
145 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall
back, PositionOptions::create(options)); | 164 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall
back, PositionOptions::create(options)); |
146 startRequest(notifier); | 165 startRequest(notifier); |
147 | 166 |
148 m_oneShots.add(notifier); | 167 m_oneShots.add(notifier); |
149 } | 168 } |
150 | 169 |
151 int Geolocation::watchPosition(PositionCallback* successCallback, PositionErrorC
allback* errorCallback, const Dictionary& options) | 170 int Geolocation::watchPosition(PositionCallback* successCallback, PositionErrorC
allback* errorCallback, const Dictionary& options) |
152 { | 171 { |
153 if (!frame()) | 172 if (!frame()) |
154 return 0; | 173 return 0; |
155 | 174 |
| 175 recordOriginTypeAccess(); |
| 176 |
156 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall
back, PositionOptions::create(options)); | 177 GeoNotifier* notifier = GeoNotifier::create(this, successCallback, errorCall
back, PositionOptions::create(options)); |
157 startRequest(notifier); | 178 startRequest(notifier); |
158 | 179 |
159 int watchID; | 180 int watchID; |
160 // Keep asking for the next id until we're given one that we don't already h
ave. | 181 // Keep asking for the next id until we're given one that we don't already h
ave. |
161 do { | 182 do { |
162 watchID = executionContext()->circularSequentialID(); | 183 watchID = executionContext()->circularSequentialID(); |
163 } while (!m_watchers.add(watchID, notifier)); | 184 } while (!m_watchers.add(watchID, notifier)); |
164 return watchID; | 185 return watchID; |
165 } | 186 } |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 notifier->startTimer(); | 537 notifier->startTimer(); |
517 else | 538 else |
518 notifier->setFatalError(PositionError::create(PositionError::POS
ITION_UNAVAILABLE, failedToStartServiceErrorMessage)); | 539 notifier->setFatalError(PositionError::create(PositionError::POS
ITION_UNAVAILABLE, failedToStartServiceErrorMessage)); |
519 } else { | 540 } else { |
520 notifier->setFatalError(PositionError::create(PositionError::PERMISS
ION_DENIED, permissionDeniedErrorMessage)); | 541 notifier->setFatalError(PositionError::create(PositionError::PERMISS
ION_DENIED, permissionDeniedErrorMessage)); |
521 } | 542 } |
522 } | 543 } |
523 } | 544 } |
524 | 545 |
525 } // namespace blink | 546 } // namespace blink |
OLD | NEW |