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

Side by Side Diff: chrome/browser/guest_view/web_view/web_view_permission_helper.cc

Issue 454253002: Location chooser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing meacer@ comments Created 6 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/guest_view/web_view/web_view_permission_helper.h" 5 #include "chrome/browser/guest_view/web_view/web_view_permission_helper.h"
6 6
7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 7 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
8 #include "chrome/browser/geolocation/geolocation_permission_context.h" 8 #include "chrome/browser/geolocation/geolocation_permission_context.h"
9 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" 9 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h"
10 #include "chrome/browser/guest_view/web_view/web_view_constants.h" 10 #include "chrome/browser/guest_view/web_view/web_view_constants.h"
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 const base::Callback<void(bool)>& callback, 343 const base::Callback<void(bool)>& callback,
344 bool allow, 344 bool allow,
345 const std::string& user_input) { 345 const std::string& user_input) {
346 callback.Run(allow && web_view_guest_->attached()); 346 callback.Run(allow && web_view_guest_->attached());
347 } 347 }
348 348
349 void WebViewPermissionHelper::RequestGeolocationPermission( 349 void WebViewPermissionHelper::RequestGeolocationPermission(
350 int bridge_id, 350 int bridge_id,
351 const GURL& requesting_frame, 351 const GURL& requesting_frame,
352 bool user_gesture, 352 bool user_gesture,
353 const base::Callback<void(bool)>& callback) { 353 const base::Callback<void(int, bool)>& callback) {
354 base::DictionaryValue request_info; 354 base::DictionaryValue request_info;
355 request_info.SetString(guestview::kUrl, requesting_frame.spec()); 355 request_info.SetString(guestview::kUrl, requesting_frame.spec());
356 request_info.SetBoolean(guestview::kUserGesture, user_gesture); 356 request_info.SetBoolean(guestview::kUserGesture, user_gesture);
357 357
358 // It is safe to hold an unretained pointer to WebViewPermissionHelper because 358 // It is safe to hold an unretained pointer to WebViewPermissionHelper because
359 // this callback is called from WebViewPermissionHelper::SetPermission. 359 // this callback is called from WebViewPermissionHelper::SetPermission.
360 const PermissionResponseCallback permission_callback = 360 const PermissionResponseCallback permission_callback =
361 base::Bind( 361 base::Bind(
362 &WebViewPermissionHelper::OnGeolocationPermissionResponse, 362 &WebViewPermissionHelper::OnGeolocationPermissionResponse,
363 base::Unretained(this), 363 base::Unretained(this),
364 bridge_id, 364 bridge_id,
365 user_gesture, 365 user_gesture,
366 callback); 366 callback);
367 int request_id = RequestPermission( 367 int request_id = RequestPermission(
368 WEB_VIEW_PERMISSION_TYPE_GEOLOCATION, 368 WEB_VIEW_PERMISSION_TYPE_GEOLOCATION,
369 request_info, 369 request_info,
370 permission_callback, 370 permission_callback,
371 false /* allowed_by_default */); 371 false /* allowed_by_default */);
372 bridge_id_to_request_id_map_[bridge_id] = request_id; 372 bridge_id_to_request_id_map_[bridge_id] = request_id;
373 } 373 }
374 374
375 void WebViewPermissionHelper::OnGeolocationPermissionResponse( 375 void WebViewPermissionHelper::OnGeolocationPermissionResponse(
376 int bridge_id, 376 int bridge_id,
377 bool user_gesture, 377 bool user_gesture,
378 const base::Callback<void(bool)>& callback, 378 const base::Callback<void(int, bool)>& callback,
379 bool allow, 379 bool allow,
380 const std::string& user_input) { 380 const std::string& user_input) {
381 // The <webview> embedder has allowed the permission. We now need to make sure 381 // The <webview> embedder has allowed the permission. We now need to make sure
382 // that the embedder has geolocation permission. 382 // that the embedder has geolocation permission.
383 RemoveBridgeID(bridge_id); 383 RemoveBridgeID(bridge_id);
384 384
385 if (!allow || !web_view_guest_->attached()) { 385 if (!allow || !web_view_guest_->attached()) {
386 callback.Run(false); 386 callback.Run(false, -1);
387 return; 387 return;
388 } 388 }
389 389
390 Profile* profile = Profile::FromBrowserContext( 390 Profile* profile = Profile::FromBrowserContext(
391 web_view_guest_->browser_context()); 391 web_view_guest_->browser_context());
392 GeolocationPermissionContextFactory::GetForProfile(profile)-> 392 GeolocationPermissionContextFactory::GetForProfile(profile)->
393 RequestGeolocationPermission( 393 RequestGeolocationPermission(
394 web_view_guest_->embedder_web_contents(), 394 web_view_guest_->embedder_web_contents(),
395 // The geolocation permission request here is not initiated 395 // The geolocation permission request here is not initiated
396 // through WebGeolocationPermissionRequest. We are only interested 396 // through WebGeolocationPermissionRequest. We are only interested
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 const PermissionResponseCallback& callback, 590 const PermissionResponseCallback& callback,
591 WebViewPermissionType permission_type, 591 WebViewPermissionType permission_type,
592 bool allowed_by_default) 592 bool allowed_by_default)
593 : callback(callback), 593 : callback(callback),
594 permission_type(permission_type), 594 permission_type(permission_type),
595 allowed_by_default(allowed_by_default) { 595 allowed_by_default(allowed_by_default) {
596 } 596 }
597 597
598 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() { 598 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() {
599 } 599 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698