Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 } | 133 } |
| 134 virtual void SaveAccessToken(const GURL& server_url, | 134 virtual void SaveAccessToken(const GURL& server_url, |
| 135 const base::string16& access_token) override { } | 135 const base::string16& access_token) override { } |
| 136 | 136 |
| 137 private: | 137 private: |
| 138 virtual ~AwAccessTokenStore() { } | 138 virtual ~AwAccessTokenStore() { } |
| 139 | 139 |
| 140 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); | 140 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); |
| 141 }; | 141 }; |
| 142 | 142 |
| 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 | 143 } // namespace |
| 155 | 144 |
| 156 std::string AwContentBrowserClient::GetAcceptLangsImpl() { | 145 std::string AwContentBrowserClient::GetAcceptLangsImpl() { |
| 157 // Start with the currnet locale. | 146 // Start with the currnet locale. |
| 158 std::string langs = l10n_util::GetDefaultLocale(); | 147 std::string langs = l10n_util::GetDefaultLocale(); |
| 159 | 148 |
| 160 // If we're not en-US, add in en-US which will be | 149 // If we're not en-US, add in en-US which will be |
| 161 // used with a lower q-value. | 150 // used with a lower q-value. |
| 162 if (base::StringToLowerASCII(langs) != "en-us") { | 151 if (base::StringToLowerASCII(langs) != "en-us") { |
| 163 langs += ",en-US"; | 152 langs += ",en-US"; |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 } | 384 } |
| 396 | 385 |
| 397 void AwContentBrowserClient::ShowDesktopNotification( | 386 void AwContentBrowserClient::ShowDesktopNotification( |
| 398 const content::ShowDesktopNotificationHostMsgParams& params, | 387 const content::ShowDesktopNotificationHostMsgParams& params, |
| 399 content::RenderFrameHost* render_frame_host, | 388 content::RenderFrameHost* render_frame_host, |
| 400 scoped_ptr<content::DesktopNotificationDelegate> delegate, | 389 scoped_ptr<content::DesktopNotificationDelegate> delegate, |
| 401 base::Closure* cancel_callback) { | 390 base::Closure* cancel_callback) { |
| 402 NOTREACHED() << "Android WebView does not support desktop notifications."; | 391 NOTREACHED() << "Android WebView does not support desktop notifications."; |
| 403 } | 392 } |
| 404 | 393 |
| 405 void AwContentBrowserClient::RequestGeolocationPermission( | 394 void AwContentBrowserClient::RequestPermission( |
| 395 content::PermissionType permission, | |
| 406 content::WebContents* web_contents, | 396 content::WebContents* web_contents, |
| 407 int bridge_id, | 397 int bridge_id, |
| 408 const GURL& requesting_frame, | 398 const GURL& requesting_frame, |
| 409 bool user_gesture, | 399 bool user_gesture, |
| 410 const base::Callback<void(bool)>& result_callback) { | 400 const base::Callback<void(bool)>& result_callback) { |
| 411 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); | 401 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); |
| 412 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); | 402 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
| 403 GURL origin = requesting_frame.GetOrigin(); | |
| 404 AwBrowserPermissionRequestDelegate* delegate = | |
| 405 AwBrowserPermissionRequestDelegate::FromID(render_process_id, | |
| 406 render_view_id); | |
| 407 switch (permission) { | |
| 408 case content::PERMISSION_MIDI_SYSEX: | |
| 409 break; | |
|
Bernhard Bauer
2014/10/20 14:57:23
Do you want to fall through here?
Miguel Garcia
2014/10/21 17:17:11
Acknowledged.
| |
| 410 case content::PERMISSION_NOTIFICATIONS: | |
| 411 LOG(WARNING) << "Permission Request not implemented for " | |
| 412 << permission; | |
|
Bernhard Bauer
2014/10/20 14:57:24
Nit: Align << signs.
Miguel Garcia
2014/10/21 17:17:11
Acknowledged.
| |
| 413 break; | |
|
Peter Beverloo
2014/10/20 17:32:16
Can we just handle these cases in the |default| cl
Miguel Garcia
2014/10/21 17:17:11
Acknowledged.
| |
| 414 case content::PERMISSION_GEOLOCATION: | |
| 415 if (delegate == NULL) { | |
|
Bernhard Bauer
2014/10/20 14:57:24
Nit: Just !delegate
Miguel Garcia
2014/10/21 17:17:11
Done.
| |
| 416 DVLOG(0) << "Dropping GeolocationPermission request"; | |
| 417 result_callback.Run(false); | |
| 418 return; | |
| 419 } | |
| 420 delegate->RequestGeolocationPermission(origin, result_callback); | |
| 421 break; | |
| 422 case content::PERMISSION_PROTECTED_MEDIA: | |
| 423 if (delegate == NULL) { | |
| 424 DVLOG(0) << "Dropping ProtectedMediaIdentifierPermission request"; | |
| 425 result_callback.Run(false); | |
| 426 return; | |
| 427 } | |
| 428 delegate->RequestProtectedMediaIdentifierPermission( | |
| 429 origin, result_callback); | |
| 430 break; | |
| 431 default: | |
| 432 LOG(WARNING) << "Permission not available " << permission; | |
|
Bernhard Bauer
2014/10/20 14:57:23
Is there a difference between "Permission not avai
Peter Beverloo
2014/10/20 17:32:16
nit: break; after this line for consistency.
Peter Beverloo
2014/10/20 17:32:16
+1 to merging them.
Miguel Garcia
2014/10/21 17:17:11
I merged them and explicitly listed all values as
Miguel Garcia
2014/10/21 17:17:11
Acknowledged.
Miguel Garcia
2014/10/21 17:17:11
Acknowledged.
| |
| 433 } | |
| 434 } | |
| 435 | |
| 436 void AwContentBrowserClient::CancelPermissionRequest( | |
| 437 content::PermissionType permission, | |
| 438 content::WebContents* web_contents, | |
| 439 int bridge_id, | |
| 440 const GURL& origin) { | |
| 441 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); | |
| 442 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); | |
| 413 AwBrowserPermissionRequestDelegate* delegate = | 443 AwBrowserPermissionRequestDelegate* delegate = |
| 414 AwBrowserPermissionRequestDelegate::FromID(render_process_id, | 444 AwBrowserPermissionRequestDelegate::FromID(render_process_id, |
| 415 render_view_id); | 445 render_view_id); |
| 416 if (delegate == NULL) { | 446 if (!delegate) |
|
Peter Beverloo
2014/10/20 17:32:16
This check should be done in AwContentBrowserClien
Miguel Garcia
2014/10/21 17:17:11
Actually in RequestPermission there are already ch
| |
| 417 DVLOG(0) << "Dropping GeolocationPermission request"; | |
| 418 result_callback.Run(false); | |
| 419 return; | 447 return; |
| 448 switch (permission) { | |
| 449 case content::PERMISSION_MIDI_SYSEX: | |
| 450 case content::PERMISSION_NOTIFICATIONS: | |
| 451 LOG(WARNING) << "Cancel Permission request not implemented for " | |
| 452 << permission; | |
| 453 break; | |
| 454 case content::PERMISSION_GEOLOCATION: | |
| 455 delegate->CancelGeolocationPermissionRequests(origin); | |
| 456 break; | |
| 457 case content::PERMISSION_PROTECTED_MEDIA: | |
| 458 delegate->CancelProtectedMediaIdentifierPermissionRequests(origin); | |
| 459 break; | |
| 460 default: | |
| 461 LOG(WARNING) << "Permission not available " << permission; | |
| 420 } | 462 } |
| 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 } | 463 } |
| 474 | 464 |
| 475 bool AwContentBrowserClient::CanCreateWindow( | 465 bool AwContentBrowserClient::CanCreateWindow( |
| 476 const GURL& opener_url, | 466 const GURL& opener_url, |
| 477 const GURL& opener_top_level_frame_url, | 467 const GURL& opener_top_level_frame_url, |
| 478 const GURL& source_origin, | 468 const GURL& source_origin, |
| 479 WindowContainerType container_type, | 469 WindowContainerType container_type, |
| 480 const GURL& target_url, | 470 const GURL& target_url, |
| 481 const content::Referrer& referrer, | 471 const content::Referrer& referrer, |
| 482 WindowOpenDisposition disposition, | 472 WindowOpenDisposition disposition, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents); | 565 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents); |
| 576 } | 566 } |
| 577 #endif | 567 #endif |
| 578 | 568 |
| 579 content::DevToolsManagerDelegate* | 569 content::DevToolsManagerDelegate* |
| 580 AwContentBrowserClient::GetDevToolsManagerDelegate() { | 570 AwContentBrowserClient::GetDevToolsManagerDelegate() { |
| 581 return new AwDevToolsManagerDelegate(); | 571 return new AwDevToolsManagerDelegate(); |
| 582 } | 572 } |
| 583 | 573 |
| 584 } // namespace android_webview | 574 } // namespace android_webview |
| OLD | NEW |