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/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" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/metrics/user_metrics_action.h" | 12 #include "base/metrics/user_metrics_action.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "content/browser/accessibility/accessibility_mode_helper.h" | 14 #include "content/browser/accessibility/accessibility_mode_helper.h" |
15 #include "content/browser/accessibility/browser_accessibility_manager.h" | 15 #include "content/browser/accessibility/browser_accessibility_manager.h" |
16 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 16 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
17 #include "content/browser/child_process_security_policy_impl.h" | 17 #include "content/browser/child_process_security_policy_impl.h" |
18 #include "content/browser/frame_host/cross_process_frame_connector.h" | 18 #include "content/browser/frame_host/cross_process_frame_connector.h" |
19 #include "content/browser/frame_host/cross_site_transferring_request.h" | 19 #include "content/browser/frame_host/cross_site_transferring_request.h" |
20 #include "content/browser/frame_host/frame_tree.h" | 20 #include "content/browser/frame_host/frame_tree.h" |
21 #include "content/browser/frame_host/frame_tree_node.h" | 21 #include "content/browser/frame_host/frame_tree_node.h" |
22 #include "content/browser/frame_host/navigator.h" | 22 #include "content/browser/frame_host/navigator.h" |
23 #include "content/browser/frame_host/render_frame_host_delegate.h" | 23 #include "content/browser/frame_host/render_frame_host_delegate.h" |
24 #include "content/browser/frame_host/render_frame_proxy_host.h" | 24 #include "content/browser/frame_host/render_frame_proxy_host.h" |
25 #include "content/browser/renderer_host/input/input_router.h" | 25 #include "content/browser/renderer_host/input/input_router.h" |
26 #include "content/browser/renderer_host/input/timeout_monitor.h" | 26 #include "content/browser/renderer_host/input/timeout_monitor.h" |
27 #include "content/browser/renderer_host/render_process_host_impl.h" | 27 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 28 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 29 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
28 #include "content/browser/renderer_host/render_view_host_impl.h" | 30 #include "content/browser/renderer_host/render_view_host_impl.h" |
29 #include "content/browser/renderer_host/render_widget_host_impl.h" | 31 #include "content/browser/renderer_host/render_widget_host_impl.h" |
30 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 32 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
31 #include "content/browser/transition_request_manager.h" | 33 #include "content/browser/transition_request_manager.h" |
32 #include "content/common/accessibility_messages.h" | 34 #include "content/common/accessibility_messages.h" |
33 #include "content/common/desktop_notification_messages.h" | 35 #include "content/common/desktop_notification_messages.h" |
34 #include "content/common/frame_messages.h" | 36 #include "content/common/frame_messages.h" |
35 #include "content/common/input_messages.h" | 37 #include "content/common/input_messages.h" |
36 #include "content/common/inter_process_time_ticks_converter.h" | 38 #include "content/common/inter_process_time_ticks_converter.h" |
37 #include "content/common/platform_notification_messages.h" | 39 #include "content/common/platform_notification_messages.h" |
38 #include "content/common/render_frame_setup.mojom.h" | 40 #include "content/common/render_frame_setup.mojom.h" |
39 #include "content/common/swapped_out_messages.h" | 41 #include "content/common/swapped_out_messages.h" |
40 #include "content/public/browser/ax_event_notification_details.h" | 42 #include "content/public/browser/ax_event_notification_details.h" |
41 #include "content/public/browser/browser_accessibility_state.h" | 43 #include "content/public/browser/browser_accessibility_state.h" |
42 #include "content/public/browser/browser_thread.h" | 44 #include "content/public/browser/browser_thread.h" |
43 #include "content/public/browser/content_browser_client.h" | 45 #include "content/public/browser/content_browser_client.h" |
44 #include "content/public/browser/desktop_notification_delegate.h" | 46 #include "content/public/browser/desktop_notification_delegate.h" |
45 #include "content/public/browser/render_process_host.h" | 47 #include "content/public/browser/render_process_host.h" |
46 #include "content/public/browser/render_widget_host_view.h" | 48 #include "content/public/browser/render_widget_host_view.h" |
47 #include "content/public/browser/user_metrics.h" | 49 #include "content/public/browser/user_metrics.h" |
48 #include "content/public/common/content_constants.h" | 50 #include "content/public/common/content_constants.h" |
49 #include "content/public/common/content_switches.h" | 51 #include "content/public/common/content_switches.h" |
50 #include "content/public/common/url_constants.h" | 52 #include "content/public/common/url_constants.h" |
51 #include "content/public/common/url_utils.h" | 53 #include "content/public/common/url_utils.h" |
52 #include "ui/accessibility/ax_tree.h" | 54 #include "ui/accessibility/ax_tree.h" |
53 #include "url/gurl.h" | 55 #include "url/gurl.h" |
54 | 56 |
| 57 #if defined(OS_MACOSX) |
| 58 #include "content/browser/frame_host/popup_menu_helper_mac.h" |
| 59 #endif |
| 60 |
55 using base::TimeDelta; | 61 using base::TimeDelta; |
56 | 62 |
57 namespace content { | 63 namespace content { |
58 | 64 |
59 namespace { | 65 namespace { |
60 | 66 |
61 // The (process id, routing id) pair that identifies one RenderFrame. | 67 // The (process id, routing id) pair that identifies one RenderFrame. |
62 typedef std::pair<int32, int32> RenderFrameHostID; | 68 typedef std::pair<int32, int32> RenderFrameHostID; |
63 typedef base::hash_map<RenderFrameHostID, RenderFrameHostImpl*> | 69 typedef base::hash_map<RenderFrameHostID, RenderFrameHostImpl*> |
64 RoutingIDFrameMap; | 70 RoutingIDFrameMap; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 OnRequestPlatformNotificationPermission) | 363 OnRequestPlatformNotificationPermission) |
358 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, | 364 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, |
359 OnShowDesktopNotification) | 365 OnShowDesktopNotification) |
360 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, | 366 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, |
361 OnCancelDesktopNotification) | 367 OnCancelDesktopNotification) |
362 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, | 368 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, |
363 OnTextSurroundingSelectionResponse) | 369 OnTextSurroundingSelectionResponse) |
364 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) | 370 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) |
365 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, | 371 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, |
366 OnAccessibilityLocationChanges) | 372 OnAccessibilityLocationChanges) |
| 373 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 374 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) |
| 375 IPC_MESSAGE_HANDLER(FrameHostMsg_HidePopup, OnHidePopup) |
| 376 #endif |
367 IPC_END_MESSAGE_MAP() | 377 IPC_END_MESSAGE_MAP() |
368 | 378 |
369 return handled; | 379 return handled; |
370 } | 380 } |
371 | 381 |
372 void RenderFrameHostImpl::AccessibilitySetFocus(int object_id) { | 382 void RenderFrameHostImpl::AccessibilitySetFocus(int object_id) { |
373 Send(new AccessibilityMsg_SetFocus(routing_id_, object_id)); | 383 Send(new AccessibilityMsg_SetFocus(routing_id_, object_id)); |
374 } | 384 } |
375 | 385 |
376 void RenderFrameHostImpl::AccessibilityDoDefaultAction(int object_id) { | 386 void RenderFrameHostImpl::AccessibilityDoDefaultAction(int object_id) { |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 browser_accessibility_manager_.reset( | 1001 browser_accessibility_manager_.reset( |
992 view->CreateBrowserAccessibilityManager(this)); | 1002 view->CreateBrowserAccessibilityManager(this)); |
993 } | 1003 } |
994 if (browser_accessibility_manager_) | 1004 if (browser_accessibility_manager_) |
995 browser_accessibility_manager_->OnLocationChanges(params); | 1005 browser_accessibility_manager_->OnLocationChanges(params); |
996 } | 1006 } |
997 // TODO(aboxhall): send location change events to web contents observers too | 1007 // TODO(aboxhall): send location change events to web contents observers too |
998 } | 1008 } |
999 } | 1009 } |
1000 | 1010 |
| 1011 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 1012 void RenderFrameHostImpl::OnShowPopup( |
| 1013 const FrameHostMsg_ShowPopup_Params& params) { |
| 1014 RenderViewHostDelegateView* view = |
| 1015 render_view_host_->delegate_->GetDelegateView(); |
| 1016 if (view) { |
| 1017 view->ShowPopupMenu(this, |
| 1018 params.bounds, |
| 1019 params.item_height, |
| 1020 params.item_font_size, |
| 1021 params.selected_item, |
| 1022 params.popup_items, |
| 1023 params.right_aligned, |
| 1024 params.allow_multiple_selection); |
| 1025 } |
| 1026 } |
| 1027 |
| 1028 void RenderFrameHostImpl::OnHidePopup() { |
| 1029 RenderViewHostDelegateView* view = |
| 1030 render_view_host_->delegate_->GetDelegateView(); |
| 1031 if (view) |
| 1032 view->HidePopupMenu(); |
| 1033 } |
| 1034 #endif |
| 1035 |
1001 void RenderFrameHostImpl::SetPendingShutdown(const base::Closure& on_swap_out) { | 1036 void RenderFrameHostImpl::SetPendingShutdown(const base::Closure& on_swap_out) { |
1002 render_view_host_->SetPendingShutdown(on_swap_out); | 1037 render_view_host_->SetPendingShutdown(on_swap_out); |
1003 } | 1038 } |
1004 | 1039 |
1005 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) { | 1040 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) { |
1006 // TODO(creis): We should also check for WebUI pages here. Also, when the | 1041 // TODO(creis): We should also check for WebUI pages here. Also, when the |
1007 // out-of-process iframes implementation is ready, we should check for | 1042 // out-of-process iframes implementation is ready, we should check for |
1008 // cross-site URLs that are not allowed to commit in this process. | 1043 // cross-site URLs that are not allowed to commit in this process. |
1009 | 1044 |
1010 // Give the client a chance to disallow URLs from committing. | 1045 // Give the client a chance to disallow URLs from committing. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 render_view_host_->GetView()); | 1226 render_view_host_->GetView()); |
1192 if (view && | 1227 if (view && |
1193 !browser_accessibility_manager_) { | 1228 !browser_accessibility_manager_) { |
1194 browser_accessibility_manager_.reset( | 1229 browser_accessibility_manager_.reset( |
1195 view->CreateBrowserAccessibilityManager(this)); | 1230 view->CreateBrowserAccessibilityManager(this)); |
1196 } | 1231 } |
1197 return browser_accessibility_manager_.get(); | 1232 return browser_accessibility_manager_.get(); |
1198 } | 1233 } |
1199 | 1234 |
1200 #if defined(OS_WIN) | 1235 #if defined(OS_WIN) |
| 1236 |
1201 void RenderFrameHostImpl::SetParentNativeViewAccessible( | 1237 void RenderFrameHostImpl::SetParentNativeViewAccessible( |
1202 gfx::NativeViewAccessible accessible_parent) { | 1238 gfx::NativeViewAccessible accessible_parent) { |
1203 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( | 1239 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( |
1204 render_view_host_->GetView()); | 1240 render_view_host_->GetView()); |
1205 if (view) | 1241 if (view) |
1206 view->SetParentNativeViewAccessible(accessible_parent); | 1242 view->SetParentNativeViewAccessible(accessible_parent); |
1207 } | 1243 } |
1208 | 1244 |
1209 gfx::NativeViewAccessible | 1245 gfx::NativeViewAccessible |
1210 RenderFrameHostImpl::GetParentNativeViewAccessible() const { | 1246 RenderFrameHostImpl::GetParentNativeViewAccessible() const { |
1211 return delegate_->GetParentNativeViewAccessible(); | 1247 return delegate_->GetParentNativeViewAccessible(); |
1212 } | 1248 } |
1213 #endif // defined(OS_WIN) | 1249 |
| 1250 #elif defined(OS_MACOSX) |
| 1251 |
| 1252 void RenderFrameHostImpl::DidSelectPopupMenuItem(int selected_index) { |
| 1253 Send(new FrameMsg_SelectPopupMenuItem(routing_id_, selected_index)); |
| 1254 } |
| 1255 |
| 1256 void RenderFrameHostImpl::DidCancelPopupMenu() { |
| 1257 Send(new FrameMsg_SelectPopupMenuItem(routing_id_, -1)); |
| 1258 } |
| 1259 |
| 1260 #elif defined(OS_ANDROID) |
| 1261 |
| 1262 void RenderFrameHostImpl::DidSelectPopupMenuItems( |
| 1263 const std::vector<int>& selected_indices) { |
| 1264 Send(new FrameMsg_SelectPopupMenuItems(routing_id_, false, selected_indices)); |
| 1265 } |
| 1266 |
| 1267 void RenderFrameHostImpl::DidCancelPopupMenu() { |
| 1268 Send(new FrameMsg_SelectPopupMenuItems( |
| 1269 routing_id_, true, std::vector<int>())); |
| 1270 } |
| 1271 |
| 1272 #endif |
1214 | 1273 |
1215 void RenderFrameHostImpl::ClearPendingTransitionRequestData() { | 1274 void RenderFrameHostImpl::ClearPendingTransitionRequestData() { |
1216 BrowserThread::PostTask( | 1275 BrowserThread::PostTask( |
1217 BrowserThread::IO, | 1276 BrowserThread::IO, |
1218 FROM_HERE, | 1277 FROM_HERE, |
1219 base::Bind( | 1278 base::Bind( |
1220 &TransitionRequestManager::ClearPendingTransitionRequestData, | 1279 &TransitionRequestManager::ClearPendingTransitionRequestData, |
1221 base::Unretained(TransitionRequestManager::GetInstance()), | 1280 base::Unretained(TransitionRequestManager::GetInstance()), |
1222 GetProcess()->GetID(), | 1281 GetProcess()->GetID(), |
1223 routing_id_)); | 1282 routing_id_)); |
(...skipping 20 matching lines...) Expand all Loading... |
1244 } | 1303 } |
1245 | 1304 |
1246 void RenderFrameHostImpl::CancelSuspendedNavigations() { | 1305 void RenderFrameHostImpl::CancelSuspendedNavigations() { |
1247 // Clear any state if a pending navigation is canceled or preempted. | 1306 // Clear any state if a pending navigation is canceled or preempted. |
1248 if (suspended_nav_params_) | 1307 if (suspended_nav_params_) |
1249 suspended_nav_params_.reset(); | 1308 suspended_nav_params_.reset(); |
1250 navigations_suspended_ = false; | 1309 navigations_suspended_ = false; |
1251 } | 1310 } |
1252 | 1311 |
1253 } // namespace content | 1312 } // namespace content |
OLD | NEW |