| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 code = PositionError::PERMISSION_DENIED; | 61 code = PositionError::PERMISSION_DENIED; |
| 62 break; | 62 break; |
| 63 case GeolocationError::PositionUnavailable: | 63 case GeolocationError::PositionUnavailable: |
| 64 code = PositionError::POSITION_UNAVAILABLE; | 64 code = PositionError::POSITION_UNAVAILABLE; |
| 65 break; | 65 break; |
| 66 } | 66 } |
| 67 | 67 |
| 68 return PositionError::create(code, error->message()); | 68 return PositionError::create(code, error->message()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 Geolocation::GeoNotifier::GeoNotifier(Geolocation* geolocation, PassRefPtr<Posit
ionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, P
assRefPtr<PositionOptions> options) | 71 Geolocation::GeoNotifier::GeoNotifier(Geolocation* geolocation, PassOwnPtr<Posit
ionCallback> successCallback, PassOwnPtr<PositionErrorCallback> errorCallback, P
assRefPtr<PositionOptions> options) |
| 72 : m_geolocation(geolocation) | 72 : m_geolocation(geolocation) |
| 73 , m_successCallback(successCallback) | 73 , m_successCallback(successCallback) |
| 74 , m_errorCallback(errorCallback) | 74 , m_errorCallback(errorCallback) |
| 75 , m_options(options) | 75 , m_options(options) |
| 76 , m_timer(this, &Geolocation::GeoNotifier::timerFired) | 76 , m_timer(this, &Geolocation::GeoNotifier::timerFired) |
| 77 , m_useCachedPosition(false) | 77 , m_useCachedPosition(false) |
| 78 { | 78 { |
| 79 ASSERT(m_geolocation); | 79 ASSERT(m_geolocation); |
| 80 ASSERT(m_successCallback); | 80 ASSERT(m_successCallback); |
| 81 // If no options were supplied from JS, we should have created a default set | 81 // If no options were supplied from JS, we should have created a default set |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 { | 277 { |
| 278 Page* page = this->page(); | 278 Page* page = this->page(); |
| 279 if (!page) | 279 if (!page) |
| 280 return 0; | 280 return 0; |
| 281 | 281 |
| 282 m_lastPosition = createGeoposition(GeolocationController::from(page)->lastPo
sition()); | 282 m_lastPosition = createGeoposition(GeolocationController::from(page)->lastPo
sition()); |
| 283 | 283 |
| 284 return m_lastPosition.get(); | 284 return m_lastPosition.get(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 void Geolocation::getCurrentPosition(PassRefPtr<PositionCallback> successCallbac
k, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions>
options) | 287 void Geolocation::getCurrentPosition(PassOwnPtr<PositionCallback> successCallbac
k, PassOwnPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions>
options) |
| 288 { | 288 { |
| 289 if (!frame()) | 289 if (!frame()) |
| 290 return; | 290 return; |
| 291 | 291 |
| 292 RefPtr<GeoNotifier> notifier = GeoNotifier::create(this, successCallback, er
rorCallback, options); | 292 RefPtr<GeoNotifier> notifier = GeoNotifier::create(this, successCallback, er
rorCallback, options); |
| 293 startRequest(notifier.get()); | 293 startRequest(notifier.get()); |
| 294 | 294 |
| 295 m_oneShots.add(notifier); | 295 m_oneShots.add(notifier); |
| 296 } | 296 } |
| 297 | 297 |
| 298 int Geolocation::watchPosition(PassRefPtr<PositionCallback> successCallback, Pas
sRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> option
s) | 298 int Geolocation::watchPosition(PassOwnPtr<PositionCallback> successCallback, Pas
sOwnPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> option
s) |
| 299 { | 299 { |
| 300 if (!frame()) | 300 if (!frame()) |
| 301 return 0; | 301 return 0; |
| 302 | 302 |
| 303 RefPtr<GeoNotifier> notifier = GeoNotifier::create(this, successCallback, er
rorCallback, options); | 303 RefPtr<GeoNotifier> notifier = GeoNotifier::create(this, successCallback, er
rorCallback, options); |
| 304 startRequest(notifier.get()); | 304 startRequest(notifier.get()); |
| 305 | 305 |
| 306 int watchID; | 306 int watchID; |
| 307 // Keep asking for the next id until we're given one that we don't already h
ave. | 307 // Keep asking for the next id until we're given one that we don't already h
ave. |
| 308 do { | 308 do { |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 notifier->startTimerIfNeeded(); | 668 notifier->startTimerIfNeeded(); |
| 669 else | 669 else |
| 670 notifier->setFatalError(PositionError::create(PositionError::POS
ITION_UNAVAILABLE, failedToStartServiceErrorMessage)); | 670 notifier->setFatalError(PositionError::create(PositionError::POS
ITION_UNAVAILABLE, failedToStartServiceErrorMessage)); |
| 671 } else { | 671 } else { |
| 672 notifier->setFatalError(PositionError::create(PositionError::PERMISS
ION_DENIED, permissionDeniedErrorMessage)); | 672 notifier->setFatalError(PositionError::create(PositionError::PERMISS
ION_DENIED, permissionDeniedErrorMessage)); |
| 673 } | 673 } |
| 674 } | 674 } |
| 675 } | 675 } |
| 676 | 676 |
| 677 } // namespace WebCore | 677 } // namespace WebCore |
| OLD | NEW |