Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: content/renderer/geolocation_dispatcher.cc

Issue 10316007: Make the Geoposition helper class public (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix forward-declaration of struct as class. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/geolocation_dispatcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/renderer/geolocation_dispatcher.h" 5 #include "content/renderer/geolocation_dispatcher.h"
6 6
7 #include "content/common/geolocation_messages.h" 7 #include "content/common/geolocation_messages.h"
8 #include "content/renderer/render_view_impl.h" 8 #include "content/renderer/render_view_impl.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationPermiss ionRequest.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationPermiss ionRequest.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationPermiss ionRequestManager.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationPermiss ionRequestManager.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationClient. h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationClient. h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 // Permission for using geolocation has been set. 106 // Permission for using geolocation has been set.
107 void GeolocationDispatcher::OnPermissionSet(int bridge_id, bool is_allowed) { 107 void GeolocationDispatcher::OnPermissionSet(int bridge_id, bool is_allowed) {
108 WebGeolocationPermissionRequest permissionRequest; 108 WebGeolocationPermissionRequest permissionRequest;
109 if (!pending_permissions_->remove(bridge_id, permissionRequest)) 109 if (!pending_permissions_->remove(bridge_id, permissionRequest))
110 return; 110 return;
111 permissionRequest.setIsAllowed(is_allowed); 111 permissionRequest.setIsAllowed(is_allowed);
112 } 112 }
113 113
114 // We have an updated geolocation position or error code. 114 // We have an updated geolocation position or error code.
115 void GeolocationDispatcher::OnPositionUpdated(const Geoposition& geoposition) { 115 void GeolocationDispatcher::OnPositionUpdated(
116 const content::Geoposition& geoposition) {
116 // It is possible for the browser process to have queued an update message 117 // It is possible for the browser process to have queued an update message
117 // before receiving the stop updating message. 118 // before receiving the stop updating message.
118 if (!updating_) 119 if (!updating_)
119 return; 120 return;
120 121
121 DCHECK(geoposition.IsInitialized()); 122 if (geoposition.Validate()) {
122 if (geoposition.IsValidFix()) {
123 controller_->positionChanged( 123 controller_->positionChanged(
124 WebGeolocationPosition( 124 WebGeolocationPosition(
125 geoposition.timestamp.ToDoubleT(), 125 geoposition.timestamp.ToDoubleT(),
126 geoposition.latitude, geoposition.longitude, 126 geoposition.latitude, geoposition.longitude,
127 geoposition.accuracy, 127 geoposition.accuracy,
128 geoposition.is_valid_altitude(), geoposition.altitude, 128 // Lowest point on land is at approximately -400 meters.
129 geoposition.is_valid_altitude_accuracy(), 129 geoposition.altitude > -10000.,
130 geoposition.altitude,
131 geoposition.altitude_accuracy >= 0.,
130 geoposition.altitude_accuracy, 132 geoposition.altitude_accuracy,
131 geoposition.is_valid_heading(), geoposition.heading, 133 geoposition.heading >= 0. && geoposition.heading <= 360.,
132 geoposition.is_valid_speed(), geoposition.speed)); 134 geoposition.heading,
135 geoposition.speed >= 0.,
136 geoposition.speed));
133 } else { 137 } else {
134 WebGeolocationError::Error code; 138 WebGeolocationError::Error code;
135 switch (geoposition.error_code) { 139 switch (geoposition.error_code) {
136 case Geoposition::ERROR_CODE_PERMISSION_DENIED: 140 case content::Geoposition::ERROR_CODE_PERMISSION_DENIED:
137 code = WebGeolocationError::ErrorPermissionDenied; 141 code = WebGeolocationError::ErrorPermissionDenied;
138 break; 142 break;
139 case Geoposition::ERROR_CODE_POSITION_UNAVAILABLE: 143 case content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE:
140 code = WebGeolocationError::ErrorPositionUnavailable; 144 code = WebGeolocationError::ErrorPositionUnavailable;
141 break; 145 break;
142 default: 146 default:
143 DCHECK(false);
144 NOTREACHED() << geoposition.error_code; 147 NOTREACHED() << geoposition.error_code;
145 return; 148 return;
146 } 149 }
147 controller_->errorOccurred( 150 controller_->errorOccurred(
148 WebGeolocationError( 151 WebGeolocationError(
149 code, WebKit::WebString::fromUTF8(geoposition.error_message))); 152 code, WebKit::WebString::fromUTF8(geoposition.error_message)));
150 } 153 }
151 } 154 }
OLDNEW
« no previous file with comments | « content/renderer/geolocation_dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698