Chromium Code Reviews| 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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 523 // there we just check whether we've seen any drag status update or | 525 // there we just check whether we've seen any drag status update or |
| 524 // not. | 526 // not. |
| 525 if (last_drag_status_ != blink::WebDragStatusOver && | 527 if (last_drag_status_ != blink::WebDragStatusOver && |
| 526 seen_embedder_drag_source_ended_at_ && seen_embedder_system_drag_ended_) { | 528 seen_embedder_drag_source_ended_at_ && seen_embedder_system_drag_ended_) { |
| 527 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | 529 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( |
| 528 GetWebContents()->GetRenderViewHost()); | 530 GetWebContents()->GetRenderViewHost()); |
| 529 guest_rvh->DragSourceSystemDragEnded(); | 531 guest_rvh->DragSourceSystemDragEnded(); |
| 530 last_drag_status_ = blink::WebDragStatusUnknown; | 532 last_drag_status_ = blink::WebDragStatusUnknown; |
| 531 seen_embedder_system_drag_ended_ = false; | 533 seen_embedder_system_drag_ended_ = false; |
| 532 seen_embedder_drag_source_ended_at_ = false; | 534 seen_embedder_drag_source_ended_at_ = false; |
| 533 dragged_url_ = GURL(); | 535 ignore_dragged_url_ = false; |
| 534 } | 536 } |
| 535 } | 537 } |
| 536 | 538 |
| 537 void BrowserPluginGuest::EmbedderSystemDragEnded() { | 539 void BrowserPluginGuest::EmbedderSystemDragEnded() { |
| 538 seen_embedder_system_drag_ended_ = true; | 540 seen_embedder_system_drag_ended_ = true; |
| 539 EndSystemDragIfApplicable(); | 541 EndSystemDragIfApplicable(); |
| 540 } | 542 } |
| 541 | 543 |
| 542 // TODO(wjmaclean): Replace this approach with ones based on std::function | 544 // TODO(wjmaclean): Replace this approach with ones based on std::function |
| 543 // as in https://codereview.chromium.org/1404353004/ once all Chrome platforms | 545 // as in https://codereview.chromium.org/1404353004/ once all Chrome platforms |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 792 delegate_->DidDetach(); | 794 delegate_->DidDetach(); |
| 793 } | 795 } |
| 794 | 796 |
| 795 void BrowserPluginGuest::OnDragStatusUpdate(int browser_plugin_instance_id, | 797 void BrowserPluginGuest::OnDragStatusUpdate(int browser_plugin_instance_id, |
| 796 blink::WebDragStatus drag_status, | 798 blink::WebDragStatus drag_status, |
| 797 const DropData& drop_data, | 799 const DropData& drop_data, |
| 798 blink::WebDragOperationsMask mask, | 800 blink::WebDragOperationsMask mask, |
| 799 const gfx::Point& location) { | 801 const gfx::Point& location) { |
| 800 RenderViewHost* host = GetWebContents()->GetRenderViewHost(); | 802 RenderViewHost* host = GetWebContents()->GetRenderViewHost(); |
| 801 auto embedder = owner_web_contents_->GetBrowserPluginEmbedder(); | 803 auto embedder = owner_web_contents_->GetBrowserPluginEmbedder(); |
| 804 DropData filtered_data(drop_data); | |
| 805 host->FilterDropData(&filtered_data); | |
| 802 switch (drag_status) { | 806 switch (drag_status) { |
| 803 case blink::WebDragStatusEnter: | 807 case blink::WebDragStatusEnter: |
| 808 host->DragTargetDragEnter(filtered_data, location, location, mask, | |
| 809 drop_data.key_modifiers); | |
| 804 // Only track the URL being dragged over the guest if the link isn't | 810 // Only track the URL being dragged over the guest if the link isn't |
| 805 // coming from the guest. | 811 // coming from the guest. |
| 806 if (!embedder->DragEnteredGuest(this)) | 812 if (!embedder->DragEnteredGuest(this)) { |
| 807 dragged_url_ = drop_data.url; | 813 ignore_dragged_url_ = true; |
| 808 host->DragTargetDragEnter(drop_data, location, location, mask, | 814 } |
| 809 drop_data.key_modifiers); | 815 |
| 810 break; | 816 break; |
| 811 case blink::WebDragStatusOver: | 817 case blink::WebDragStatusOver: |
| 812 host->DragTargetDragOver(location, location, mask, | 818 host->DragTargetDragOver(location, location, mask, |
| 813 drop_data.key_modifiers); | 819 drop_data.key_modifiers); |
| 814 break; | 820 break; |
| 815 case blink::WebDragStatusLeave: | 821 case blink::WebDragStatusLeave: |
| 816 embedder->DragLeftGuest(this); | 822 embedder->DragLeftGuest(this); |
| 817 host->DragTargetDragLeave(); | 823 host->DragTargetDragLeave(); |
| 818 break; | 824 break; |
| 819 case blink::WebDragStatusDrop: | 825 case blink::WebDragStatusDrop: |
| 820 host->DragTargetDrop(location, location, drop_data.key_modifiers); | 826 |
| 821 if (dragged_url_.is_valid()) { | 827 host->DragTargetDrop(filtered_data, location, location, |
| 822 delegate_->DidDropLink(dragged_url_); | 828 drop_data.key_modifiers); |
| 823 dragged_url_ = GURL(); | 829 |
| 830 if (ignore_dragged_url_ && filtered_data.url.is_valid()) { | |
| 831 delegate_->DidDropLink(filtered_data.url); | |
| 832 ignore_dragged_url_ = false; | |
|
lazyboy
2016/06/04 04:52:38
Should setting this to false be outside of/after t
hush (inactive)
2016/06/06 17:42:24
yeah, that's right. Done
| |
| 824 } | 833 } |
| 834 | |
| 825 break; | 835 break; |
| 826 case blink::WebDragStatusUnknown: | 836 case blink::WebDragStatusUnknown: |
| 827 NOTREACHED(); | 837 NOTREACHED(); |
| 828 } | 838 } |
| 829 last_drag_status_ = drag_status; | 839 last_drag_status_ = drag_status; |
| 830 EndSystemDragIfApplicable(); | 840 EndSystemDragIfApplicable(); |
| 831 } | 841 } |
| 832 | 842 |
| 833 void BrowserPluginGuest::OnExecuteEditCommand(int browser_plugin_instance_id, | 843 void BrowserPluginGuest::OnExecuteEditCommand(int browser_plugin_instance_id, |
| 834 const std::string& name) { | 844 const std::string& name) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1007 range, character_bounds); | 1017 range, character_bounds); |
| 1008 } | 1018 } |
| 1009 #endif | 1019 #endif |
| 1010 | 1020 |
| 1011 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { | 1021 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { |
| 1012 if (delegate_) | 1022 if (delegate_) |
| 1013 delegate_->SetContextMenuPosition(position); | 1023 delegate_->SetContextMenuPosition(position); |
| 1014 } | 1024 } |
| 1015 | 1025 |
| 1016 } // namespace content | 1026 } // namespace content |
| OLD | NEW |