| 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 28 matching lines...) Expand all Loading... |
| 39 #include "wtf/Assertions.h" | 39 #include "wtf/Assertions.h" |
| 40 #include "wtf/CurrentTime.h" | 40 #include "wtf/CurrentTime.h" |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 namespace { | 43 namespace { |
| 44 | 44 |
| 45 static const char permissionDeniedErrorMessage[] = "User denied Geolocation"; | 45 static const char permissionDeniedErrorMessage[] = "User denied Geolocation"; |
| 46 static const char failedToStartServiceErrorMessage[] = "Failed to start Geolocat
ion service"; | 46 static const char failedToStartServiceErrorMessage[] = "Failed to start Geolocat
ion service"; |
| 47 static const char framelessDocumentErrorMessage[] = "Geolocation cannot be used
in frameless documents"; | 47 static const char framelessDocumentErrorMessage[] = "Geolocation cannot be used
in frameless documents"; |
| 48 | 48 |
| 49 static Geoposition* createGeoposition(const mojom::blink::Geoposition& position) | 49 static Geoposition* createGeoposition(const device::mojom::blink::Geoposition& p
osition) |
| 50 { | 50 { |
| 51 Coordinates* coordinates = Coordinates::create( | 51 Coordinates* coordinates = Coordinates::create( |
| 52 position.latitude, | 52 position.latitude, |
| 53 position.longitude, | 53 position.longitude, |
| 54 // Lowest point on land is at approximately -400 meters. | 54 // Lowest point on land is at approximately -400 meters. |
| 55 position.altitude > -10000., | 55 position.altitude > -10000., |
| 56 position.altitude, | 56 position.altitude, |
| 57 position.accuracy, | 57 position.accuracy, |
| 58 position.altitude_accuracy >= 0., | 58 position.altitude_accuracy >= 0., |
| 59 position.altitude_accuracy, | 59 position.altitude_accuracy, |
| 60 position.heading >= 0. && position.heading <= 360., | 60 position.heading >= 0. && position.heading <= 360., |
| 61 position.heading, | 61 position.heading, |
| 62 position.speed >= 0., | 62 position.speed >= 0., |
| 63 position.speed); | 63 position.speed); |
| 64 return Geoposition::create(coordinates, convertSecondsToDOMTimeStamp(positio
n.timestamp)); | 64 return Geoposition::create(coordinates, convertSecondsToDOMTimeStamp(positio
n.timestamp)); |
| 65 } | 65 } |
| 66 | 66 |
| 67 static PositionError* createPositionError(mojom::blink::Geoposition::ErrorCode m
ojomErrorCode, const String& error) | 67 static PositionError* createPositionError(device::mojom::blink::Geoposition::Err
orCode mojomErrorCode, const String& error) |
| 68 { | 68 { |
| 69 PositionError::ErrorCode errorCode = PositionError::kPositionUnavailable; | 69 PositionError::ErrorCode errorCode = PositionError::kPositionUnavailable; |
| 70 switch (mojomErrorCode) { | 70 switch (mojomErrorCode) { |
| 71 case mojom::blink::Geoposition::ErrorCode::PERMISSION_DENIED: | 71 case device::mojom::blink::Geoposition::ErrorCode::PERMISSION_DENIED: |
| 72 errorCode = PositionError::kPermissionDenied; | 72 errorCode = PositionError::kPermissionDenied; |
| 73 break; | 73 break; |
| 74 case mojom::blink::Geoposition::ErrorCode::POSITION_UNAVAILABLE: | 74 case device::mojom::blink::Geoposition::ErrorCode::POSITION_UNAVAILABLE: |
| 75 errorCode = PositionError::kPositionUnavailable; | 75 errorCode = PositionError::kPositionUnavailable; |
| 76 break; | 76 break; |
| 77 case mojom::blink::Geoposition::ErrorCode::NONE: | 77 case device::mojom::blink::Geoposition::ErrorCode::NONE: |
| 78 case mojom::blink::Geoposition::ErrorCode::TIMEOUT: | 78 case device::mojom::blink::Geoposition::ErrorCode::TIMEOUT: |
| 79 NOTREACHED(); | 79 NOTREACHED(); |
| 80 break; | 80 break; |
| 81 } | 81 } |
| 82 return PositionError::create(errorCode, error); | 82 return PositionError::create(errorCode, error); |
| 83 } | 83 } |
| 84 | 84 |
| 85 } // namespace | 85 } // namespace |
| 86 | 86 |
| 87 Geolocation* Geolocation::create(ExecutionContext* context) | 87 Geolocation* Geolocation::create(ExecutionContext* context) |
| 88 { | 88 { |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 if (m_enableHighAccuracy) | 498 if (m_enableHighAccuracy) |
| 499 m_geolocationService->SetHighAccuracy(true); | 499 m_geolocationService->SetHighAccuracy(true); |
| 500 queryNextPosition(); | 500 queryNextPosition(); |
| 501 } | 501 } |
| 502 | 502 |
| 503 void Geolocation::queryNextPosition() | 503 void Geolocation::queryNextPosition() |
| 504 { | 504 { |
| 505 m_geolocationService->QueryNextPosition(convertToBaseCallback(WTF::bind(&Geo
location::onPositionUpdated, wrapPersistent(this)))); | 505 m_geolocationService->QueryNextPosition(convertToBaseCallback(WTF::bind(&Geo
location::onPositionUpdated, wrapPersistent(this)))); |
| 506 } | 506 } |
| 507 | 507 |
| 508 void Geolocation::onPositionUpdated(mojom::blink::GeopositionPtr position) | 508 void Geolocation::onPositionUpdated(device::mojom::blink::GeopositionPtr positio
n) |
| 509 { | 509 { |
| 510 m_disconnectedGeolocationService = false; | 510 m_disconnectedGeolocationService = false; |
| 511 if (position->valid) { | 511 if (position->valid) { |
| 512 m_lastPosition = createGeoposition(*position); | 512 m_lastPosition = createGeoposition(*position); |
| 513 positionChanged(); | 513 positionChanged(); |
| 514 } else { | 514 } else { |
| 515 handleError(createPositionError(position->error_code, position->error_me
ssage)); | 515 handleError(createPositionError(position->error_code, position->error_me
ssage)); |
| 516 } | 516 } |
| 517 if (!m_disconnectedGeolocationService) | 517 if (!m_disconnectedGeolocationService) |
| 518 queryNextPosition(); | 518 queryNextPosition(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 529 error->setIsFatal(true); | 529 error->setIsFatal(true); |
| 530 handleError(error); | 530 handleError(error); |
| 531 } | 531 } |
| 532 | 532 |
| 533 void Geolocation::onPermissionConnectionError() | 533 void Geolocation::onPermissionConnectionError() |
| 534 { | 534 { |
| 535 onGeolocationPermissionUpdated(mojom::blink::PermissionStatus::DENIED); | 535 onGeolocationPermissionUpdated(mojom::blink::PermissionStatus::DENIED); |
| 536 } | 536 } |
| 537 | 537 |
| 538 } // namespace blink | 538 } // namespace blink |
| OLD | NEW |