| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) | 5 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) |
| 6 | 6 |
| 7 #include "chrome/renderer/geolocation_dispatcher.h" | 7 #include "chrome/renderer/geolocation_dispatcher.h" |
| 8 | 8 |
| 9 #include "chrome/renderer/render_view.h" | 9 #include "chrome/renderer/render_view.h" |
| 10 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 } | 117 } |
| 118 | 118 |
| 119 // We have an updated geolocation position or error code. | 119 // We have an updated geolocation position or error code. |
| 120 void GeolocationDispatcher::OnGeolocationPositionUpdated( | 120 void GeolocationDispatcher::OnGeolocationPositionUpdated( |
| 121 const Geoposition& geoposition) { | 121 const Geoposition& geoposition) { |
| 122 DCHECK(updating_); | 122 DCHECK(updating_); |
| 123 DCHECK(geoposition.IsInitialized()); | 123 DCHECK(geoposition.IsInitialized()); |
| 124 if (geoposition.IsValidFix()) { | 124 if (geoposition.IsValidFix()) { |
| 125 controller_->positionChanged( | 125 controller_->positionChanged( |
| 126 WebGeolocationPosition( | 126 WebGeolocationPosition( |
| 127 static_cast<int64>(geoposition.timestamp.ToDoubleT() * 1000), | 127 geoposition.timestamp.ToDoubleT() * 1000.0, |
| 128 geoposition.latitude, geoposition.longitude, | 128 geoposition.latitude, geoposition.longitude, |
| 129 geoposition.accuracy, | 129 geoposition.accuracy, |
| 130 geoposition.is_valid_altitude(), geoposition.altitude, | 130 geoposition.is_valid_altitude(), geoposition.altitude, |
| 131 geoposition.is_valid_altitude_accuracy(), | 131 geoposition.is_valid_altitude_accuracy(), |
| 132 geoposition.altitude_accuracy, | 132 geoposition.altitude_accuracy, |
| 133 geoposition.is_valid_heading(), geoposition.heading, | 133 geoposition.is_valid_heading(), geoposition.heading, |
| 134 geoposition.is_valid_speed(), geoposition.speed)); | 134 geoposition.is_valid_speed(), geoposition.speed)); |
| 135 } else { | 135 } else { |
| 136 WebGeolocationError::Error code; | 136 WebGeolocationError::Error code; |
| 137 switch (geoposition.error_code) { | 137 switch (geoposition.error_code) { |
| 138 case Geoposition::ERROR_CODE_PERMISSION_DENIED: | 138 case Geoposition::ERROR_CODE_PERMISSION_DENIED: |
| 139 code = WebGeolocationError::ErrorPermissionDenied; | 139 code = WebGeolocationError::ErrorPermissionDenied; |
| 140 break; | 140 break; |
| 141 case Geoposition::ERROR_CODE_POSITION_UNAVAILABLE: | 141 case Geoposition::ERROR_CODE_POSITION_UNAVAILABLE: |
| 142 code = WebGeolocationError::ErrorPositionUnavailable; | 142 code = WebGeolocationError::ErrorPositionUnavailable; |
| 143 break; | 143 break; |
| 144 default: | 144 default: |
| 145 DCHECK(false); | 145 DCHECK(false); |
| 146 NOTREACHED() << geoposition.error_code; | 146 NOTREACHED() << geoposition.error_code; |
| 147 return; | 147 return; |
| 148 } | 148 } |
| 149 controller_->errorOccurred( | 149 controller_->errorOccurred( |
| 150 WebGeolocationError( | 150 WebGeolocationError( |
| 151 code, WebKit::WebString::fromUTF8(geoposition.error_message))); | 151 code, WebKit::WebString::fromUTF8(geoposition.error_message))); |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 | 154 |
| 155 #endif // CLIENT_BASED_GEOLOCATION | 155 #endif // CLIENT_BASED_GEOLOCATION |
| OLD | NEW |