OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/metrics/user_metrics_action.h" | 10 #include "base/metrics/user_metrics_action.h" |
11 #include "content/browser/child_process_security_policy_impl.h" | 11 #include "content/browser/child_process_security_policy_impl.h" |
12 #include "content/browser/frame_host/cross_process_frame_connector.h" | 12 #include "content/browser/frame_host/cross_process_frame_connector.h" |
13 #include "content/browser/frame_host/cross_site_transferring_request.h" | 13 #include "content/browser/frame_host/cross_site_transferring_request.h" |
14 #include "content/browser/frame_host/frame_tree.h" | 14 #include "content/browser/frame_host/frame_tree.h" |
15 #include "content/browser/frame_host/frame_tree_node.h" | 15 #include "content/browser/frame_host/frame_tree_node.h" |
16 #include "content/browser/frame_host/navigator.h" | 16 #include "content/browser/frame_host/navigator.h" |
17 #include "content/browser/frame_host/render_frame_host_delegate.h" | 17 #include "content/browser/frame_host/render_frame_host_delegate.h" |
18 #include "content/browser/frame_host/render_frame_proxy_host.h" | 18 #include "content/browser/frame_host/render_frame_proxy_host.h" |
19 #include "content/browser/renderer_host/input/input_router.h" | 19 #include "content/browser/renderer_host/input/input_router.h" |
20 #include "content/browser/renderer_host/input/timeout_monitor.h" | 20 #include "content/browser/renderer_host/input/timeout_monitor.h" |
21 #include "content/browser/renderer_host/render_process_host_impl.h" | 21 #include "content/browser/renderer_host/render_process_host_impl.h" |
22 #include "content/browser/renderer_host/render_view_host_impl.h" | 22 #include "content/browser/renderer_host/render_view_host_impl.h" |
23 #include "content/browser/renderer_host/render_widget_host_impl.h" | 23 #include "content/browser/renderer_host/render_widget_host_impl.h" |
24 #include "content/browser/transition_request_manager.h" | 24 #include "content/browser/transition_request_manager.h" |
25 #include "content/common/desktop_notification_messages.h" | 25 #include "content/common/desktop_notification_messages.h" |
26 #include "content/common/frame_messages.h" | 26 #include "content/common/frame_messages.h" |
27 #include "content/common/input_messages.h" | 27 #include "content/common/input_messages.h" |
28 #include "content/common/inter_process_time_ticks_converter.h" | 28 #include "content/common/inter_process_time_ticks_converter.h" |
| 29 #include "content/common/platform_notification_messages.h" |
29 #include "content/common/render_frame_setup.mojom.h" | 30 #include "content/common/render_frame_setup.mojom.h" |
30 #include "content/common/swapped_out_messages.h" | 31 #include "content/common/swapped_out_messages.h" |
| 32 #include "content/public/browser/browser_context.h" |
31 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
32 #include "content/public/browser/content_browser_client.h" | 34 #include "content/public/browser/content_browser_client.h" |
33 #include "content/public/browser/desktop_notification_delegate.h" | 35 #include "content/public/browser/desktop_notification_delegate.h" |
34 #include "content/public/browser/render_process_host.h" | 36 #include "content/public/browser/render_process_host.h" |
35 #include "content/public/browser/render_widget_host_view.h" | 37 #include "content/public/browser/render_widget_host_view.h" |
36 #include "content/public/browser/user_metrics.h" | 38 #include "content/public/browser/user_metrics.h" |
37 #include "content/public/common/content_constants.h" | 39 #include "content/public/common/content_constants.h" |
38 #include "content/public/common/url_constants.h" | 40 #include "content/public/common/url_constants.h" |
39 #include "content/public/common/url_utils.h" | 41 #include "content/public/common/url_utils.h" |
40 #include "url/gurl.h" | 42 #include "url/gurl.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 OnJavaScriptExecuteResponse) | 330 OnJavaScriptExecuteResponse) |
329 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage, | 331 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage, |
330 OnRunJavaScriptMessage) | 332 OnRunJavaScriptMessage) |
331 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm, | 333 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm, |
332 OnRunBeforeUnloadConfirm) | 334 OnRunBeforeUnloadConfirm) |
333 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument, | 335 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument, |
334 OnDidAccessInitialDocument) | 336 OnDidAccessInitialDocument) |
335 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisownOpener, OnDidDisownOpener) | 337 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisownOpener, OnDidDisownOpener) |
336 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) | 338 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) |
337 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) | 339 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) |
| 340 IPC_MESSAGE_HANDLER(PlatformNotificationHostMsg_RequestPermission, |
| 341 OnRequestPlatformNotificationPermission) |
338 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, | 342 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, |
339 OnRequestDesktopNotificationPermission) | 343 OnRequestDesktopNotificationPermission) |
340 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, | 344 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, |
341 OnShowDesktopNotification) | 345 OnShowDesktopNotification) |
342 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, | 346 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, |
343 OnCancelDesktopNotification) | 347 OnCancelDesktopNotification) |
344 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, | 348 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, |
345 OnTextSurroundingSelectionResponse) | 349 OnTextSurroundingSelectionResponse) |
346 IPC_END_MESSAGE_MAP() | 350 IPC_END_MESSAGE_MAP() |
347 | 351 |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 const base::string16& message, | 697 const base::string16& message, |
694 bool is_reload, | 698 bool is_reload, |
695 IPC::Message* reply_msg) { | 699 IPC::Message* reply_msg) { |
696 // While a JS before unload dialog is showing, tabs in the same process | 700 // While a JS before unload dialog is showing, tabs in the same process |
697 // shouldn't process input events. | 701 // shouldn't process input events. |
698 GetProcess()->SetIgnoreInputEvents(true); | 702 GetProcess()->SetIgnoreInputEvents(true); |
699 render_view_host_->StopHangMonitorTimeout(); | 703 render_view_host_->StopHangMonitorTimeout(); |
700 delegate_->RunBeforeUnloadConfirm(this, message, is_reload, reply_msg); | 704 delegate_->RunBeforeUnloadConfirm(this, message, is_reload, reply_msg); |
701 } | 705 } |
702 | 706 |
| 707 void RenderFrameHostImpl::OnRequestPlatformNotificationPermission( |
| 708 const GURL& origin, int request_id) { |
| 709 base::Closure done_callback = base::Bind( |
| 710 &RenderFrameHostImpl::PlatformNotificationPermissionRequestDone, |
| 711 weak_ptr_factory_.GetWeakPtr(), origin, request_id); |
| 712 GetContentClient()->browser()->RequestDesktopNotificationPermission( |
| 713 origin, this, done_callback); |
| 714 } |
| 715 |
| 716 // TODO(peter): Remove this call and the associated IPC messages when Blink |
| 717 // has switched to the new Web Notification permission code-path. |
703 void RenderFrameHostImpl::OnRequestDesktopNotificationPermission( | 718 void RenderFrameHostImpl::OnRequestDesktopNotificationPermission( |
704 const GURL& source_origin, int callback_context) { | 719 const GURL& source_origin, int callback_context) { |
705 base::Closure done_callback = base::Bind( | 720 base::Closure done_callback = base::Bind( |
706 &RenderFrameHostImpl::DesktopNotificationPermissionRequestDone, | 721 &RenderFrameHostImpl::DesktopNotificationPermissionRequestDone, |
707 weak_ptr_factory_.GetWeakPtr(), callback_context); | 722 weak_ptr_factory_.GetWeakPtr(), callback_context); |
708 GetContentClient()->browser()->RequestDesktopNotificationPermission( | 723 GetContentClient()->browser()->RequestDesktopNotificationPermission( |
709 source_origin, this, done_callback); | 724 source_origin, this, done_callback); |
710 } | 725 } |
711 | 726 |
712 void RenderFrameHostImpl::OnShowDesktopNotification( | 727 void RenderFrameHostImpl::OnShowDesktopNotification( |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 render_view_host_->delegate_->RendererUnresponsive( | 937 render_view_host_->delegate_->RendererUnresponsive( |
923 render_view_host_, | 938 render_view_host_, |
924 render_view_host_->is_waiting_for_beforeunload_ack(), | 939 render_view_host_->is_waiting_for_beforeunload_ack(), |
925 render_view_host_->IsWaitingForUnloadACK()); | 940 render_view_host_->IsWaitingForUnloadACK()); |
926 } | 941 } |
927 | 942 |
928 void RenderFrameHostImpl::NotificationClosed(int notification_id) { | 943 void RenderFrameHostImpl::NotificationClosed(int notification_id) { |
929 cancel_notification_callbacks_.erase(notification_id); | 944 cancel_notification_callbacks_.erase(notification_id); |
930 } | 945 } |
931 | 946 |
| 947 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( |
| 948 const GURL& origin, int request_id) { |
| 949 blink::WebNotificationPermission permission = |
| 950 blink::WebNotificationPermissionAllowed; |
| 951 #if defined(ENABLE_NOTIFICATIONS) |
| 952 permission = static_cast<blink::WebNotificationPermission>( |
| 953 GetContentClient()->browser()->CheckDesktopNotificationPermission( |
| 954 origin, |
| 955 GetProcess()->GetBrowserContext()->GetResourceContext(), |
| 956 GetProcess()->GetID())); |
| 957 #endif |
| 958 |
| 959 Send(new PlatformNotificationMsg_PermissionRequestComplete( |
| 960 routing_id_, request_id, permission)); |
| 961 } |
| 962 |
| 963 // TODO(peter): Remove this method when Blink uses the new code-path. |
932 void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone( | 964 void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone( |
933 int callback_context) { | 965 int callback_context) { |
934 Send(new DesktopNotificationMsg_PermissionRequestDone( | 966 Send(new DesktopNotificationMsg_PermissionRequestDone( |
935 routing_id_, callback_context)); | 967 routing_id_, callback_context)); |
936 } | 968 } |
937 | 969 |
938 void RenderFrameHostImpl::SetHasPendingTransitionRequest( | 970 void RenderFrameHostImpl::SetHasPendingTransitionRequest( |
939 bool has_pending_request) { | 971 bool has_pending_request) { |
940 BrowserThread::PostTask( | 972 BrowserThread::PostTask( |
941 BrowserThread::IO, | 973 BrowserThread::IO, |
942 FROM_HERE, | 974 FROM_HERE, |
943 base::Bind( | 975 base::Bind( |
944 &TransitionRequestManager::SetHasPendingTransitionRequest, | 976 &TransitionRequestManager::SetHasPendingTransitionRequest, |
945 base::Unretained(TransitionRequestManager::GetInstance()), | 977 base::Unretained(TransitionRequestManager::GetInstance()), |
946 GetProcess()->GetID(), | 978 GetProcess()->GetID(), |
947 routing_id_, | 979 routing_id_, |
948 has_pending_request)); | 980 has_pending_request)); |
949 } | 981 } |
950 | 982 |
951 } // namespace content | 983 } // namespace content |
OLD | NEW |