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

Side by Side Diff: android_webview/browser/aw_content_browser_client.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 "android_webview/browser/aw_content_browser_client.h" 5 #include "android_webview/browser/aw_content_browser_client.h"
6 6
7 #include "android_webview/browser/aw_browser_context.h" 7 #include "android_webview/browser/aw_browser_context.h"
8 #include "android_webview/browser/aw_browser_main_parts.h" 8 #include "android_webview/browser/aw_browser_main_parts.h"
9 #include "android_webview/browser/aw_browser_permission_request_delegate.h" 9 #include "android_webview/browser/aw_browser_permission_request_delegate.h"
10 #include "android_webview/browser/aw_contents_client_bridge_base.h" 10 #include "android_webview/browser/aw_contents_client_bridge_base.h"
11 #include "android_webview/browser/aw_contents_io_thread_client.h" 11 #include "android_webview/browser/aw_contents_io_thread_client.h"
12 #include "android_webview/browser/aw_cookie_access_policy.h" 12 #include "android_webview/browser/aw_cookie_access_policy.h"
13 #include "android_webview/browser/aw_dev_tools_manager_delegate.h" 13 #include "android_webview/browser/aw_dev_tools_manager_delegate.h"
14 #include "android_webview/browser/aw_quota_permission_context.h" 14 #include "android_webview/browser/aw_quota_permission_context.h"
15 #include "android_webview/browser/aw_web_preferences_populater.h" 15 #include "android_webview/browser/aw_web_preferences_populater.h"
16 #include "android_webview/browser/jni_dependency_factory.h" 16 #include "android_webview/browser/jni_dependency_factory.h"
17 #include "android_webview/browser/net/aw_url_request_context_getter.h" 17 #include "android_webview/browser/net/aw_url_request_context_getter.h"
18 #include "android_webview/browser/net_disk_cache_remover.h" 18 #include "android_webview/browser/net_disk_cache_remover.h"
19 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" 19 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h"
20 #include "android_webview/common/render_view_messages.h" 20 #include "android_webview/common/render_view_messages.h"
21 #include "android_webview/common/url_constants.h" 21 #include "android_webview/common/url_constants.h"
22 #include "base/android/locale_utils.h" 22 #include "base/android/locale_utils.h"
23 #include "base/base_paths_android.h" 23 #include "base/base_paths_android.h"
24 #include "base/path_service.h" 24 #include "base/path_service.h"
25 #include "components/cdm/browser/cdm_message_filter_android.h" 25 #include "components/cdm/browser/cdm_message_filter_android.h"
26 #include "content/public/browser/access_token_store.h" 26 #include "content/public/browser/access_token_store.h"
27 #include "content/public/browser/browser_message_filter.h" 27 #include "content/public/browser/browser_message_filter.h"
28 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/child_process_security_policy.h" 29 #include "content/public/browser/child_process_security_policy.h"
30 #include "content/public/browser/permission_type.h"
30 #include "content/public/browser/render_process_host.h" 31 #include "content/public/browser/render_process_host.h"
31 #include "content/public/browser/render_view_host.h" 32 #include "content/public/browser/render_view_host.h"
32 #include "content/public/browser/web_contents.h" 33 #include "content/public/browser/web_contents.h"
33 #include "content/public/common/url_constants.h" 34 #include "content/public/common/url_constants.h"
34 #include "content/public/common/web_preferences.h" 35 #include "content/public/common/web_preferences.h"
35 #include "net/android/network_library.h" 36 #include "net/android/network_library.h"
36 #include "net/ssl/ssl_cert_request_info.h" 37 #include "net/ssl/ssl_cert_request_info.h"
37 #include "net/ssl/ssl_info.h" 38 #include "net/ssl/ssl_info.h"
38 #include "ui/base/resource/resource_bundle.h" 39 #include "ui/base/resource/resource_bundle.h"
39 #include "ui/resources/grit/ui_resources.h" 40 #include "ui/resources/grit/ui_resources.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 134 }
134 virtual void SaveAccessToken(const GURL& server_url, 135 virtual void SaveAccessToken(const GURL& server_url,
135 const base::string16& access_token) override { } 136 const base::string16& access_token) override { }
136 137
137 private: 138 private:
138 virtual ~AwAccessTokenStore() { } 139 virtual ~AwAccessTokenStore() { }
139 140
140 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); 141 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore);
141 }; 142 };
142 143
143 void CancelProtectedMediaIdentifierPermissionRequests(
144 int render_process_id,
145 int render_view_id,
146 const GURL& origin) {
147 AwBrowserPermissionRequestDelegate* delegate =
148 AwBrowserPermissionRequestDelegate::FromID(render_process_id,
149 render_view_id);
150 if (delegate)
151 delegate->CancelProtectedMediaIdentifierPermissionRequests(origin);
152 }
153
154 } // namespace 144 } // namespace
155 145
156 std::string AwContentBrowserClient::GetAcceptLangsImpl() { 146 std::string AwContentBrowserClient::GetAcceptLangsImpl() {
157 // Start with the currnet locale. 147 // Start with the currnet locale.
158 std::string langs = base::android::GetDefaultLocale(); 148 std::string langs = base::android::GetDefaultLocale();
159 149
160 // If we're not en-US, add in en-US which will be 150 // If we're not en-US, add in en-US which will be
161 // used with a lower q-value. 151 // used with a lower q-value.
162 if (base::StringToLowerASCII(langs) != "en-us") { 152 if (base::StringToLowerASCII(langs) != "en-us") {
163 langs += ",en-US"; 153 langs += ",en-US";
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 } 385 }
396 386
397 void AwContentBrowserClient::ShowDesktopNotification( 387 void AwContentBrowserClient::ShowDesktopNotification(
398 const content::ShowDesktopNotificationHostMsgParams& params, 388 const content::ShowDesktopNotificationHostMsgParams& params,
399 content::RenderFrameHost* render_frame_host, 389 content::RenderFrameHost* render_frame_host,
400 scoped_ptr<content::DesktopNotificationDelegate> delegate, 390 scoped_ptr<content::DesktopNotificationDelegate> delegate,
401 base::Closure* cancel_callback) { 391 base::Closure* cancel_callback) {
402 NOTREACHED() << "Android WebView does not support desktop notifications."; 392 NOTREACHED() << "Android WebView does not support desktop notifications.";
403 } 393 }
404 394
405 void AwContentBrowserClient::RequestGeolocationPermission( 395 void AwContentBrowserClient::RequestPermission(
396 content::PermissionType permission,
406 content::WebContents* web_contents, 397 content::WebContents* web_contents,
407 int bridge_id, 398 int bridge_id,
408 const GURL& requesting_frame, 399 const GURL& requesting_frame,
409 bool user_gesture, 400 bool user_gesture,
410 const base::Callback<void(bool)>& result_callback) { 401 const base::Callback<void(bool)>& result_callback) {
411 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); 402 int render_process_id = web_contents->GetRenderProcessHost()->GetID();
412 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); 403 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
404 GURL origin = requesting_frame.GetOrigin();
405 AwBrowserPermissionRequestDelegate* delegate =
406 AwBrowserPermissionRequestDelegate::FromID(render_process_id,
407 render_view_id);
408 switch (permission) {
409 case content::PERMISSION_GEOLOCATION:
410 if (!delegate) {
411 DVLOG(0) << "Dropping GeolocationPermission request";
412 result_callback.Run(false);
413 return;
414 }
415 delegate->RequestGeolocationPermission(origin, result_callback);
416 break;
417 case content::PERMISSION_PROTECTED_MEDIA:
418 if (!delegate) {
419 DVLOG(0) << "Dropping ProtectedMediaIdentifierPermission request";
420 result_callback.Run(false);
421 return;
422 }
423 delegate->RequestProtectedMediaIdentifierPermission(origin,
424 result_callback);
425 break;
426 case content::PERMISSION_MIDI_SYSEX:
427 case content::PERMISSION_NOTIFICATIONS:
428 case content::PERMISSION_PUSH_MESSAGING:
429 NOTIMPLEMENTED() << "RequestPermission not implemented for "
430 << permission;
431 break;
432 case content::PERMISSION_NUM:
433 NOTREACHED() << "Invalid RequestPermission for " << permission;
434 break;
435 }
436 }
437
438 void AwContentBrowserClient::CancelPermissionRequest(
439 content::PermissionType permission,
440 content::WebContents* web_contents,
441 int bridge_id,
442 const GURL& origin) {
443 int render_process_id = web_contents->GetRenderProcessHost()->GetID();
444 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
413 AwBrowserPermissionRequestDelegate* delegate = 445 AwBrowserPermissionRequestDelegate* delegate =
414 AwBrowserPermissionRequestDelegate::FromID(render_process_id, 446 AwBrowserPermissionRequestDelegate::FromID(render_process_id,
415 render_view_id); 447 render_view_id);
416 if (delegate == NULL) { 448 if (!delegate)
417 DVLOG(0) << "Dropping GeolocationPermission request";
418 result_callback.Run(false);
419 return; 449 return;
450 switch (permission) {
451 case content::PERMISSION_GEOLOCATION:
452 delegate->CancelGeolocationPermissionRequests(origin);
453 break;
454 case content::PERMISSION_PROTECTED_MEDIA:
455 delegate->CancelProtectedMediaIdentifierPermissionRequests(origin);
456 break;
457 case content::PERMISSION_MIDI_SYSEX:
458 case content::PERMISSION_NOTIFICATIONS:
459 case content::PERMISSION_PUSH_MESSAGING:
460 NOTIMPLEMENTED() << "CancelPermission not implemented for " << permission;
461 break;
462 case content::PERMISSION_NUM:
463 NOTREACHED() << "Invalid CancelPermission for " << permission;
464 break;
420 } 465 }
421
422 GURL origin = requesting_frame.GetOrigin();
423 delegate->RequestGeolocationPermission(origin, result_callback);
424 }
425
426 void AwContentBrowserClient::CancelGeolocationPermissionRequest(
427 content::WebContents* web_contents,
428 int bridge_id,
429 const GURL& requesting_frame) {
430 int render_process_id = web_contents->GetRenderProcessHost()->GetID();
431 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
432 AwBrowserPermissionRequestDelegate* delegate =
433 AwBrowserPermissionRequestDelegate::FromID(render_process_id,
434 render_view_id);
435 if (delegate)
436 delegate->CancelGeolocationPermissionRequests(requesting_frame);
437 }
438
439 void AwContentBrowserClient::RequestMidiSysExPermission(
440 content::WebContents* web_contents,
441 int bridge_id,
442 const GURL& requesting_frame,
443 bool user_gesture,
444 base::Callback<void(bool)> result_callback,
445 base::Closure* cancel_callback) {
446 // TODO(toyoshim): Android WebView is not supported yet.
447 // See http://crbug.com/339767.
448 result_callback.Run(false);
449 }
450
451 void AwContentBrowserClient::RequestProtectedMediaIdentifierPermission(
452 content::WebContents* web_contents,
453 const GURL& origin,
454 base::Callback<void(bool)> result_callback,
455 base::Closure* cancel_callback) {
456 int render_process_id = web_contents->GetRenderProcessHost()->GetID();
457 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
458 AwBrowserPermissionRequestDelegate* delegate =
459 AwBrowserPermissionRequestDelegate::FromID(render_process_id,
460 render_view_id);
461 if (delegate == NULL) {
462 DVLOG(0) << "Dropping ProtectedMediaIdentifierPermission request";
463 result_callback.Run(false);
464 return;
465 }
466
467 if (cancel_callback) {
468 *cancel_callback = base::Bind(
469 CancelProtectedMediaIdentifierPermissionRequests,
470 render_process_id, render_view_id, origin);
471 }
472 delegate->RequestProtectedMediaIdentifierPermission(origin, result_callback);
473 } 466 }
474 467
475 bool AwContentBrowserClient::CanCreateWindow( 468 bool AwContentBrowserClient::CanCreateWindow(
476 const GURL& opener_url, 469 const GURL& opener_url,
477 const GURL& opener_top_level_frame_url, 470 const GURL& opener_top_level_frame_url,
478 const GURL& source_origin, 471 const GURL& source_origin,
479 WindowContainerType container_type, 472 WindowContainerType container_type,
480 const GURL& target_url, 473 const GURL& target_url,
481 const content::Referrer& referrer, 474 const content::Referrer& referrer,
482 WindowOpenDisposition disposition, 475 WindowOpenDisposition disposition,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents); 568 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents);
576 } 569 }
577 #endif 570 #endif
578 571
579 content::DevToolsManagerDelegate* 572 content::DevToolsManagerDelegate*
580 AwContentBrowserClient::GetDevToolsManagerDelegate() { 573 AwContentBrowserClient::GetDevToolsManagerDelegate() {
581 return new AwDevToolsManagerDelegate(); 574 return new AwDevToolsManagerDelegate();
582 } 575 }
583 576
584 } // namespace android_webview 577 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698