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 24 matching lines...) Expand all Loading... |
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" | 39 #include "content/common/text_input_state.h" |
40 #include "content/common/view_messages.h" | 40 #include "content/common/view_messages.h" |
41 #include "content/public/browser/browser_context.h" | 41 #include "content/public/browser/browser_context.h" |
42 #include "content/public/browser/browser_plugin_guest_manager.h" | 42 #include "content/public/browser/browser_plugin_guest_manager.h" |
43 #include "content/public/browser/content_browser_client.h" | 43 #include "content/public/browser/content_browser_client.h" |
44 #include "content/public/browser/guest_host.h" | 44 #include "content/public/browser/guest_host.h" |
| 45 #include "content/public/browser/render_process_host.h" |
45 #include "content/public/browser/render_widget_host_view.h" | 46 #include "content/public/browser/render_widget_host_view.h" |
46 #include "content/public/browser/user_metrics.h" | 47 #include "content/public/browser/user_metrics.h" |
47 #include "content/public/browser/web_contents_observer.h" | 48 #include "content/public/browser/web_contents_observer.h" |
48 #include "content/public/common/browser_plugin_guest_mode.h" | 49 #include "content/public/common/browser_plugin_guest_mode.h" |
49 #include "content/public/common/drop_data.h" | 50 #include "content/public/common/drop_data.h" |
50 #include "ui/gfx/geometry/size_conversions.h" | 51 #include "ui/gfx/geometry/size_conversions.h" |
51 | 52 |
52 #if defined(OS_MACOSX) | 53 #if defined(OS_MACOSX) |
53 #include "content/browser/browser_plugin/browser_plugin_popup_menu_helper_mac.h" | 54 #include "content/browser/browser_plugin/browser_plugin_popup_menu_helper_mac.h" |
54 #include "content/common/frame_messages.h" | 55 #include "content/common/frame_messages.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 guest_visible_(false), | 96 guest_visible_(false), |
96 embedder_visible_(true), | 97 embedder_visible_(true), |
97 is_full_page_plugin_(false), | 98 is_full_page_plugin_(false), |
98 has_render_view_(has_render_view), | 99 has_render_view_(has_render_view), |
99 is_in_destruction_(false), | 100 is_in_destruction_(false), |
100 initialized_(false), | 101 initialized_(false), |
101 guest_proxy_routing_id_(MSG_ROUTING_NONE), | 102 guest_proxy_routing_id_(MSG_ROUTING_NONE), |
102 last_drag_status_(blink::WebDragStatusUnknown), | 103 last_drag_status_(blink::WebDragStatusUnknown), |
103 seen_embedder_system_drag_ended_(false), | 104 seen_embedder_system_drag_ended_(false), |
104 seen_embedder_drag_source_ended_at_(false), | 105 seen_embedder_drag_source_ended_at_(false), |
| 106 ignore_dragged_url_(false), |
105 delegate_(delegate), | 107 delegate_(delegate), |
106 weak_ptr_factory_(this) { | 108 weak_ptr_factory_(this) { |
107 DCHECK(web_contents); | 109 DCHECK(web_contents); |
108 DCHECK(delegate); | 110 DCHECK(delegate); |
109 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); | 111 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); |
110 web_contents->SetBrowserPluginGuest(this); | 112 web_contents->SetBrowserPluginGuest(this); |
111 delegate->SetGuestHost(this); | 113 delegate->SetGuestHost(this); |
112 } | 114 } |
113 | 115 |
114 int BrowserPluginGuest::GetGuestProxyRoutingID() { | 116 int BrowserPluginGuest::GetGuestProxyRoutingID() { |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 // there we just check whether we've seen any drag status update or | 528 // there we just check whether we've seen any drag status update or |
527 // not. | 529 // not. |
528 if (last_drag_status_ != blink::WebDragStatusOver && | 530 if (last_drag_status_ != blink::WebDragStatusOver && |
529 seen_embedder_drag_source_ended_at_ && seen_embedder_system_drag_ended_) { | 531 seen_embedder_drag_source_ended_at_ && seen_embedder_system_drag_ended_) { |
530 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | 532 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( |
531 GetWebContents()->GetRenderViewHost()); | 533 GetWebContents()->GetRenderViewHost()); |
532 guest_rvh->DragSourceSystemDragEnded(); | 534 guest_rvh->DragSourceSystemDragEnded(); |
533 last_drag_status_ = blink::WebDragStatusUnknown; | 535 last_drag_status_ = blink::WebDragStatusUnknown; |
534 seen_embedder_system_drag_ended_ = false; | 536 seen_embedder_system_drag_ended_ = false; |
535 seen_embedder_drag_source_ended_at_ = false; | 537 seen_embedder_drag_source_ended_at_ = false; |
536 dragged_url_ = GURL(); | 538 ignore_dragged_url_ = false; |
537 } | 539 } |
538 } | 540 } |
539 | 541 |
540 void BrowserPluginGuest::EmbedderSystemDragEnded() { | 542 void BrowserPluginGuest::EmbedderSystemDragEnded() { |
541 seen_embedder_system_drag_ended_ = true; | 543 seen_embedder_system_drag_ended_ = true; |
542 EndSystemDragIfApplicable(); | 544 EndSystemDragIfApplicable(); |
543 } | 545 } |
544 | 546 |
545 // TODO(wjmaclean): Replace this approach with ones based on std::function | 547 // TODO(wjmaclean): Replace this approach with ones based on std::function |
546 // as in https://codereview.chromium.org/1404353004/ once all Chrome platforms | 548 // as in https://codereview.chromium.org/1404353004/ once all Chrome platforms |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 delegate_->DidDetach(); | 797 delegate_->DidDetach(); |
796 } | 798 } |
797 | 799 |
798 void BrowserPluginGuest::OnDragStatusUpdate(int browser_plugin_instance_id, | 800 void BrowserPluginGuest::OnDragStatusUpdate(int browser_plugin_instance_id, |
799 blink::WebDragStatus drag_status, | 801 blink::WebDragStatus drag_status, |
800 const DropData& drop_data, | 802 const DropData& drop_data, |
801 blink::WebDragOperationsMask mask, | 803 blink::WebDragOperationsMask mask, |
802 const gfx::Point& location) { | 804 const gfx::Point& location) { |
803 RenderViewHost* host = GetWebContents()->GetRenderViewHost(); | 805 RenderViewHost* host = GetWebContents()->GetRenderViewHost(); |
804 auto embedder = owner_web_contents_->GetBrowserPluginEmbedder(); | 806 auto embedder = owner_web_contents_->GetBrowserPluginEmbedder(); |
| 807 DropData filtered_data(drop_data); |
| 808 host->FilterDropData(&filtered_data); |
805 switch (drag_status) { | 809 switch (drag_status) { |
806 case blink::WebDragStatusEnter: | 810 case blink::WebDragStatusEnter: |
| 811 host->DragTargetDragEnter(filtered_data, location, location, mask, |
| 812 drop_data.key_modifiers); |
807 // Only track the URL being dragged over the guest if the link isn't | 813 // Only track the URL being dragged over the guest if the link isn't |
808 // coming from the guest. | 814 // coming from the guest. |
809 if (!embedder->DragEnteredGuest(this)) | 815 if (!embedder->DragEnteredGuest(this)) |
810 dragged_url_ = drop_data.url; | 816 ignore_dragged_url_ = true; |
811 host->DragTargetDragEnter(drop_data, location, location, mask, | |
812 drop_data.key_modifiers); | |
813 break; | 817 break; |
814 case blink::WebDragStatusOver: | 818 case blink::WebDragStatusOver: |
815 host->DragTargetDragOver(location, location, mask, | 819 host->DragTargetDragOver(location, location, mask, |
816 drop_data.key_modifiers); | 820 drop_data.key_modifiers); |
817 break; | 821 break; |
818 case blink::WebDragStatusLeave: | 822 case blink::WebDragStatusLeave: |
819 embedder->DragLeftGuest(this); | 823 embedder->DragLeftGuest(this); |
820 host->DragTargetDragLeave(); | 824 host->DragTargetDragLeave(); |
| 825 ignore_dragged_url_ = false; |
821 break; | 826 break; |
822 case blink::WebDragStatusDrop: | 827 case blink::WebDragStatusDrop: |
823 host->DragTargetDrop(location, location, drop_data.key_modifiers); | 828 host->DragTargetDrop(filtered_data, location, location, |
824 if (dragged_url_.is_valid()) { | 829 drop_data.key_modifiers); |
825 delegate_->DidDropLink(dragged_url_); | 830 |
826 dragged_url_ = GURL(); | 831 if (ignore_dragged_url_ && filtered_data.url.is_valid()) |
827 } | 832 delegate_->DidDropLink(filtered_data.url); |
| 833 ignore_dragged_url_ = false; |
828 break; | 834 break; |
829 case blink::WebDragStatusUnknown: | 835 case blink::WebDragStatusUnknown: |
| 836 ignore_dragged_url_ = false; |
830 NOTREACHED(); | 837 NOTREACHED(); |
831 } | 838 } |
832 last_drag_status_ = drag_status; | 839 last_drag_status_ = drag_status; |
833 EndSystemDragIfApplicable(); | 840 EndSystemDragIfApplicable(); |
834 } | 841 } |
835 | 842 |
836 void BrowserPluginGuest::OnExecuteEditCommand(int browser_plugin_instance_id, | 843 void BrowserPluginGuest::OnExecuteEditCommand(int browser_plugin_instance_id, |
837 const std::string& name) { | 844 const std::string& name) { |
838 RenderFrameHost* focused_frame = web_contents()->GetFocusedFrame(); | 845 RenderFrameHost* focused_frame = web_contents()->GetFocusedFrame(); |
839 if (!focused_frame) | 846 if (!focused_frame) |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 range, character_bounds); | 1017 range, character_bounds); |
1011 } | 1018 } |
1012 #endif | 1019 #endif |
1013 | 1020 |
1014 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { | 1021 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { |
1015 if (delegate_) | 1022 if (delegate_) |
1016 delegate_->SetContextMenuPosition(position); | 1023 delegate_->SetContextMenuPosition(position); |
1017 } | 1024 } |
1018 | 1025 |
1019 } // namespace content | 1026 } // namespace content |
OLD | NEW |