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

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

Issue 501583003: Move external popup menus from WebViewClient to WebFrameClient, part 3/3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nicer ipc Created 6 years, 3 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
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"
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
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
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();
nasko 2014/08/25 16:54:13 Shouldn't we be going through RenderframeHostDeleg
Avi (use Gerrit) 2014/08/25 18:17:33 This patch got big quickly, so I wanted to cut off
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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 if (view) 1236 if (view)
1202 view->SetParentNativeViewAccessible(accessible_parent); 1237 view->SetParentNativeViewAccessible(accessible_parent);
1203 } 1238 }
1204 1239
1205 gfx::NativeViewAccessible 1240 gfx::NativeViewAccessible
1206 RenderFrameHostImpl::GetParentNativeViewAccessible() const { 1241 RenderFrameHostImpl::GetParentNativeViewAccessible() const {
1207 return delegate_->GetParentNativeViewAccessible(); 1242 return delegate_->GetParentNativeViewAccessible();
1208 } 1243 }
1209 #endif // defined(OS_WIN) 1244 #endif // defined(OS_WIN)
1210 1245
1246 #if defined(OS_MACOSX)
1247 void RenderFrameHostImpl::DidSelectPopupMenuItem(int selected_index) {
1248 Send(new FrameMsg_SelectPopupMenuItem(routing_id_, selected_index));
1249 }
1250
1251 void RenderFrameHostImpl::DidCancelPopupMenu() {
1252 Send(new FrameMsg_SelectPopupMenuItem(routing_id_, -1));
1253 }
1254 #endif
nasko 2014/08/25 16:54:12 nit: You used #elif in other places, any reason no
Avi (use Gerrit) 2014/08/25 18:17:33 Done.
1255
1256 #if defined(OS_ANDROID)
1257 void RenderFrameHostImpl::DidSelectPopupMenuItems(
1258 const std::vector<int>& selected_indices) {
1259 Send(new FrameMsg_SelectPopupMenuItems(routing_id_, false, selected_indices));
1260 }
1261
1262 void RenderFrameHostImpl::DidCancelPopupMenu() {
1263 Send(new FrameMsg_SelectPopupMenuItems(
1264 routing_id_, true, std::vector<int>()));
1265 }
1266 #endif
1267
1211 void RenderFrameHostImpl::ClearPendingTransitionRequestData() { 1268 void RenderFrameHostImpl::ClearPendingTransitionRequestData() {
1212 BrowserThread::PostTask( 1269 BrowserThread::PostTask(
1213 BrowserThread::IO, 1270 BrowserThread::IO,
1214 FROM_HERE, 1271 FROM_HERE,
1215 base::Bind( 1272 base::Bind(
1216 &TransitionRequestManager::ClearPendingTransitionRequestData, 1273 &TransitionRequestManager::ClearPendingTransitionRequestData,
1217 base::Unretained(TransitionRequestManager::GetInstance()), 1274 base::Unretained(TransitionRequestManager::GetInstance()),
1218 GetProcess()->GetID(), 1275 GetProcess()->GetID(),
1219 routing_id_)); 1276 routing_id_));
1220 } 1277 }
(...skipping 19 matching lines...) Expand all
1240 } 1297 }
1241 1298
1242 void RenderFrameHostImpl::CancelSuspendedNavigations() { 1299 void RenderFrameHostImpl::CancelSuspendedNavigations() {
1243 // Clear any state if a pending navigation is canceled or preempted. 1300 // Clear any state if a pending navigation is canceled or preempted.
1244 if (suspended_nav_params_) 1301 if (suspended_nav_params_)
1245 suspended_nav_params_.reset(); 1302 suspended_nav_params_.reset();
1246 navigations_suspended_ = false; 1303 navigations_suspended_ = false;
1247 } 1304 }
1248 1305
1249 } // namespace content 1306 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698