OLD | NEW |
---|---|
1 // Copyright (c) 2012 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/browser/geolocation/geolocation_dispatcher_host.h" | 5 #include "content/browser/geolocation/geolocation_dispatcher_host.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "content/browser/geolocation/geolocation_provider_impl.h" | 13 #include "content/browser/geolocation/geolocation_provider_impl.h" |
14 #include "content/browser/renderer_host/render_message_filter.h" | 14 #include "content/browser/renderer_host/render_message_filter.h" |
15 #include "content/browser/renderer_host/render_process_host_impl.h" | 15 #include "content/browser/renderer_host/render_process_host_impl.h" |
16 #include "content/browser/renderer_host/render_view_host_impl.h" | 16 #include "content/browser/renderer_host/render_view_host_impl.h" |
17 #include "content/public/browser/geolocation_permission_context.h" | 17 #include "content/public/browser/geolocation_permission_context.h" |
18 #include "content/public/common/geoposition.h" | 18 #include "content/public/common/geoposition.h" |
19 #include "content/common/geolocation_messages.h" | 19 #include "content/common/geolocation_messages.h" |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 namespace { | 22 namespace { |
23 | 23 |
24 // Geoposition error codes for reporting in UMA. | |
25 enum GeopositionErrorCode { | |
26 // NOTE: Do not renumber these as that would confuse interpretation of | |
27 // previously logged data. When making changes, also update the enum list | |
28 // in tools/metrics/histograms/histograms.xml to keep it in sync. | |
29 | |
30 // There was no error. | |
31 GEOPOSITION_ERROR_CODE_NONE = 0, | |
32 | |
33 // User denied use of geolocation. | |
34 GEOPOSITION_ERROR_CODE_PERMISSION_DENIED = 1, | |
35 | |
36 // Geoposition could not be determined | |
timvolodine
2014/04/08 12:35:57
nit: period at the eol.
Michael van Ouwerkerk
2014/04/08 13:01:40
Done.
| |
37 GEOPOSITION_ERROR_CODE_POSITION_UNAVAILABLE = 2, | |
38 | |
39 // Timeout. | |
40 GEOPOSITION_ERROR_CODE_TIMEOUT = 3, | |
41 | |
42 // NOTE: Add entries only immediately above this line. | |
43 GEOPOSITION_ERROR_CODE_COUNT = 4 | |
44 }; | |
45 | |
46 void RecordGeopositionErrorCode(Geoposition::ErrorCode error_code) { | |
47 GeopositionErrorCode code = GEOPOSITION_ERROR_CODE_NONE; | |
48 switch (error_code) { | |
49 case Geoposition::ERROR_CODE_NONE: | |
50 code = GEOPOSITION_ERROR_CODE_NONE; | |
51 break; | |
52 case Geoposition::ERROR_CODE_PERMISSION_DENIED: | |
53 code = GEOPOSITION_ERROR_CODE_PERMISSION_DENIED; | |
54 break; | |
55 case Geoposition::ERROR_CODE_POSITION_UNAVAILABLE: | |
56 code = GEOPOSITION_ERROR_CODE_POSITION_UNAVAILABLE; | |
57 break; | |
58 case Geoposition::ERROR_CODE_TIMEOUT: | |
59 code = GEOPOSITION_ERROR_CODE_TIMEOUT; | |
60 break; | |
61 default: | |
62 NOTREACHED(); | |
Ilya Sherman
2014/04/07 23:54:12
Please remove the default case, so that the compil
Michael van Ouwerkerk
2014/04/08 13:01:40
Done.
| |
63 } | |
64 UMA_HISTOGRAM_ENUMERATION("Geolocation.LocationUpdate.ErrorCode", | |
65 code, | |
66 GEOPOSITION_ERROR_CODE_COUNT); | |
67 } | |
68 | |
24 void NotifyGeolocationProviderPermissionGranted() { | 69 void NotifyGeolocationProviderPermissionGranted() { |
25 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
26 GeolocationProviderImpl::GetInstance()->UserDidOptIntoLocationServices(); | 71 GeolocationProviderImpl::GetInstance()->UserDidOptIntoLocationServices(); |
27 } | 72 } |
28 | 73 |
29 void SendGeolocationPermissionResponse(int render_process_id, | 74 void SendGeolocationPermissionResponse(int render_process_id, |
30 int render_view_id, | 75 int render_view_id, |
31 int bridge_id, | 76 int bridge_id, |
32 bool allowed) { | 77 bool allowed) { |
33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 IPC_MESSAGE_HANDLER(GeolocationHostMsg_StartUpdating, OnStartUpdating) | 186 IPC_MESSAGE_HANDLER(GeolocationHostMsg_StartUpdating, OnStartUpdating) |
142 IPC_MESSAGE_HANDLER(GeolocationHostMsg_StopUpdating, OnStopUpdating) | 187 IPC_MESSAGE_HANDLER(GeolocationHostMsg_StopUpdating, OnStopUpdating) |
143 IPC_MESSAGE_UNHANDLED(handled = false) | 188 IPC_MESSAGE_UNHANDLED(handled = false) |
144 IPC_END_MESSAGE_MAP() | 189 IPC_END_MESSAGE_MAP() |
145 return handled; | 190 return handled; |
146 } | 191 } |
147 | 192 |
148 void GeolocationDispatcherHostImpl::OnLocationUpdate( | 193 void GeolocationDispatcherHostImpl::OnLocationUpdate( |
149 const Geoposition& geoposition) { | 194 const Geoposition& geoposition) { |
150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
196 RecordGeopositionErrorCode(geoposition.error_code); | |
151 for (std::map<int, RendererGeolocationOptions>::iterator it = | 197 for (std::map<int, RendererGeolocationOptions>::iterator it = |
152 geolocation_renderers_.begin(); | 198 geolocation_renderers_.begin(); |
153 it != geolocation_renderers_.end(); ++it) { | 199 it != geolocation_renderers_.end(); ++it) { |
154 if (!(it->second.is_paused)) | 200 if (!(it->second.is_paused)) |
155 Send(new GeolocationMsg_PositionUpdated(it->first, geoposition)); | 201 Send(new GeolocationMsg_PositionUpdated(it->first, geoposition)); |
156 } | 202 } |
157 } | 203 } |
158 | 204 |
159 void GeolocationDispatcherHostImpl::OnRequestPermission( | 205 void GeolocationDispatcherHostImpl::OnRequestPermission( |
160 int render_view_id, | 206 int render_view_id, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 } | 342 } |
297 | 343 |
298 GeolocationDispatcherHost::GeolocationDispatcherHost() | 344 GeolocationDispatcherHost::GeolocationDispatcherHost() |
299 : BrowserMessageFilter(GeolocationMsgStart) { | 345 : BrowserMessageFilter(GeolocationMsgStart) { |
300 } | 346 } |
301 | 347 |
302 GeolocationDispatcherHost::~GeolocationDispatcherHost() { | 348 GeolocationDispatcherHost::~GeolocationDispatcherHost() { |
303 } | 349 } |
304 | 350 |
305 } // namespace content | 351 } // namespace content |
OLD | NEW |