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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "content/browser/frame_host/render_frame_host_impl.h" | 11 #include "content/browser/frame_host/render_frame_host_impl.h" |
12 #include "content/browser/renderer_host/render_message_filter.h" | 12 #include "content/browser/renderer_host/render_message_filter.h" |
13 #include "content/browser/renderer_host/render_process_host_impl.h" | 13 #include "content/browser/renderer_host/render_process_host_impl.h" |
14 #include "content/browser/renderer_host/render_view_host_impl.h" | 14 #include "content/browser/renderer_host/render_view_host_impl.h" |
15 #include "content/browser/web_contents/web_contents_impl.h" | 15 #include "content/browser/web_contents/web_contents_impl.h" |
16 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
17 #include "content/public/browser/content_browser_client.h" | 17 #include "content/public/browser/content_browser_client.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 const char kGeolocationPermission[] = "geolocation"; | |
25 | |
24 // Geoposition error codes for reporting in UMA. | 26 // Geoposition error codes for reporting in UMA. |
25 enum GeopositionErrorCode { | 27 enum GeopositionErrorCode { |
26 // NOTE: Do not renumber these as that would confuse interpretation of | 28 // NOTE: Do not renumber these as that would confuse interpretation of |
27 // previously logged data. When making changes, also update the enum list | 29 // previously logged data. When making changes, also update the enum list |
28 // in tools/metrics/histograms/histograms.xml to keep it in sync. | 30 // in tools/metrics/histograms/histograms.xml to keep it in sync. |
29 | 31 |
30 // There was no error. | 32 // There was no error. |
31 GEOPOSITION_ERROR_CODE_NONE = 0, | 33 GEOPOSITION_ERROR_CODE_NONE = 0, |
32 | 34 |
33 // User denied use of geolocation. | 35 // User denied use of geolocation. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 void GeolocationDispatcherHost::OnLocationUpdate( | 125 void GeolocationDispatcherHost::OnLocationUpdate( |
124 const Geoposition& geoposition) { | 126 const Geoposition& geoposition) { |
125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
126 | 128 |
127 RecordGeopositionErrorCode(geoposition.error_code); | 129 RecordGeopositionErrorCode(geoposition.error_code); |
128 if (paused_) | 130 if (paused_) |
129 return; | 131 return; |
130 | 132 |
131 for (std::map<RenderFrameHost*, bool>::iterator i = updating_frames_.begin(); | 133 for (std::map<RenderFrameHost*, bool>::iterator i = updating_frames_.begin(); |
132 i != updating_frames_.end(); ++i) { | 134 i != updating_frames_.end(); ++i) { |
135 RenderFrameHost* topFrame = i->first; | |
136 while (topFrame->GetParent()) { | |
137 topFrame = topFrame->GetParent(); | |
138 } | |
139 GetContentClient()->browser()->UseContentSettingPermission( | |
140 web_contents(), | |
141 topFrame->GetLastCommittedURL().GetOrigin(), | |
Michael van Ouwerkerk
2014/07/08 17:02:18
Sorry to keep going on about this, but from what I
Daniel Nishi
2014/07/08 18:14:35
I think I understand now. So this change here shou
| |
142 topFrame->GetLastCommittedURL().GetOrigin(), | |
143 kGeolocationPermission); | |
144 | |
133 i->first->Send(new GeolocationMsg_PositionUpdated( | 145 i->first->Send(new GeolocationMsg_PositionUpdated( |
134 i->first->GetRoutingID(), geoposition)); | 146 i->first->GetRoutingID(), geoposition)); |
135 } | 147 } |
136 } | 148 } |
137 | 149 |
138 void GeolocationDispatcherHost::OnRequestPermission( | 150 void GeolocationDispatcherHost::OnRequestPermission( |
139 RenderFrameHost* render_frame_host, | 151 RenderFrameHost* render_frame_host, |
140 int bridge_id, | 152 int bridge_id, |
141 const GURL& requesting_frame, | 153 const GURL& requesting_frame, |
142 bool user_gesture) { | 154 bool user_gesture) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 | 260 |
249 pending_permissions_.erase(pending_permissions_.begin() + i); | 261 pending_permissions_.erase(pending_permissions_.begin() + i); |
250 return; | 262 return; |
251 } | 263 } |
252 } | 264 } |
253 | 265 |
254 NOTREACHED(); | 266 NOTREACHED(); |
255 } | 267 } |
256 | 268 |
257 } // namespace content | 269 } // namespace content |
OLD | NEW |