| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 132 } |
| 133 virtual void SaveAccessToken(const GURL& server_url, | 133 virtual void SaveAccessToken(const GURL& server_url, |
| 134 const base::string16& access_token) OVERRIDE { } | 134 const base::string16& access_token) OVERRIDE { } |
| 135 | 135 |
| 136 private: | 136 private: |
| 137 virtual ~AwAccessTokenStore() { } | 137 virtual ~AwAccessTokenStore() { } |
| 138 | 138 |
| 139 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); | 139 DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 void CancelProtectedMediaIdentifierPermissionRequests( | |
| 143 int render_process_id, | |
| 144 int render_view_id, | |
| 145 const GURL& origin) { | |
| 146 AwBrowserPermissionRequestDelegate* delegate = | |
| 147 AwBrowserPermissionRequestDelegate::FromID(render_process_id, | |
| 148 render_view_id); | |
| 149 if (delegate) | |
| 150 delegate->CancelProtectedMediaIdentifierPermissionRequests(origin); | |
| 151 } | |
| 152 | |
| 153 } // namespace | 142 } // namespace |
| 154 | 143 |
| 155 std::string AwContentBrowserClient::GetAcceptLangsImpl() { | 144 std::string AwContentBrowserClient::GetAcceptLangsImpl() { |
| 156 // Start with the currnet locale. | 145 // Start with the currnet locale. |
| 157 std::string langs = l10n_util::GetDefaultLocale(); | 146 std::string langs = l10n_util::GetDefaultLocale(); |
| 158 | 147 |
| 159 // 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 |
| 160 // used with a lower q-value. | 149 // used with a lower q-value. |
| 161 if (base::StringToLowerASCII(langs) != "en-us") { | 150 if (base::StringToLowerASCII(langs) != "en-us") { |
| 162 langs += ",en-US"; | 151 langs += ",en-US"; |
| (...skipping 232 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; |
| 410 case content::PERMISSION_NOTIFICATIONS: |
| 411 LOG(WARNING) << "Permission Request not implemented for " |
| 412 << permission; |
| 413 break; |
| 414 case content::PERMISSION_GEOLOCATION: |
| 415 if (delegate == NULL) { |
| 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; |
| 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) |
| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 | 560 |
| 571 #if defined(VIDEO_HOLE) | 561 #if defined(VIDEO_HOLE) |
| 572 content::ExternalVideoSurfaceContainer* | 562 content::ExternalVideoSurfaceContainer* |
| 573 AwContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer( | 563 AwContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer( |
| 574 content::WebContents* web_contents) { | 564 content::WebContents* web_contents) { |
| 575 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents); | 565 return native_factory_->CreateExternalVideoSurfaceContainer(web_contents); |
| 576 } | 566 } |
| 577 #endif | 567 #endif |
| 578 | 568 |
| 579 } // namespace android_webview | 569 } // namespace android_webview |
| OLD | NEW |