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

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: more fixin 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 (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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 guest_visible_(false), 81 guest_visible_(false),
81 guest_opaque_(true), 82 guest_opaque_(true),
82 embedder_visible_(true), 83 embedder_visible_(true),
83 copy_request_id_(0), 84 copy_request_id_(0),
84 has_render_view_(has_render_view), 85 has_render_view_(has_render_view),
85 is_in_destruction_(false), 86 is_in_destruction_(false),
86 last_text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 87 last_text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
87 last_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), 88 last_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
88 last_can_compose_inline_(true), 89 last_can_compose_inline_(true),
89 delegate_(delegate), 90 delegate_(delegate),
91 render_frame_message_source_(NULL),
90 weak_ptr_factory_(this) { 92 weak_ptr_factory_(this) {
91 DCHECK(web_contents); 93 DCHECK(web_contents);
92 DCHECK(delegate); 94 DCHECK(delegate);
93 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); 95 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create"));
94 web_contents->SetBrowserPluginGuest(this); 96 web_contents->SetBrowserPluginGuest(this);
95 delegate->RegisterDestructionCallback( 97 delegate->RegisterDestructionCallback(
96 base::Bind(&BrowserPluginGuest::WillDestroy, AsWeakPtr())); 98 base::Bind(&BrowserPluginGuest::WillDestroy, AsWeakPtr()));
97 } 99 }
98 100
99 void BrowserPluginGuest::WillDestroy() { 101 void BrowserPluginGuest::WillDestroy() {
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition, 440 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition,
439 OnImeCancelComposition) 441 OnImeCancelComposition)
440 #if defined(OS_MACOSX) || defined(USE_AURA) 442 #if defined(OS_MACOSX) || defined(USE_AURA)
441 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, 443 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged,
442 OnImeCompositionRangeChanged) 444 OnImeCompositionRangeChanged)
443 #endif 445 #endif
444 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, 446 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers,
445 OnHasTouchEventHandlers) 447 OnHasTouchEventHandlers)
446 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) 448 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse)
447 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) 449 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) 450 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget)
455 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) 451 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
456 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, 452 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged,
457 OnTextInputStateChanged) 453 OnTextInputStateChanged)
458 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) 454 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse)
459 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) 455 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)
460 IPC_MESSAGE_UNHANDLED(handled = false) 456 IPC_MESSAGE_UNHANDLED(handled = false)
461 IPC_END_MESSAGE_MAP() 457 IPC_END_MESSAGE_MAP()
462 return handled; 458 return handled;
463 } 459 }
464 460
461 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message,
462 RenderFrameHost* render_frame_host) {
463 // This will eventually be the home for more IPC handlers that depend on
464 // RenderFrameHost. Until more are moved here, though, the IPC_* macros won't
465 // compile if there are no handlers for a platform. So we have both #if guards
466 // around the whole thing (unfortunate but temporary), and #if guards where
467 // they belong, only around the one IPC handler. TODO(avi): Move more of the
468 // frame-based handlers to this function and remove the outer #if layer.
469 #if defined(OS_MACOSX)
470 render_frame_message_source_ = render_frame_host;
Fady Samuel 2014/08/23 10:56:17 nit: There's no way to pass this along via the mac
Avi (use Gerrit) 2014/08/23 18:36:44 No. If you take a look at WebContentsImpl::OnMessa
Avi (use Gerrit) 2014/08/24 23:00:06 Actually, IPC_BEGIN_MESSAGE_MAP_WITH_PARAM works.
471
472 bool handled = true;
473 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message)
474 #if defined(OS_MACOSX)
475 // MacOS X creates and populates platform-specific select drop-down menus
476 // whereas other platforms merely create a popup window that the guest
477 // renderer process paints inside.
478 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup)
479 #endif
480 IPC_MESSAGE_UNHANDLED(handled = false)
481 IPC_END_MESSAGE_MAP()
482 render_frame_message_source_ = NULL;
483
484 return handled;
485 #else
486 return false;
487 #endif
488 }
489
465 void BrowserPluginGuest::Attach( 490 void BrowserPluginGuest::Attach(
466 int browser_plugin_instance_id, 491 int browser_plugin_instance_id,
467 WebContentsImpl* embedder_web_contents, 492 WebContentsImpl* embedder_web_contents,
468 const BrowserPluginHostMsg_Attach_Params& params) { 493 const BrowserPluginHostMsg_Attach_Params& params) {
469 if (attached()) 494 if (attached())
470 return; 495 return;
471 496
472 delegate_->WillAttach(embedder_web_contents); 497 delegate_->WillAttach(embedder_web_contents);
473 498
474 // If a RenderView has already been created for this new window, then we need 499 // 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)); 801 browser_plugin_instance_id(), accept));
777 } 802 }
778 803
779 void BrowserPluginGuest::OnSetCursor(const WebCursor& cursor) { 804 void BrowserPluginGuest::OnSetCursor(const WebCursor& cursor) {
780 SendMessageToEmbedder( 805 SendMessageToEmbedder(
781 new BrowserPluginMsg_SetCursor(browser_plugin_instance_id(), cursor)); 806 new BrowserPluginMsg_SetCursor(browser_plugin_instance_id(), cursor));
782 } 807 }
783 808
784 #if defined(OS_MACOSX) 809 #if defined(OS_MACOSX)
785 void BrowserPluginGuest::OnShowPopup( 810 void BrowserPluginGuest::OnShowPopup(
786 const ViewHostMsg_ShowPopup_Params& params) { 811 const FrameHostMsg_ShowPopup_Params& params) {
787 gfx::Rect translated_bounds(params.bounds); 812 gfx::Rect translated_bounds(params.bounds);
788 translated_bounds.Offset(guest_window_rect_.OffsetFromOrigin()); 813 translated_bounds.Offset(guest_window_rect_.OffsetFromOrigin());
789 BrowserPluginPopupMenuHelper popup_menu_helper( 814 BrowserPluginPopupMenuHelper popup_menu_helper(
790 embedder_web_contents_->GetRenderViewHost(), 815 embedder_web_contents_->GetRenderViewHost(),
791 GetWebContents()->GetRenderViewHost()); 816 render_frame_message_source_);
792 popup_menu_helper.ShowPopupMenu(translated_bounds, 817 popup_menu_helper.ShowPopupMenu(translated_bounds,
793 params.item_height, 818 params.item_height,
794 params.item_font_size, 819 params.item_font_size,
795 params.selected_item, 820 params.selected_item,
796 params.popup_items, 821 params.popup_items,
797 params.right_aligned, 822 params.right_aligned,
798 params.allow_multiple_selection); 823 params.allow_multiple_selection);
799 } 824 }
800 #endif 825 #endif
801 826
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 void BrowserPluginGuest::OnImeCompositionRangeChanged( 872 void BrowserPluginGuest::OnImeCompositionRangeChanged(
848 const gfx::Range& range, 873 const gfx::Range& range,
849 const std::vector<gfx::Rect>& character_bounds) { 874 const std::vector<gfx::Rect>& character_bounds) {
850 static_cast<RenderWidgetHostViewBase*>( 875 static_cast<RenderWidgetHostViewBase*>(
851 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( 876 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged(
852 range, character_bounds); 877 range, character_bounds);
853 } 878 }
854 #endif 879 #endif
855 880
856 } // namespace content 881 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698