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

Side by Side Diff: android_webview/browser/aw_content_browser_client.cc

Issue 1011953003: Refactor Permissions related method out of ContentBrowserClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission_type_enum_class
Patch Set: fix cros Created 5 years, 8 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"
10 #include "android_webview/browser/aw_contents_client_bridge_base.h" 9 #include "android_webview/browser/aw_contents_client_bridge_base.h"
11 #include "android_webview/browser/aw_contents_io_thread_client.h" 10 #include "android_webview/browser/aw_contents_io_thread_client.h"
12 #include "android_webview/browser/aw_cookie_access_policy.h" 11 #include "android_webview/browser/aw_cookie_access_policy.h"
13 #include "android_webview/browser/aw_dev_tools_manager_delegate.h" 12 #include "android_webview/browser/aw_dev_tools_manager_delegate.h"
14 #include "android_webview/browser/aw_printing_message_filter.h" 13 #include "android_webview/browser/aw_printing_message_filter.h"
15 #include "android_webview/browser/aw_quota_permission_context.h" 14 #include "android_webview/browser/aw_quota_permission_context.h"
16 #include "android_webview/browser/aw_web_preferences_populater.h" 15 #include "android_webview/browser/aw_web_preferences_populater.h"
17 #include "android_webview/browser/jni_dependency_factory.h" 16 #include "android_webview/browser/jni_dependency_factory.h"
18 #include "android_webview/browser/net/aw_url_request_context_getter.h" 17 #include "android_webview/browser/net/aw_url_request_context_getter.h"
19 #include "android_webview/browser/net_disk_cache_remover.h" 18 #include "android_webview/browser/net_disk_cache_remover.h"
20 #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"
21 #include "android_webview/common/render_view_messages.h" 20 #include "android_webview/common/render_view_messages.h"
22 #include "android_webview/common/url_constants.h" 21 #include "android_webview/common/url_constants.h"
23 #include "base/android/locale_utils.h" 22 #include "base/android/locale_utils.h"
24 #include "base/base_paths_android.h" 23 #include "base/base_paths_android.h"
25 #include "base/path_service.h" 24 #include "base/path_service.h"
26 #include "components/cdm/browser/cdm_message_filter_android.h" 25 #include "components/cdm/browser/cdm_message_filter_android.h"
27 #include "content/public/browser/access_token_store.h" 26 #include "content/public/browser/access_token_store.h"
28 #include "content/public/browser/browser_message_filter.h" 27 #include "content/public/browser/browser_message_filter.h"
29 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/child_process_security_policy.h" 29 #include "content/public/browser/child_process_security_policy.h"
31 #include "content/public/browser/client_certificate_delegate.h" 30 #include "content/public/browser/client_certificate_delegate.h"
32 #include "content/public/browser/permission_type.h"
33 #include "content/public/browser/render_frame_host.h" 31 #include "content/public/browser/render_frame_host.h"
34 #include "content/public/browser/render_process_host.h" 32 #include "content/public/browser/render_process_host.h"
35 #include "content/public/browser/render_view_host.h" 33 #include "content/public/browser/render_view_host.h"
36 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
37 #include "content/public/common/url_constants.h" 35 #include "content/public/common/url_constants.h"
38 #include "content/public/common/web_preferences.h" 36 #include "content/public/common/web_preferences.h"
39 #include "net/android/network_library.h" 37 #include "net/android/network_library.h"
40 #include "net/ssl/ssl_cert_request_info.h" 38 #include "net/ssl/ssl_cert_request_info.h"
41 #include "net/ssl/ssl_info.h" 39 #include "net/ssl/ssl_info.h"
42 #include "ui/base/resource/resource_bundle.h" 40 #include "ui/base/resource/resource_bundle.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 132 }
135 void SaveAccessToken(const GURL& server_url, 133 void SaveAccessToken(const GURL& server_url,
136 const base::string16& access_token) override {} 134 const base::string16& access_token) override {}
137 135
138 private: 136 private:
139 ~AwAccessTokenStore() override {} 137 ~AwAccessTokenStore() override {}
140 138
141 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); 139 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore);
142 }; 140 };
143 141
144 void CallbackPermisisonStatusWrapper(
145 const base::Callback<void(content::PermissionStatus)>& callback,
146 bool allowed) {
147 callback.Run(allowed ? content::PERMISSION_STATUS_GRANTED
148 : content::PERMISSION_STATUS_DENIED);
149 }
150
151 } // anonymous namespace 142 } // anonymous namespace
152 143
153 std::string AwContentBrowserClient::GetAcceptLangsImpl() { 144 std::string AwContentBrowserClient::GetAcceptLangsImpl() {
154 // Start with the currnet locale. 145 // Start with the currnet locale.
155 std::string langs = base::android::GetDefaultLocale(); 146 std::string langs = base::android::GetDefaultLocale();
156 147
157 // If we're not en-US, add in en-US which will be 148 // If we're not en-US, add in en-US which will be
158 // used with a lower q-value. 149 // used with a lower q-value.
159 if (base::StringToLowerASCII(langs) != "en-us") { 150 if (base::StringToLowerASCII(langs) != "en-us") {
160 langs += ",en-US"; 151 langs += ",en-US";
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 void AwContentBrowserClient::SelectClientCertificate( 363 void AwContentBrowserClient::SelectClientCertificate(
373 content::WebContents* web_contents, 364 content::WebContents* web_contents,
374 net::SSLCertRequestInfo* cert_request_info, 365 net::SSLCertRequestInfo* cert_request_info,
375 scoped_ptr<content::ClientCertificateDelegate> delegate) { 366 scoped_ptr<content::ClientCertificateDelegate> delegate) {
376 AwContentsClientBridgeBase* client = 367 AwContentsClientBridgeBase* client =
377 AwContentsClientBridgeBase::FromWebContents(web_contents); 368 AwContentsClientBridgeBase::FromWebContents(web_contents);
378 if (client) 369 if (client)
379 client->SelectClientCertificate(cert_request_info, delegate.Pass()); 370 client->SelectClientCertificate(cert_request_info, delegate.Pass());
380 } 371 }
381 372
382 void AwContentBrowserClient::RequestPermission(
383 content::PermissionType permission,
384 content::WebContents* web_contents,
385 int bridge_id,
386 const GURL& requesting_frame,
387 bool user_gesture,
388 const base::Callback<void(content::PermissionStatus)>& callback) {
389 int render_process_id = web_contents->GetRenderProcessHost()->GetID();
390 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
391 GURL origin = requesting_frame.GetOrigin();
392 AwBrowserPermissionRequestDelegate* delegate =
393 AwBrowserPermissionRequestDelegate::FromID(render_process_id,
394 render_view_id);
395 switch (permission) {
396 case content::PermissionType::GEOLOCATION:
397 if (!delegate) {
398 DVLOG(0) << "Dropping GeolocationPermission request";
399 callback.Run(content::PERMISSION_STATUS_DENIED);
400 return;
401 }
402 delegate->RequestGeolocationPermission(
403 origin, base::Bind(&CallbackPermisisonStatusWrapper, callback));
404 break;
405 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
406 if (!delegate) {
407 DVLOG(0) << "Dropping ProtectedMediaIdentifierPermission request";
408 callback.Run(content::PERMISSION_STATUS_DENIED);
409 return;
410 }
411 delegate->RequestProtectedMediaIdentifierPermission(
412 origin, base::Bind(&CallbackPermisisonStatusWrapper, callback));
413 break;
414 case content::PermissionType::MIDI_SYSEX:
415 case content::PermissionType::NOTIFICATIONS:
416 case content::PermissionType::PUSH_MESSAGING:
417 NOTIMPLEMENTED() << "RequestPermission not implemented for "
418 << static_cast<int>(permission);
419 break;
420 case content::PermissionType::NUM:
421 NOTREACHED() << "Invalid RequestPermission for "
422 << static_cast<int>(permission);
423 break;
424 }
425 }
426
427 void AwContentBrowserClient::CancelPermissionRequest(
428 content::PermissionType permission,
429 content::WebContents* web_contents,
430 int bridge_id,
431 const GURL& origin) {
432 int render_process_id = web_contents->GetRenderProcessHost()->GetID();
433 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
434 AwBrowserPermissionRequestDelegate* delegate =
435 AwBrowserPermissionRequestDelegate::FromID(render_process_id,
436 render_view_id);
437 if (!delegate)
438 return;
439 switch (permission) {
440 case content::PermissionType::GEOLOCATION:
441 delegate->CancelGeolocationPermissionRequests(origin);
442 break;
443 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
444 delegate->CancelProtectedMediaIdentifierPermissionRequests(origin);
445 break;
446 case content::PermissionType::MIDI_SYSEX:
447 case content::PermissionType::NOTIFICATIONS:
448 case content::PermissionType::PUSH_MESSAGING:
449 NOTIMPLEMENTED() << "CancelPermission not implemented for "
450 << static_cast<int>(permission);
451 break;
452 case content::PermissionType::NUM:
453 NOTREACHED() << "Invalid CancelPermission for "
454 << static_cast<int>(permission);
455 break;
456 }
457 }
458
459 bool AwContentBrowserClient::CanCreateWindow( 373 bool AwContentBrowserClient::CanCreateWindow(
460 const GURL& opener_url, 374 const GURL& opener_url,
461 const GURL& opener_top_level_frame_url, 375 const GURL& opener_top_level_frame_url,
462 const GURL& source_origin, 376 const GURL& source_origin,
463 WindowContainerType container_type, 377 WindowContainerType container_type,
464 const GURL& target_url, 378 const GURL& target_url,
465 const content::Referrer& referrer, 379 const content::Referrer& referrer,
466 WindowOpenDisposition disposition, 380 WindowOpenDisposition disposition,
467 const blink::WebWindowFeatures& features, 381 const blink::WebWindowFeatures& features,
468 bool user_gesture, 382 bool user_gesture,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents); 472 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents);
559 } 473 }
560 #endif 474 #endif
561 475
562 content::DevToolsManagerDelegate* 476 content::DevToolsManagerDelegate*
563 AwContentBrowserClient::GetDevToolsManagerDelegate() { 477 AwContentBrowserClient::GetDevToolsManagerDelegate() {
564 return new AwDevToolsManagerDelegate(); 478 return new AwDevToolsManagerDelegate();
565 } 479 }
566 480
567 } // namespace android_webview 481 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/aw_content_browser_client.h ('k') | android_webview/browser/aw_permission_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698