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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.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: rebase Created 6 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser_plugin/browser_plugin_guest.h" 5 #include "content/browser/browser_plugin/browser_plugin_guest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/pickle.h" 10 #include "base/pickle.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 12 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
13 #include "content/browser/browser_thread_impl.h" 13 #include "content/browser/browser_thread_impl.h"
14 #include "content/browser/child_process_security_policy_impl.h" 14 #include "content/browser/child_process_security_policy_impl.h"
15 #include "content/browser/frame_host/render_frame_host_impl.h" 15 #include "content/browser/frame_host/render_frame_host_impl.h"
16 #include "content/browser/frame_host/render_widget_host_view_guest.h" 16 #include "content/browser/frame_host/render_widget_host_view_guest.h"
17 #include "content/browser/loader/resource_dispatcher_host_impl.h" 17 #include "content/browser/loader/resource_dispatcher_host_impl.h"
18 #include "content/browser/renderer_host/render_view_host_impl.h" 18 #include "content/browser/renderer_host/render_view_host_impl.h"
19 #include "content/browser/renderer_host/render_widget_host_impl.h" 19 #include "content/browser/renderer_host/render_widget_host_impl.h"
20 #include "content/browser/renderer_host/render_widget_host_view_base.h" 20 #include "content/browser/renderer_host/render_widget_host_view_base.h"
21 #include "content/browser/web_contents/web_contents_impl.h" 21 #include "content/browser/web_contents/web_contents_impl.h"
22 #include "content/browser/web_contents/web_contents_view_guest.h" 22 #include "content/browser/web_contents/web_contents_view_guest.h"
23 #include "content/common/browser_plugin/browser_plugin_constants.h" 23 #include "content/common/browser_plugin/browser_plugin_constants.h"
24 #include "content/common/browser_plugin/browser_plugin_messages.h" 24 #include "content/common/browser_plugin/browser_plugin_messages.h"
25 #include "content/common/content_constants_internal.h" 25 #include "content/common/content_constants_internal.h"
26 #include "content/common/drag_messages.h" 26 #include "content/common/drag_messages.h"
27 #include "content/common/frame_messages.h"
27 #include "content/common/input_messages.h" 28 #include "content/common/input_messages.h"
28 #include "content/common/view_messages.h" 29 #include "content/common/view_messages.h"
29 #include "content/public/browser/browser_context.h" 30 #include "content/public/browser/browser_context.h"
30 #include "content/public/browser/browser_plugin_guest_manager.h" 31 #include "content/public/browser/browser_plugin_guest_manager.h"
31 #include "content/public/browser/content_browser_client.h" 32 #include "content/public/browser/content_browser_client.h"
32 #include "content/public/browser/render_widget_host_view.h" 33 #include "content/public/browser/render_widget_host_view.h"
33 #include "content/public/browser/user_metrics.h" 34 #include "content/public/browser/user_metrics.h"
34 #include "content/public/browser/web_contents_observer.h" 35 #include "content/public/browser/web_contents_observer.h"
35 #include "content/public/common/drop_data.h" 36 #include "content/public/common/drop_data.h"
36 #include "third_party/WebKit/public/platform/WebCursorInfo.h" 37 #include "third_party/WebKit/public/platform/WebCursorInfo.h"
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition, 439 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition,
439 OnImeCancelComposition) 440 OnImeCancelComposition)
440 #if defined(OS_MACOSX) || defined(USE_AURA) 441 #if defined(OS_MACOSX) || defined(USE_AURA)
441 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, 442 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged,
442 OnImeCompositionRangeChanged) 443 OnImeCompositionRangeChanged)
443 #endif 444 #endif
444 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, 445 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers,
445 OnHasTouchEventHandlers) 446 OnHasTouchEventHandlers)
446 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) 447 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse)
447 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) 448 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor)
448 #if defined(OS_MACOSX)
449 // MacOSX creates and populates platform-specific select drop-down menus
450 // whereas other platforms merely create a popup window that the guest
451 // renderer process paints inside.
452 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup)
453 #endif
454 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) 449 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget)
455 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) 450 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
456 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, 451 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged,
457 OnTextInputStateChanged) 452 OnTextInputStateChanged)
458 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) 453 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse)
459 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) 454 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)
460 IPC_MESSAGE_UNHANDLED(handled = false) 455 IPC_MESSAGE_UNHANDLED(handled = false)
461 IPC_END_MESSAGE_MAP() 456 IPC_END_MESSAGE_MAP()
462 return handled; 457 return handled;
463 } 458 }
464 459
460 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message,
461 RenderFrameHost* render_frame_host) {
462 // This will eventually be the home for more IPC handlers that depend on
463 // RenderFrameHost. Until more are moved here, though, the IPC_* macros won't
464 // compile if there are no handlers for a platform. So we have both #if guards
465 // around the whole thing (unfortunate but temporary), and #if guards where
466 // they belong, only around the one IPC handler. TODO(avi): Move more of the
467 // frame-based handlers to this function and remove the outer #if layer.
468 #if defined(OS_MACOSX)
469 bool handled = true;
470 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(BrowserPluginGuest, message,
471 render_frame_host)
472 #if defined(OS_MACOSX)
473 // MacOS X creates and populates platform-specific select drop-down menus
474 // whereas other platforms merely create a popup window that the guest
475 // renderer process paints inside.
476 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup)
477 #endif
478 IPC_MESSAGE_UNHANDLED(handled = false)
479 IPC_END_MESSAGE_MAP()
480 return handled;
481 #else
482 return false;
483 #endif
484 }
485
465 void BrowserPluginGuest::Attach( 486 void BrowserPluginGuest::Attach(
466 int browser_plugin_instance_id, 487 int browser_plugin_instance_id,
467 WebContentsImpl* embedder_web_contents, 488 WebContentsImpl* embedder_web_contents,
468 const BrowserPluginHostMsg_Attach_Params& params) { 489 const BrowserPluginHostMsg_Attach_Params& params) {
469 if (attached()) 490 if (attached())
470 return; 491 return;
471 492
472 delegate_->WillAttach(embedder_web_contents); 493 delegate_->WillAttach(embedder_web_contents);
473 494
474 // If a RenderView has already been created for this new window, then we need 495 // If a RenderView has already been created for this new window, then we need
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 browser_plugin_instance_id(), accept)); 797 browser_plugin_instance_id(), accept));
777 } 798 }
778 799
779 void BrowserPluginGuest::OnSetCursor(const WebCursor& cursor) { 800 void BrowserPluginGuest::OnSetCursor(const WebCursor& cursor) {
780 SendMessageToEmbedder( 801 SendMessageToEmbedder(
781 new BrowserPluginMsg_SetCursor(browser_plugin_instance_id(), cursor)); 802 new BrowserPluginMsg_SetCursor(browser_plugin_instance_id(), cursor));
782 } 803 }
783 804
784 #if defined(OS_MACOSX) 805 #if defined(OS_MACOSX)
785 void BrowserPluginGuest::OnShowPopup( 806 void BrowserPluginGuest::OnShowPopup(
786 const ViewHostMsg_ShowPopup_Params& params) { 807 RenderFrameHost* render_frame_host,
808 const FrameHostMsg_ShowPopup_Params& params) {
787 gfx::Rect translated_bounds(params.bounds); 809 gfx::Rect translated_bounds(params.bounds);
788 translated_bounds.Offset(guest_window_rect_.OffsetFromOrigin()); 810 translated_bounds.Offset(guest_window_rect_.OffsetFromOrigin());
789 BrowserPluginPopupMenuHelper popup_menu_helper( 811 BrowserPluginPopupMenuHelper popup_menu_helper(
790 embedder_web_contents_->GetRenderViewHost(), 812 embedder_web_contents_->GetRenderViewHost(), render_frame_host);
791 GetWebContents()->GetRenderViewHost());
792 popup_menu_helper.ShowPopupMenu(translated_bounds, 813 popup_menu_helper.ShowPopupMenu(translated_bounds,
793 params.item_height, 814 params.item_height,
794 params.item_font_size, 815 params.item_font_size,
795 params.selected_item, 816 params.selected_item,
796 params.popup_items, 817 params.popup_items,
797 params.right_aligned, 818 params.right_aligned,
798 params.allow_multiple_selection); 819 params.allow_multiple_selection);
799 } 820 }
800 #endif 821 #endif
801 822
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 void BrowserPluginGuest::OnImeCompositionRangeChanged( 868 void BrowserPluginGuest::OnImeCompositionRangeChanged(
848 const gfx::Range& range, 869 const gfx::Range& range,
849 const std::vector<gfx::Rect>& character_bounds) { 870 const std::vector<gfx::Rect>& character_bounds) {
850 static_cast<RenderWidgetHostViewBase*>( 871 static_cast<RenderWidgetHostViewBase*>(
851 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( 872 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged(
852 range, character_bounds); 873 range, character_bounds);
853 } 874 }
854 #endif 875 #endif
855 876
856 } // namespace content 877 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698