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

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

Issue 740543003: Remove the old Web Notification code-path (Chromium) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unittest references Created 6 years, 1 month 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 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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 19 matching lines...) Expand all
30 #include "content/browser/renderer_host/input/input_router.h" 30 #include "content/browser/renderer_host/input/input_router.h"
31 #include "content/browser/renderer_host/input/timeout_monitor.h" 31 #include "content/browser/renderer_host/input/timeout_monitor.h"
32 #include "content/browser/renderer_host/render_process_host_impl.h" 32 #include "content/browser/renderer_host/render_process_host_impl.h"
33 #include "content/browser/renderer_host/render_view_host_delegate.h" 33 #include "content/browser/renderer_host/render_view_host_delegate.h"
34 #include "content/browser/renderer_host/render_view_host_delegate_view.h" 34 #include "content/browser/renderer_host/render_view_host_delegate_view.h"
35 #include "content/browser/renderer_host/render_view_host_impl.h" 35 #include "content/browser/renderer_host/render_view_host_impl.h"
36 #include "content/browser/renderer_host/render_widget_host_impl.h" 36 #include "content/browser/renderer_host/render_widget_host_impl.h"
37 #include "content/browser/renderer_host/render_widget_host_view_base.h" 37 #include "content/browser/renderer_host/render_widget_host_view_base.h"
38 #include "content/browser/transition_request_manager.h" 38 #include "content/browser/transition_request_manager.h"
39 #include "content/common/accessibility_messages.h" 39 #include "content/common/accessibility_messages.h"
40 #include "content/common/desktop_notification_messages.h"
41 #include "content/common/frame_messages.h" 40 #include "content/common/frame_messages.h"
42 #include "content/common/input_messages.h" 41 #include "content/common/input_messages.h"
43 #include "content/common/inter_process_time_ticks_converter.h" 42 #include "content/common/inter_process_time_ticks_converter.h"
44 #include "content/common/navigation_params.h" 43 #include "content/common/navigation_params.h"
45 #include "content/common/platform_notification_messages.h" 44 #include "content/common/platform_notification_messages.h"
46 #include "content/common/render_frame_setup.mojom.h" 45 #include "content/common/render_frame_setup.mojom.h"
47 #include "content/common/swapped_out_messages.h" 46 #include "content/common/swapped_out_messages.h"
48 #include "content/public/browser/ax_event_notification_details.h" 47 #include "content/public/browser/ax_event_notification_details.h"
49 #include "content/public/browser/browser_accessibility_state.h" 48 #include "content/public/browser/browser_accessibility_state.h"
50 #include "content/public/browser/browser_context.h" 49 #include "content/public/browser/browser_context.h"
(...skipping 25 matching lines...) Expand all
76 // The next value to use for the accessibility reset token. 75 // The next value to use for the accessibility reset token.
77 int g_next_accessibility_reset_token = 1; 76 int g_next_accessibility_reset_token = 1;
78 77
79 // The (process id, routing id) pair that identifies one RenderFrame. 78 // The (process id, routing id) pair that identifies one RenderFrame.
80 typedef std::pair<int32, int32> RenderFrameHostID; 79 typedef std::pair<int32, int32> RenderFrameHostID;
81 typedef base::hash_map<RenderFrameHostID, RenderFrameHostImpl*> 80 typedef base::hash_map<RenderFrameHostID, RenderFrameHostImpl*>
82 RoutingIDFrameMap; 81 RoutingIDFrameMap;
83 base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = 82 base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map =
84 LAZY_INSTANCE_INITIALIZER; 83 LAZY_INSTANCE_INITIALIZER;
85 84
86 class DesktopNotificationDelegateImpl : public DesktopNotificationDelegate {
87 public:
88 DesktopNotificationDelegateImpl(RenderFrameHost* render_frame_host,
89 int notification_id)
90 : render_process_id_(render_frame_host->GetProcess()->GetID()),
91 render_frame_id_(render_frame_host->GetRoutingID()),
92 notification_id_(notification_id) {}
93
94 ~DesktopNotificationDelegateImpl() override {}
95
96 void NotificationDisplayed() override {
97 RenderFrameHost* rfh =
98 RenderFrameHost::FromID(render_process_id_, render_frame_id_);
99 if (!rfh)
100 return;
101
102 rfh->Send(new DesktopNotificationMsg_PostDisplay(
103 rfh->GetRoutingID(), notification_id_));
104 }
105
106 void NotificationClosed(bool by_user) override {
107 RenderFrameHost* rfh =
108 RenderFrameHost::FromID(render_process_id_, render_frame_id_);
109 if (!rfh)
110 return;
111
112 rfh->Send(new DesktopNotificationMsg_PostClose(
113 rfh->GetRoutingID(), notification_id_, by_user));
114 static_cast<RenderFrameHostImpl*>(rfh)->NotificationClosed(
115 notification_id_);
116 }
117
118 void NotificationClick() override {
119 RenderFrameHost* rfh =
120 RenderFrameHost::FromID(render_process_id_, render_frame_id_);
121 if (!rfh)
122 return;
123
124 rfh->Send(new DesktopNotificationMsg_PostClick(
125 rfh->GetRoutingID(), notification_id_));
126 }
127
128 private:
129 int render_process_id_;
130 int render_frame_id_;
131 int notification_id_;
132 };
133
134 // Translate a WebKit text direction into a base::i18n one. 85 // Translate a WebKit text direction into a base::i18n one.
135 base::i18n::TextDirection WebTextDirectionToChromeTextDirection( 86 base::i18n::TextDirection WebTextDirectionToChromeTextDirection(
136 blink::WebTextDirection dir) { 87 blink::WebTextDirection dir) {
137 switch (dir) { 88 switch (dir) {
138 case blink::WebTextDirectionLeftToRight: 89 case blink::WebTextDirectionLeftToRight:
139 return base::i18n::LEFT_TO_RIGHT; 90 return base::i18n::LEFT_TO_RIGHT;
140 case blink::WebTextDirectionRightToLeft: 91 case blink::WebTextDirectionRightToLeft:
141 return base::i18n::RIGHT_TO_LEFT; 92 return base::i18n::RIGHT_TO_LEFT;
142 default: 93 default:
143 NOTREACHED(); 94 NOTREACHED();
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument, 328 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument,
378 OnDidAccessInitialDocument) 329 OnDidAccessInitialDocument)
379 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisownOpener, OnDidDisownOpener) 330 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisownOpener, OnDidDisownOpener)
380 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAssignPageId, OnDidAssignPageId) 331 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAssignPageId, OnDidAssignPageId)
381 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) 332 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle)
382 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) 333 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding)
383 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, 334 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation,
384 OnBeginNavigation) 335 OnBeginNavigation)
385 IPC_MESSAGE_HANDLER(PlatformNotificationHostMsg_RequestPermission, 336 IPC_MESSAGE_HANDLER(PlatformNotificationHostMsg_RequestPermission,
386 OnRequestPlatformNotificationPermission) 337 OnRequestPlatformNotificationPermission)
387 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show,
388 OnShowDesktopNotification)
389 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel,
390 OnCancelDesktopNotification)
391 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, 338 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse,
392 OnTextSurroundingSelectionResponse) 339 OnTextSurroundingSelectionResponse)
393 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) 340 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents)
394 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, 341 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges,
395 OnAccessibilityLocationChanges) 342 OnAccessibilityLocationChanges)
396 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_FindInPageResult, 343 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_FindInPageResult,
397 OnAccessibilityFindInPageResult) 344 OnAccessibilityFindInPageResult)
398 #if defined(OS_MACOSX) || defined(OS_ANDROID) 345 #if defined(OS_MACOSX) || defined(OS_ANDROID)
399 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) 346 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup)
400 IPC_MESSAGE_HANDLER(FrameHostMsg_HidePopup, OnHidePopup) 347 IPC_MESSAGE_HANDLER(FrameHostMsg_HidePopup, OnHidePopup)
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 // TODO(peter): plumb user_gesture and bridge_id. 957 // TODO(peter): plumb user_gesture and bridge_id.
1011 GetContentClient()->browser()->RequestPermission( 958 GetContentClient()->browser()->RequestPermission(
1012 content::PERMISSION_NOTIFICATIONS, 959 content::PERMISSION_NOTIFICATIONS,
1013 delegate()->GetAsWebContents(), 960 delegate()->GetAsWebContents(),
1014 routing_id_, 961 routing_id_,
1015 origin, 962 origin,
1016 true, // user_gesture, 963 true, // user_gesture,
1017 done_callback); 964 done_callback);
1018 } 965 }
1019 966
1020 void RenderFrameHostImpl::OnShowDesktopNotification(
1021 int notification_id,
1022 const ShowDesktopNotificationHostMsgParams& params) {
1023 scoped_ptr<DesktopNotificationDelegateImpl> delegate(
1024 new DesktopNotificationDelegateImpl(this, notification_id));
1025
1026 base::Closure cancel_callback;
1027 GetContentClient()->browser()->ShowDesktopNotification(
1028 params,
1029 GetSiteInstance()->GetBrowserContext(),
1030 GetProcess()->GetID(),
1031 delegate.Pass(),
1032 &cancel_callback);
1033
1034 cancel_notification_callbacks_[notification_id] = cancel_callback;
1035 }
1036
1037 void RenderFrameHostImpl::OnCancelDesktopNotification(int notification_id) {
1038 if (!cancel_notification_callbacks_.count(notification_id))
1039 return;
1040
1041 cancel_notification_callbacks_[notification_id].Run();
1042 cancel_notification_callbacks_.erase(notification_id);
1043 }
1044
1045 void RenderFrameHostImpl::OnTextSurroundingSelectionResponse( 967 void RenderFrameHostImpl::OnTextSurroundingSelectionResponse(
1046 const base::string16& content, 968 const base::string16& content,
1047 size_t start_offset, 969 size_t start_offset,
1048 size_t end_offset) { 970 size_t end_offset) {
1049 render_view_host_->OnTextSurroundingSelectionResponse( 971 render_view_host_->OnTextSurroundingSelectionResponse(
1050 content, start_offset, end_offset); 972 content, start_offset, end_offset);
1051 } 973 }
1052 974
1053 void RenderFrameHostImpl::OnDidAccessInitialDocument() { 975 void RenderFrameHostImpl::OnDidAccessInitialDocument() {
1054 delegate_->DidAccessInitialDocument(); 976 delegate_->DidAccessInitialDocument();
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 // If we are waiting for an unload or beforeunload ack and the user has 1368 // If we are waiting for an unload or beforeunload ack and the user has
1447 // suppressed messages, kill the tab immediately; a page that's spamming 1369 // suppressed messages, kill the tab immediately; a page that's spamming
1448 // alerts in onbeforeunload is presumably malicious, so there's no point in 1370 // alerts in onbeforeunload is presumably malicious, so there's no point in
1449 // continuing to run its script and dragging out the process. 1371 // continuing to run its script and dragging out the process.
1450 // This must be done after sending the reply since RenderView can't close 1372 // This must be done after sending the reply since RenderView can't close
1451 // correctly while waiting for a response. 1373 // correctly while waiting for a response.
1452 if (is_waiting && dialog_was_suppressed) 1374 if (is_waiting && dialog_was_suppressed)
1453 render_view_host_->delegate_->RendererUnresponsive(render_view_host_); 1375 render_view_host_->delegate_->RendererUnresponsive(render_view_host_);
1454 } 1376 }
1455 1377
1456 void RenderFrameHostImpl::NotificationClosed(int notification_id) {
1457 cancel_notification_callbacks_.erase(notification_id);
1458 }
1459
1460 // PlzNavigate 1378 // PlzNavigate
1461 void RenderFrameHostImpl::CommitNavigation( 1379 void RenderFrameHostImpl::CommitNavigation(
1462 ResourceResponse* response, 1380 ResourceResponse* response,
1463 scoped_ptr<StreamHandle> body, 1381 scoped_ptr<StreamHandle> body,
1464 const CommonNavigationParams& common_params, 1382 const CommonNavigationParams& common_params,
1465 const CommitNavigationParams& commit_params) { 1383 const CommitNavigationParams& commit_params) {
1466 // TODO(clamy): Check if we have to add security checks for the browser plugin 1384 // TODO(clamy): Check if we have to add security checks for the browser plugin
1467 // guests. 1385 // guests.
1468 1386
1469 Send(new FrameMsg_CommitNavigation( 1387 Send(new FrameMsg_CommitNavigation(
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 void RenderFrameHostImpl::DidUseGeolocationPermission() { 1602 void RenderFrameHostImpl::DidUseGeolocationPermission() {
1685 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); 1603 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame();
1686 GetContentClient()->browser()->RegisterPermissionUsage( 1604 GetContentClient()->browser()->RegisterPermissionUsage(
1687 PERMISSION_GEOLOCATION, 1605 PERMISSION_GEOLOCATION,
1688 delegate_->GetAsWebContents(), 1606 delegate_->GetAsWebContents(),
1689 GetLastCommittedURL().GetOrigin(), 1607 GetLastCommittedURL().GetOrigin(),
1690 top_frame->GetLastCommittedURL().GetOrigin()); 1608 top_frame->GetLastCommittedURL().GetOrigin());
1691 } 1609 }
1692 1610
1693 } // namespace content 1611 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/browser/renderer_host/render_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698