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

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

Issue 399493002: Remove many instances of CreateBooleanValue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 | Annotate | Revision Log
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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 256 }
257 } 257 }
258 258
259 #endif // defined(ENABLE_PLUGINS) 259 #endif // defined(ENABLE_PLUGINS)
260 260
261 void WebViewPermissionHelper::RequestMediaAccessPermission( 261 void WebViewPermissionHelper::RequestMediaAccessPermission(
262 content::WebContents* source, 262 content::WebContents* source,
263 const content::MediaStreamRequest& request, 263 const content::MediaStreamRequest& request,
264 const content::MediaResponseCallback& callback) { 264 const content::MediaResponseCallback& callback) {
265 base::DictionaryValue request_info; 265 base::DictionaryValue request_info;
266 request_info.Set(guestview::kUrl, 266 request_info.SetString(guestview::kUrl, request.security_origin.spec());
267 new base::StringValue(request.security_origin.spec()));
268 RequestPermission(WEB_VIEW_PERMISSION_TYPE_MEDIA, 267 RequestPermission(WEB_VIEW_PERMISSION_TYPE_MEDIA,
269 request_info, 268 request_info,
270 base::Bind(&WebViewPermissionHelper:: 269 base::Bind(&WebViewPermissionHelper::
271 OnMediaPermissionResponse, 270 OnMediaPermissionResponse,
272 base::Unretained(this), 271 base::Unretained(this),
273 request, 272 request,
274 callback), 273 callback),
275 false /* allowed_by_default */); 274 false /* allowed_by_default */);
276 } 275 }
277 276
(...skipping 17 matching lines...) Expand all
295 request, 294 request,
296 callback); 295 callback);
297 } 296 }
298 297
299 void WebViewPermissionHelper::CanDownload( 298 void WebViewPermissionHelper::CanDownload(
300 content::RenderViewHost* render_view_host, 299 content::RenderViewHost* render_view_host,
301 const GURL& url, 300 const GURL& url,
302 const std::string& request_method, 301 const std::string& request_method,
303 const base::Callback<void(bool)>& callback) { 302 const base::Callback<void(bool)>& callback) {
304 base::DictionaryValue request_info; 303 base::DictionaryValue request_info;
305 request_info.Set(guestview::kUrl, new base::StringValue(url.spec())); 304 request_info.SetString(guestview::kUrl, url.spec());
306 RequestPermission( 305 RequestPermission(
307 WEB_VIEW_PERMISSION_TYPE_DOWNLOAD, 306 WEB_VIEW_PERMISSION_TYPE_DOWNLOAD,
308 request_info, 307 request_info,
309 base::Bind(&WebViewPermissionHelper::OnDownloadPermissionResponse, 308 base::Bind(&WebViewPermissionHelper::OnDownloadPermissionResponse,
310 base::Unretained(this), 309 base::Unretained(this),
311 callback), 310 callback),
312 false /* allowed_by_default */); 311 false /* allowed_by_default */);
313 } 312 }
314 313
315 void WebViewPermissionHelper::OnDownloadPermissionResponse( 314 void WebViewPermissionHelper::OnDownloadPermissionResponse(
316 const base::Callback<void(bool)>& callback, 315 const base::Callback<void(bool)>& callback,
317 bool allow, 316 bool allow,
318 const std::string& user_input) { 317 const std::string& user_input) {
319 callback.Run(allow && web_view_guest_->attached()); 318 callback.Run(allow && web_view_guest_->attached());
320 } 319 }
321 320
322 void WebViewPermissionHelper::RequestPointerLockPermission( 321 void WebViewPermissionHelper::RequestPointerLockPermission(
323 bool user_gesture, 322 bool user_gesture,
324 bool last_unlocked_by_target, 323 bool last_unlocked_by_target,
325 const base::Callback<void(bool)>& callback) { 324 const base::Callback<void(bool)>& callback) {
326 base::DictionaryValue request_info; 325 base::DictionaryValue request_info;
327 request_info.Set(guestview::kUserGesture, 326 request_info.SetBoolean(guestview::kUserGesture, user_gesture);
328 base::Value::CreateBooleanValue(user_gesture)); 327 request_info.SetBoolean(webview::kLastUnlockedBySelf,
329 request_info.Set(webview::kLastUnlockedBySelf, 328 last_unlocked_by_target);
330 base::Value::CreateBooleanValue(last_unlocked_by_target)); 329 request_info.SetString(guestview::kUrl,
331 request_info.Set(guestview::kUrl, 330 web_contents()->GetLastCommittedURL().spec());
332 new base::StringValue(
333 web_contents()->GetLastCommittedURL().spec()));
334 331
335 RequestPermission( 332 RequestPermission(
336 WEB_VIEW_PERMISSION_TYPE_POINTER_LOCK, 333 WEB_VIEW_PERMISSION_TYPE_POINTER_LOCK,
337 request_info, 334 request_info,
338 base::Bind( 335 base::Bind(
339 &WebViewPermissionHelper::OnPointerLockPermissionResponse, 336 &WebViewPermissionHelper::OnPointerLockPermissionResponse,
340 base::Unretained(this), 337 base::Unretained(this),
341 callback), 338 callback),
342 false /* allowed_by_default */); 339 false /* allowed_by_default */);
343 } 340 }
344 341
345 void WebViewPermissionHelper::OnPointerLockPermissionResponse( 342 void WebViewPermissionHelper::OnPointerLockPermissionResponse(
346 const base::Callback<void(bool)>& callback, 343 const base::Callback<void(bool)>& callback,
347 bool allow, 344 bool allow,
348 const std::string& user_input) { 345 const std::string& user_input) {
349 callback.Run(allow && web_view_guest_->attached()); 346 callback.Run(allow && web_view_guest_->attached());
350 } 347 }
351 348
352 void WebViewPermissionHelper::RequestGeolocationPermission( 349 void WebViewPermissionHelper::RequestGeolocationPermission(
353 int bridge_id, 350 int bridge_id,
354 const GURL& requesting_frame, 351 const GURL& requesting_frame,
355 bool user_gesture, 352 bool user_gesture,
356 const base::Callback<void(bool)>& callback) { 353 const base::Callback<void(bool)>& callback) {
357 base::DictionaryValue request_info; 354 base::DictionaryValue request_info;
358 request_info.Set(guestview::kUrl, 355 request_info.SetString(guestview::kUrl, requesting_frame.spec());
359 new base::StringValue(requesting_frame.spec())); 356 request_info.SetBoolean(guestview::kUserGesture, user_gesture);
360 request_info.Set(guestview::kUserGesture,
361 base::Value::CreateBooleanValue(user_gesture));
362 357
363 // It is safe to hold an unretained pointer to WebViewPermissionHelper because 358 // It is safe to hold an unretained pointer to WebViewPermissionHelper because
364 // this callback is called from WebViewPermissionHelper::SetPermission. 359 // this callback is called from WebViewPermissionHelper::SetPermission.
365 const PermissionResponseCallback permission_callback = 360 const PermissionResponseCallback permission_callback =
366 base::Bind( 361 base::Bind(
367 &WebViewPermissionHelper::OnGeolocationPermissionResponse, 362 &WebViewPermissionHelper::OnGeolocationPermissionResponse,
368 base::Unretained(this), 363 base::Unretained(this),
369 bridge_id, 364 bridge_id,
370 user_gesture, 365 user_gesture,
371 callback); 366 callback);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 int request_id = bridge_itr->second; 424 int request_id = bridge_itr->second;
430 bridge_id_to_request_id_map_.erase(bridge_itr); 425 bridge_id_to_request_id_map_.erase(bridge_itr);
431 return request_id; 426 return request_id;
432 } 427 }
433 428
434 void WebViewPermissionHelper::RequestFileSystemPermission( 429 void WebViewPermissionHelper::RequestFileSystemPermission(
435 const GURL& url, 430 const GURL& url,
436 bool allowed_by_default, 431 bool allowed_by_default,
437 const base::Callback<void(bool)>& callback) { 432 const base::Callback<void(bool)>& callback) {
438 base::DictionaryValue request_info; 433 base::DictionaryValue request_info;
439 request_info.Set(guestview::kUrl, new base::StringValue(url.spec())); 434 request_info.SetString(guestview::kUrl, url.spec());
440 RequestPermission( 435 RequestPermission(
441 WEB_VIEW_PERMISSION_TYPE_FILESYSTEM, 436 WEB_VIEW_PERMISSION_TYPE_FILESYSTEM,
442 request_info, 437 request_info,
443 base::Bind( 438 base::Bind(
444 &WebViewPermissionHelper::OnFileSystemPermissionResponse, 439 &WebViewPermissionHelper::OnFileSystemPermissionResponse,
445 base::Unretained(this), 440 base::Unretained(this),
446 callback), 441 callback),
447 allowed_by_default); 442 allowed_by_default);
448 } 443 }
449 444
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 const PermissionResponseCallback& callback, 590 const PermissionResponseCallback& callback,
596 WebViewPermissionType permission_type, 591 WebViewPermissionType permission_type,
597 bool allowed_by_default) 592 bool allowed_by_default)
598 : callback(callback), 593 : callback(callback),
599 permission_type(permission_type), 594 permission_type(permission_type),
600 allowed_by_default(allowed_by_default) { 595 allowed_by_default(allowed_by_default) {
601 } 596 }
602 597
603 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() { 598 WebViewPermissionHelper::PermissionResponseInfo::~PermissionResponseInfo() {
604 } 599 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698