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

Side by Side Diff: content/browser/geolocation/geolocation_dispatcher_host.cc

Issue 622793002: Group the different permission related methods in the content api. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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
OLDNEW
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"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 } 159 }
160 160
161 void GeolocationDispatcherHost::UpdateGeoposition( 161 void GeolocationDispatcherHost::UpdateGeoposition(
162 RenderFrameHost* frame, 162 RenderFrameHost* frame,
163 const Geoposition& geoposition) { 163 const Geoposition& geoposition) {
164 RenderFrameHost* top_frame = frame; 164 RenderFrameHost* top_frame = frame;
165 while (top_frame->GetParent()) { 165 while (top_frame->GetParent()) {
166 top_frame = top_frame->GetParent(); 166 top_frame = top_frame->GetParent();
167 } 167 }
168 GetContentClient()->browser()->DidUseGeolocationPermission( 168 GetContentClient()->browser()->RegisterPermissionUsage(
169 content::PERMISSION_GEOLOCATION,
169 web_contents(), 170 web_contents(),
170 frame->GetLastCommittedURL().GetOrigin(), 171 frame->GetLastCommittedURL().GetOrigin(),
171 top_frame->GetLastCommittedURL().GetOrigin()); 172 top_frame->GetLastCommittedURL().GetOrigin());
172 173
173 frame->Send(new GeolocationMsg_PositionUpdated( 174 frame->Send(new GeolocationMsg_PositionUpdated(
174 frame->GetRoutingID(), geoposition)); 175 frame->GetRoutingID(), geoposition));
175 } 176 }
176 177
177 void GeolocationDispatcherHost::OnRequestPermission( 178 void GeolocationDispatcherHost::OnRequestPermission(
178 RenderFrameHost* render_frame_host, 179 RenderFrameHost* render_frame_host,
179 int bridge_id, 180 int bridge_id,
180 const GURL& requesting_origin, 181 const GURL& requesting_origin,
181 bool user_gesture) { 182 bool user_gesture) {
182 int render_process_id = render_frame_host->GetProcess()->GetID(); 183 int render_process_id = render_frame_host->GetProcess()->GetID();
183 int render_frame_id = render_frame_host->GetRoutingID(); 184 int render_frame_id = render_frame_host->GetRoutingID();
184 185
185 PendingPermission pending_permission( 186 PendingPermission pending_permission(
186 render_frame_id, render_process_id, bridge_id, requesting_origin); 187 render_frame_id, render_process_id, bridge_id, requesting_origin);
187 pending_permissions_.push_back(pending_permission); 188 pending_permissions_.push_back(pending_permission);
188 189
189 GetContentClient()->browser()->RequestGeolocationPermission( 190 GetContentClient()->browser()->RequestPermission(
191 content::PERMISSION_GEOLOCATION,
190 web_contents(), 192 web_contents(),
191 bridge_id, 193 bridge_id,
192 requesting_origin, 194 requesting_origin,
193 user_gesture, 195 user_gesture,
194 base::Bind(&GeolocationDispatcherHost::SendGeolocationPermissionResponse, 196 base::Bind(&GeolocationDispatcherHost::SendGeolocationPermissionResponse,
195 weak_factory_.GetWeakPtr(), 197 weak_factory_.GetWeakPtr(),
196 render_process_id, render_frame_id, bridge_id)); 198 render_process_id,
199 render_frame_id,
200 bridge_id));
197 } 201 }
198 202
199 void GeolocationDispatcherHost::OnStartUpdating( 203 void GeolocationDispatcherHost::OnStartUpdating(
200 RenderFrameHost* render_frame_host, 204 RenderFrameHost* render_frame_host,
201 const GURL& requesting_origin, 205 const GURL& requesting_origin,
202 bool enable_high_accuracy) { 206 bool enable_high_accuracy) {
203 // StartUpdating() can be invoked as a result of high-accuracy mode 207 // StartUpdating() can be invoked as a result of high-accuracy mode
204 // being enabled / disabled. No need to record the dispatcher again. 208 // being enabled / disabled. No need to record the dispatcher again.
205 UMA_HISTOGRAM_BOOLEAN( 209 UMA_HISTOGRAM_BOOLEAN(
206 "Geolocation.GeolocationDispatcherHostImpl.EnableHighAccuracy", 210 "Geolocation.GeolocationDispatcherHostImpl.EnableHighAccuracy",
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 283 }
280 284
281 void GeolocationDispatcherHost::CancelPermissionRequestsForFrame( 285 void GeolocationDispatcherHost::CancelPermissionRequestsForFrame(
282 RenderFrameHost* render_frame_host) { 286 RenderFrameHost* render_frame_host) {
283 int render_process_id = render_frame_host->GetProcess()->GetID(); 287 int render_process_id = render_frame_host->GetProcess()->GetID();
284 int render_frame_id = render_frame_host->GetRoutingID(); 288 int render_frame_id = render_frame_host->GetRoutingID();
285 289
286 for (size_t i = 0; i < pending_permissions_.size(); ++i) { 290 for (size_t i = 0; i < pending_permissions_.size(); ++i) {
287 if (pending_permissions_[i].render_process_id == render_process_id && 291 if (pending_permissions_[i].render_process_id == render_process_id &&
288 pending_permissions_[i].render_frame_id == render_frame_id) { 292 pending_permissions_[i].render_frame_id == render_frame_id) {
289 GetContentClient()->browser()->CancelGeolocationPermissionRequest( 293 GetContentClient()->browser()->CancelPermissionRequest(
294 content::PERMISSION_GEOLOCATION,
290 web_contents(), 295 web_contents(),
291 pending_permissions_[i].bridge_id, 296 pending_permissions_[i].bridge_id,
292 pending_permissions_[i].origin); 297 pending_permissions_[i].origin);
293 pending_permissions_.erase(pending_permissions_.begin() + i); 298 pending_permissions_.erase(pending_permissions_.begin() + i);
294 } 299 }
295 } 300 }
296 } 301 }
297 302
298 } // namespace content 303 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698