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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 381633005: Refactor Web Notification permission requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/common/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/time/time.h" 11 #include "base/time/time.h"
12 #include "content/browser/child_process_security_policy_impl.h" 12 #include "content/browser/child_process_security_policy_impl.h"
13 #include "content/browser/frame_host/cross_process_frame_connector.h" 13 #include "content/browser/frame_host/cross_process_frame_connector.h"
14 #include "content/browser/frame_host/cross_site_transferring_request.h" 14 #include "content/browser/frame_host/cross_site_transferring_request.h"
15 #include "content/browser/frame_host/frame_tree.h" 15 #include "content/browser/frame_host/frame_tree.h"
16 #include "content/browser/frame_host/frame_tree_node.h" 16 #include "content/browser/frame_host/frame_tree_node.h"
17 #include "content/browser/frame_host/navigator.h" 17 #include "content/browser/frame_host/navigator.h"
18 #include "content/browser/frame_host/render_frame_host_delegate.h" 18 #include "content/browser/frame_host/render_frame_host_delegate.h"
19 #include "content/browser/frame_host/render_frame_proxy_host.h" 19 #include "content/browser/frame_host/render_frame_proxy_host.h"
20 #include "content/browser/renderer_host/input/input_router.h" 20 #include "content/browser/renderer_host/input/input_router.h"
21 #include "content/browser/renderer_host/input/timeout_monitor.h" 21 #include "content/browser/renderer_host/input/timeout_monitor.h"
22 #include "content/browser/renderer_host/render_process_host_impl.h" 22 #include "content/browser/renderer_host/render_process_host_impl.h"
23 #include "content/browser/renderer_host/render_view_host_impl.h" 23 #include "content/browser/renderer_host/render_view_host_impl.h"
24 #include "content/browser/renderer_host/render_widget_host_impl.h" 24 #include "content/browser/renderer_host/render_widget_host_impl.h"
25 #include "content/browser/transition_request_manager.h" 25 #include "content/browser/transition_request_manager.h"
26 #include "content/common/desktop_notification_messages.h" 26 #include "content/common/desktop_notification_messages.h"
27 #include "content/common/frame_messages.h" 27 #include "content/common/frame_messages.h"
28 #include "content/common/input_messages.h" 28 #include "content/common/input_messages.h"
29 #include "content/common/inter_process_time_ticks_converter.h" 29 #include "content/common/inter_process_time_ticks_converter.h"
30 #include "content/common/platform_notification_messages.h"
30 #include "content/common/render_frame_setup.mojom.h" 31 #include "content/common/render_frame_setup.mojom.h"
31 #include "content/common/swapped_out_messages.h" 32 #include "content/common/swapped_out_messages.h"
33 #include "content/public/browser/browser_context.h"
32 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
33 #include "content/public/browser/content_browser_client.h" 35 #include "content/public/browser/content_browser_client.h"
34 #include "content/public/browser/desktop_notification_delegate.h" 36 #include "content/public/browser/desktop_notification_delegate.h"
35 #include "content/public/browser/render_process_host.h" 37 #include "content/public/browser/render_process_host.h"
36 #include "content/public/browser/render_widget_host_view.h" 38 #include "content/public/browser/render_widget_host_view.h"
37 #include "content/public/browser/user_metrics.h" 39 #include "content/public/browser/user_metrics.h"
38 #include "content/public/common/content_constants.h" 40 #include "content/public/common/content_constants.h"
39 #include "content/public/common/url_constants.h" 41 #include "content/public/common/url_constants.h"
40 #include "content/public/common/url_utils.h" 42 #include "content/public/common/url_utils.h"
41 #include "url/gurl.h" 43 #include "url/gurl.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 OnJavaScriptExecuteResponse) 331 OnJavaScriptExecuteResponse)
330 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage, 332 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage,
331 OnRunJavaScriptMessage) 333 OnRunJavaScriptMessage)
332 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm, 334 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm,
333 OnRunBeforeUnloadConfirm) 335 OnRunBeforeUnloadConfirm)
334 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument, 336 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument,
335 OnDidAccessInitialDocument) 337 OnDidAccessInitialDocument)
336 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisownOpener, OnDidDisownOpener) 338 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisownOpener, OnDidDisownOpener)
337 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) 339 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle)
338 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) 340 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding)
341 IPC_MESSAGE_HANDLER(PlatformNotificationHostMsg_RequestPermission,
342 OnRequestPlatformNotificationPermission)
339 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, 343 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission,
340 OnRequestDesktopNotificationPermission) 344 OnRequestDesktopNotificationPermission)
341 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, 345 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show,
342 OnShowDesktopNotification) 346 OnShowDesktopNotification)
343 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, 347 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel,
344 OnCancelDesktopNotification) 348 OnCancelDesktopNotification)
345 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, 349 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse,
346 OnTextSurroundingSelectionResponse) 350 OnTextSurroundingSelectionResponse)
347 IPC_END_MESSAGE_MAP() 351 IPC_END_MESSAGE_MAP()
348 352
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 const base::string16& message, 698 const base::string16& message,
695 bool is_reload, 699 bool is_reload,
696 IPC::Message* reply_msg) { 700 IPC::Message* reply_msg) {
697 // While a JS before unload dialog is showing, tabs in the same process 701 // While a JS before unload dialog is showing, tabs in the same process
698 // shouldn't process input events. 702 // shouldn't process input events.
699 GetProcess()->SetIgnoreInputEvents(true); 703 GetProcess()->SetIgnoreInputEvents(true);
700 render_view_host_->StopHangMonitorTimeout(); 704 render_view_host_->StopHangMonitorTimeout();
701 delegate_->RunBeforeUnloadConfirm(this, message, is_reload, reply_msg); 705 delegate_->RunBeforeUnloadConfirm(this, message, is_reload, reply_msg);
702 } 706 }
703 707
708 void RenderFrameHostImpl::OnRequestPlatformNotificationPermission(
709 const GURL& origin, int request_id) {
710 base::Closure done_callback = base::Bind(
711 &RenderFrameHostImpl::PlatformNotificationPermissionRequestDone,
712 weak_ptr_factory_.GetWeakPtr(), origin, request_id);
713 GetContentClient()->browser()->RequestDesktopNotificationPermission(
714 origin, this, done_callback);
715 }
716
717 // TODO(peter): Remove this call and the associated IPC messages when Blink
718 // has switched to the new Web Notification permission code-path.
704 void RenderFrameHostImpl::OnRequestDesktopNotificationPermission( 719 void RenderFrameHostImpl::OnRequestDesktopNotificationPermission(
705 const GURL& source_origin, int callback_context) { 720 const GURL& source_origin, int callback_context) {
706 base::Closure done_callback = base::Bind( 721 base::Closure done_callback = base::Bind(
707 &RenderFrameHostImpl::DesktopNotificationPermissionRequestDone, 722 &RenderFrameHostImpl::DesktopNotificationPermissionRequestDone,
708 weak_ptr_factory_.GetWeakPtr(), callback_context); 723 weak_ptr_factory_.GetWeakPtr(), callback_context);
709 GetContentClient()->browser()->RequestDesktopNotificationPermission( 724 GetContentClient()->browser()->RequestDesktopNotificationPermission(
710 source_origin, this, done_callback); 725 source_origin, this, done_callback);
711 } 726 }
712 727
713 void RenderFrameHostImpl::OnShowDesktopNotification( 728 void RenderFrameHostImpl::OnShowDesktopNotification(
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 render_view_host_->delegate_->RendererUnresponsive( 939 render_view_host_->delegate_->RendererUnresponsive(
925 render_view_host_, 940 render_view_host_,
926 render_view_host_->is_waiting_for_beforeunload_ack(), 941 render_view_host_->is_waiting_for_beforeunload_ack(),
927 render_view_host_->IsWaitingForUnloadACK()); 942 render_view_host_->IsWaitingForUnloadACK());
928 } 943 }
929 944
930 void RenderFrameHostImpl::NotificationClosed(int notification_id) { 945 void RenderFrameHostImpl::NotificationClosed(int notification_id) {
931 cancel_notification_callbacks_.erase(notification_id); 946 cancel_notification_callbacks_.erase(notification_id);
932 } 947 }
933 948
949 void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone(
950 const GURL& origin, int request_id) {
951 blink::WebNotificationPermission permission =
952 blink::WebNotificationPermissionAllowed;
Jun Mukai 2014/07/15 21:49:32 Should this be Denied? Allowing notifications if
Peter Beverloo 2014/07/15 21:53:48 I'm merely copying the logic in RenderMessageFilte
953 #if defined(ENABLE_NOTIFICATIONS)
954 permission = static_cast<blink::WebNotificationPermission>(
955 GetContentClient()->browser()->CheckDesktopNotificationPermission(
956 origin,
957 GetProcess()->GetBrowserContext()->GetResourceContext(),
958 GetProcess()->GetID()));
959 #endif
960
961 Send(new PlatformNotificationMsg_PermissionRequestComplete(
962 routing_id_, request_id, permission));
963 }
964
965 // TODO(peter): Remove this method when Blink uses the new code-path.
934 void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone( 966 void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone(
935 int callback_context) { 967 int callback_context) {
936 Send(new DesktopNotificationMsg_PermissionRequestDone( 968 Send(new DesktopNotificationMsg_PermissionRequestDone(
937 routing_id_, callback_context)); 969 routing_id_, callback_context));
938 } 970 }
939 971
940 void RenderFrameHostImpl::SetHasPendingTransitionRequest( 972 void RenderFrameHostImpl::SetHasPendingTransitionRequest(
941 bool has_pending_request) { 973 bool has_pending_request) {
942 BrowserThread::PostTask( 974 BrowserThread::PostTask(
943 BrowserThread::IO, 975 BrowserThread::IO,
944 FROM_HERE, 976 FROM_HERE,
945 base::Bind( 977 base::Bind(
946 &TransitionRequestManager::SetHasPendingTransitionRequest, 978 &TransitionRequestManager::SetHasPendingTransitionRequest,
947 base::Unretained(TransitionRequestManager::GetInstance()), 979 base::Unretained(TransitionRequestManager::GetInstance()),
948 GetProcess()->GetID(), 980 GetProcess()->GetID(),
949 routing_id_, 981 routing_id_,
950 has_pending_request)); 982 has_pending_request));
951 } 983 }
952 984
953 } // namespace content 985 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/common/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698