| 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/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "content/browser/renderer_host/render_view_host_factory.h" | 8 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 9 #include "content/browser/web_contents/interstitial_page_impl.h" | 9 #include "content/browser/web_contents/interstitial_page_impl.h" |
| 10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
| 11 #include "content/public/browser/render_view_host.h" | 11 #include "content/public/browser/render_view_host.h" |
| 12 #include "content/public/browser/render_widget_host.h" | 12 #include "content/public/browser/render_widget_host.h" |
| 13 #include "content/public/browser/render_widget_host_view.h" | 13 #include "content/public/browser/render_widget_host_view.h" |
| 14 #include "content/public/browser/web_contents_delegate.h" | 14 #include "content/public/browser/web_contents_delegate.h" |
| 15 #include "content/public/browser/web_contents_view_delegate.h" | 15 #include "content/public/browser/web_contents_view_delegate.h" |
| 16 #include "content/public/browser/web_drag_dest_delegate.h" | 16 #include "content/public/browser/web_drag_dest_delegate.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 17 #include "ui/aura/client/drag_drop_client.h" | 18 #include "ui/aura/client/drag_drop_client.h" |
| 18 #include "ui/aura/client/drag_drop_delegate.h" | 19 #include "ui/aura/client/drag_drop_delegate.h" |
| 19 #include "ui/aura/event.h" | 20 #include "ui/aura/event.h" |
| 20 #include "ui/aura/root_window.h" | 21 #include "ui/aura/root_window.h" |
| 21 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
| 22 #include "ui/base/clipboard/custom_data_helper.h" | 23 #include "ui/base/clipboard/custom_data_helper.h" |
| 23 #include "ui/base/dragdrop/drag_drop_types.h" | 24 #include "ui/base/dragdrop/drag_drop_types.h" |
| 24 #include "ui/base/dragdrop/os_exchange_data.h" | 25 #include "ui/base/dragdrop/os_exchange_data.h" |
| 25 #include "ui/base/dragdrop/os_exchange_data_provider_aura.h" | 26 #include "ui/base/dragdrop/os_exchange_data_provider_aura.h" |
| 26 #include "ui/base/hit_test.h" | 27 #include "ui/base/hit_test.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 int web_drag_op = WebKit::WebDragOperationNone; | 159 int web_drag_op = WebKit::WebDragOperationNone; |
| 159 if (drag_op & ui::DragDropTypes::DRAG_COPY) | 160 if (drag_op & ui::DragDropTypes::DRAG_COPY) |
| 160 web_drag_op |= WebKit::WebDragOperationCopy; | 161 web_drag_op |= WebKit::WebDragOperationCopy; |
| 161 if (drag_op & ui::DragDropTypes::DRAG_MOVE) | 162 if (drag_op & ui::DragDropTypes::DRAG_MOVE) |
| 162 web_drag_op |= WebKit::WebDragOperationMove; | 163 web_drag_op |= WebKit::WebDragOperationMove; |
| 163 if (drag_op & ui::DragDropTypes::DRAG_LINK) | 164 if (drag_op & ui::DragDropTypes::DRAG_LINK) |
| 164 web_drag_op |= WebKit::WebDragOperationLink; | 165 web_drag_op |= WebKit::WebDragOperationLink; |
| 165 return (WebKit::WebDragOperationsMask) web_drag_op; | 166 return (WebKit::WebDragOperationsMask) web_drag_op; |
| 166 } | 167 } |
| 167 | 168 |
| 169 int ConvertAuraEventFlagsToWebInputEventModifiers(int aura_event_flags) { |
| 170 int web_input_event_modifiers = 0; |
| 171 if (aura_event_flags & ui::EF_SHIFT_DOWN) |
| 172 web_input_event_modifiers |= WebKit::WebInputEvent::ShiftKey; |
| 173 if (aura_event_flags & ui::EF_CONTROL_DOWN) |
| 174 web_input_event_modifiers |= WebKit::WebInputEvent::ControlKey; |
| 175 if (aura_event_flags & ui::EF_ALT_DOWN) |
| 176 web_input_event_modifiers |= WebKit::WebInputEvent::AltKey; |
| 177 if (aura_event_flags & ui::EF_COMMAND_DOWN) |
| 178 web_input_event_modifiers |= WebKit::WebInputEvent::MetaKey; |
| 179 return web_input_event_modifiers; |
| 180 } |
| 181 |
| 168 } // namespace | 182 } // namespace |
| 169 | 183 |
| 170 | 184 |
| 171 //////////////////////////////////////////////////////////////////////////////// | 185 //////////////////////////////////////////////////////////////////////////////// |
| 172 // WebContentsViewAura, public: | 186 // WebContentsViewAura, public: |
| 173 | 187 |
| 174 WebContentsViewAura::WebContentsViewAura( | 188 WebContentsViewAura::WebContentsViewAura( |
| 175 WebContentsImpl* web_contents, | 189 WebContentsImpl* web_contents, |
| 176 content::WebContentsViewDelegate* delegate) | 190 content::WebContentsViewDelegate* delegate) |
| 177 : web_contents_(web_contents), | 191 : web_contents_(web_contents), |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 drag_dest_delegate_->DragInitialize(web_contents_); | 593 drag_dest_delegate_->DragInitialize(web_contents_); |
| 580 | 594 |
| 581 WebDropData drop_data; | 595 WebDropData drop_data; |
| 582 PrepareWebDropData(&drop_data, event.data()); | 596 PrepareWebDropData(&drop_data, event.data()); |
| 583 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 597 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
| 584 | 598 |
| 585 gfx::Point screen_pt = | 599 gfx::Point screen_pt = |
| 586 GetNativeView()->GetRootWindow()->last_mouse_location(); | 600 GetNativeView()->GetRootWindow()->last_mouse_location(); |
| 587 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); | 601 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); |
| 588 web_contents_->GetRenderViewHost()->DragTargetDragEnter( | 602 web_contents_->GetRenderViewHost()->DragTargetDragEnter( |
| 589 drop_data, event.location(), screen_pt, op); | 603 drop_data, event.location(), screen_pt, op, |
| 604 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 590 | 605 |
| 591 if (drag_dest_delegate_) { | 606 if (drag_dest_delegate_) { |
| 592 drag_dest_delegate_->OnReceiveDragData(event.data()); | 607 drag_dest_delegate_->OnReceiveDragData(event.data()); |
| 593 drag_dest_delegate_->OnDragEnter(); | 608 drag_dest_delegate_->OnDragEnter(); |
| 594 } | 609 } |
| 595 } | 610 } |
| 596 | 611 |
| 597 int WebContentsViewAura::OnDragUpdated(const aura::DropTargetEvent& event) { | 612 int WebContentsViewAura::OnDragUpdated(const aura::DropTargetEvent& event) { |
| 598 DCHECK(current_rvh_for_drag_); | 613 DCHECK(current_rvh_for_drag_); |
| 599 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) | 614 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) |
| 600 OnDragEntered(event); | 615 OnDragEntered(event); |
| 601 | 616 |
| 602 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 617 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
| 603 gfx::Point screen_pt = | 618 gfx::Point screen_pt = |
| 604 GetNativeView()->GetRootWindow()->last_mouse_location(); | 619 GetNativeView()->GetRootWindow()->last_mouse_location(); |
| 605 web_contents_->GetRenderViewHost()->DragTargetDragOver( | 620 web_contents_->GetRenderViewHost()->DragTargetDragOver( |
| 606 event.location(), screen_pt, op); | 621 event.location(), screen_pt, op, |
| 622 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 607 | 623 |
| 608 if (drag_dest_delegate_) | 624 if (drag_dest_delegate_) |
| 609 drag_dest_delegate_->OnDragOver(); | 625 drag_dest_delegate_->OnDragOver(); |
| 610 | 626 |
| 611 return ConvertFromWeb(current_drag_op_); | 627 return ConvertFromWeb(current_drag_op_); |
| 612 } | 628 } |
| 613 | 629 |
| 614 void WebContentsViewAura::OnDragExited() { | 630 void WebContentsViewAura::OnDragExited() { |
| 615 DCHECK(current_rvh_for_drag_); | 631 DCHECK(current_rvh_for_drag_); |
| 616 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) | 632 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) |
| 617 return; | 633 return; |
| 618 | 634 |
| 619 web_contents_->GetRenderViewHost()->DragTargetDragLeave(); | 635 web_contents_->GetRenderViewHost()->DragTargetDragLeave(); |
| 620 if (drag_dest_delegate_) | 636 if (drag_dest_delegate_) |
| 621 drag_dest_delegate_->OnDragLeave(); | 637 drag_dest_delegate_->OnDragLeave(); |
| 622 } | 638 } |
| 623 | 639 |
| 624 int WebContentsViewAura::OnPerformDrop(const aura::DropTargetEvent& event) { | 640 int WebContentsViewAura::OnPerformDrop(const aura::DropTargetEvent& event) { |
| 625 DCHECK(current_rvh_for_drag_); | 641 DCHECK(current_rvh_for_drag_); |
| 626 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) | 642 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) |
| 627 OnDragEntered(event); | 643 OnDragEntered(event); |
| 628 | 644 |
| 629 web_contents_->GetRenderViewHost()->DragTargetDrop( | 645 web_contents_->GetRenderViewHost()->DragTargetDrop( |
| 630 event.location(), | 646 event.location(), |
| 631 GetNativeView()->GetRootWindow()->last_mouse_location()); | 647 GetNativeView()->GetRootWindow()->last_mouse_location(), |
| 648 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 632 if (drag_dest_delegate_) | 649 if (drag_dest_delegate_) |
| 633 drag_dest_delegate_->OnDrop(); | 650 drag_dest_delegate_->OnDrop(); |
| 634 return current_drag_op_; | 651 return current_drag_op_; |
| 635 } | 652 } |
| OLD | NEW |