OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 29 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
30 #include "content/browser/web_contents/web_contents_impl.h" | 30 #include "content/browser/web_contents/web_contents_impl.h" |
31 #include "content/browser/web_contents/web_contents_view_guest.h" | 31 #include "content/browser/web_contents/web_contents_view_guest.h" |
32 #include "content/common/browser_plugin/browser_plugin_constants.h" | 32 #include "content/common/browser_plugin/browser_plugin_constants.h" |
33 #include "content/common/browser_plugin/browser_plugin_messages.h" | 33 #include "content/common/browser_plugin/browser_plugin_messages.h" |
34 #include "content/common/content_constants_internal.h" | 34 #include "content/common/content_constants_internal.h" |
35 #include "content/common/drag_messages.h" | 35 #include "content/common/drag_messages.h" |
36 #include "content/common/host_shared_bitmap_manager.h" | 36 #include "content/common/host_shared_bitmap_manager.h" |
37 #include "content/common/input_messages.h" | 37 #include "content/common/input_messages.h" |
38 #include "content/common/site_isolation_policy.h" | 38 #include "content/common/site_isolation_policy.h" |
39 #include "content/common/text_input_state.h" | |
40 #include "content/common/view_messages.h" | 39 #include "content/common/view_messages.h" |
41 #include "content/public/browser/browser_context.h" | 40 #include "content/public/browser/browser_context.h" |
42 #include "content/public/browser/browser_plugin_guest_manager.h" | 41 #include "content/public/browser/browser_plugin_guest_manager.h" |
43 #include "content/public/browser/content_browser_client.h" | 42 #include "content/public/browser/content_browser_client.h" |
44 #include "content/public/browser/guest_host.h" | 43 #include "content/public/browser/guest_host.h" |
45 #include "content/public/browser/render_widget_host_view.h" | 44 #include "content/public/browser/render_widget_host_view.h" |
46 #include "content/public/browser/user_metrics.h" | 45 #include "content/public/browser/user_metrics.h" |
47 #include "content/public/browser/web_contents_observer.h" | 46 #include "content/public/browser/web_contents_observer.h" |
48 #include "content/public/common/browser_plugin_guest_mode.h" | 47 #include "content/public/common/browser_plugin_guest_mode.h" |
49 #include "content/public/common/drop_data.h" | 48 #include "content/public/common/drop_data.h" |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 rwhv->RegisterSurfaceNamespaceId(); | 769 rwhv->RegisterSurfaceNamespaceId(); |
771 has_render_view_ = true; | 770 has_render_view_ = true; |
772 | 771 |
773 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); | 772 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); |
774 } | 773 } |
775 | 774 |
776 void BrowserPluginGuest::OnDetach(int browser_plugin_instance_id) { | 775 void BrowserPluginGuest::OnDetach(int browser_plugin_instance_id) { |
777 if (!attached()) | 776 if (!attached()) |
778 return; | 777 return; |
779 | 778 |
780 // The BrowserPluginGuest loses the link to |owner_web_contents_|. Therefore, | |
781 // the RenderWidgetHostViewGuest will not get a chance to update its text | |
782 // input state which is tracked by |owner_web_contents_|. | |
783 // TODO(ekaramad): We should perform detaching through WebContentsImpl ( | |
784 // inner WebContents detaching from outer WebContents). After this is fixed, | |
785 // we can remove this call to OnTextInputStateChanged (crbug.com/602640). | |
786 OnTextInputStateChanged(TextInputState()); | |
787 | |
788 // This tells BrowserPluginGuest to queue up all IPCs to BrowserPlugin until | 779 // This tells BrowserPluginGuest to queue up all IPCs to BrowserPlugin until |
789 // it's attached again. | 780 // it's attached again. |
790 attached_ = false; | 781 attached_ = false; |
791 | 782 |
792 RenderWidgetHostViewChildFrame* rwhv = | 783 RenderWidgetHostViewChildFrame* rwhv = |
793 static_cast<RenderWidgetHostViewChildFrame*>( | 784 static_cast<RenderWidgetHostViewChildFrame*>( |
794 web_contents()->GetRenderWidgetHostView()); | 785 web_contents()->GetRenderWidgetHostView()); |
795 // If the guest is terminated, our host may already be gone. | 786 // If the guest is terminated, our host may already be gone. |
796 if (rwhv) | 787 if (rwhv) |
797 rwhv->UnregisterSurfaceNamespaceId(); | 788 rwhv->UnregisterSurfaceNamespaceId(); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 void BrowserPluginGuest::OnShowWidget(int route_id, | 972 void BrowserPluginGuest::OnShowWidget(int route_id, |
982 const gfx::Rect& initial_rect) { | 973 const gfx::Rect& initial_rect) { |
983 GetWebContents()->ShowCreatedWidget(route_id, initial_rect); | 974 GetWebContents()->ShowCreatedWidget(route_id, initial_rect); |
984 } | 975 } |
985 | 976 |
986 void BrowserPluginGuest::OnTakeFocus(bool reverse) { | 977 void BrowserPluginGuest::OnTakeFocus(bool reverse) { |
987 SendMessageToEmbedder( | 978 SendMessageToEmbedder( |
988 new BrowserPluginMsg_AdvanceFocus(browser_plugin_instance_id(), reverse)); | 979 new BrowserPluginMsg_AdvanceFocus(browser_plugin_instance_id(), reverse)); |
989 } | 980 } |
990 | 981 |
991 void BrowserPluginGuest::OnTextInputStateChanged(const TextInputState& params) { | 982 void BrowserPluginGuest::OnTextInputStateChanged( |
| 983 const ViewHostMsg_TextInputState_Params& params) { |
992 // Save the state of text input so we can restore it on focus. | 984 // Save the state of text input so we can restore it on focus. |
993 last_text_input_state_.reset(new TextInputState(params)); | 985 last_text_input_state_.reset(new ViewHostMsg_TextInputState_Params(params)); |
994 | 986 |
995 SendTextInputTypeChangedToView( | 987 SendTextInputTypeChangedToView( |
996 static_cast<RenderWidgetHostViewBase*>( | 988 static_cast<RenderWidgetHostViewBase*>( |
997 web_contents()->GetRenderWidgetHostView())); | 989 web_contents()->GetRenderWidgetHostView())); |
998 } | 990 } |
999 | 991 |
1000 void BrowserPluginGuest::OnImeCancelComposition() { | 992 void BrowserPluginGuest::OnImeCancelComposition() { |
1001 static_cast<RenderWidgetHostViewBase*>( | 993 static_cast<RenderWidgetHostViewBase*>( |
1002 web_contents()->GetRenderWidgetHostView())->ImeCancelComposition(); | 994 web_contents()->GetRenderWidgetHostView())->ImeCancelComposition(); |
1003 } | 995 } |
1004 | 996 |
1005 #if defined(OS_MACOSX) || defined(USE_AURA) | 997 #if defined(OS_MACOSX) || defined(USE_AURA) |
1006 void BrowserPluginGuest::OnImeCompositionRangeChanged( | 998 void BrowserPluginGuest::OnImeCompositionRangeChanged( |
1007 const gfx::Range& range, | 999 const gfx::Range& range, |
1008 const std::vector<gfx::Rect>& character_bounds) { | 1000 const std::vector<gfx::Rect>& character_bounds) { |
1009 static_cast<RenderWidgetHostViewBase*>( | 1001 static_cast<RenderWidgetHostViewBase*>( |
1010 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( | 1002 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( |
1011 range, character_bounds); | 1003 range, character_bounds); |
1012 } | 1004 } |
1013 #endif | 1005 #endif |
1014 | 1006 |
1015 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { | 1007 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { |
1016 if (delegate_) | 1008 if (delegate_) |
1017 delegate_->SetContextMenuPosition(position); | 1009 delegate_->SetContextMenuPosition(position); |
1018 } | 1010 } |
1019 | 1011 |
1020 } // namespace content | 1012 } // namespace content |
OLD | NEW |