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

Side by Side Diff: content/browser/web_contents/web_contents_view_aura.cc

Issue 10377119: Plumb event flags (shift/alt/ctrl modifiers) for drag/drop events to WebKit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed compile error Created 8 years, 7 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/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
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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 drag_dest_delegate_->DragInitialize(web_contents_); 595 drag_dest_delegate_->DragInitialize(web_contents_);
582 596
583 WebDropData drop_data; 597 WebDropData drop_data;
584 PrepareWebDropData(&drop_data, event.data()); 598 PrepareWebDropData(&drop_data, event.data());
585 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); 599 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations());
586 600
587 gfx::Point screen_pt = 601 gfx::Point screen_pt =
588 GetNativeView()->GetRootWindow()->last_mouse_location(); 602 GetNativeView()->GetRootWindow()->last_mouse_location();
589 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); 603 current_rvh_for_drag_ = web_contents_->GetRenderViewHost();
590 web_contents_->GetRenderViewHost()->DragTargetDragEnter( 604 web_contents_->GetRenderViewHost()->DragTargetDragEnter(
591 drop_data, event.location(), screen_pt, op); 605 drop_data, event.location(), screen_pt, op,
606 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags()));
592 607
593 if (drag_dest_delegate_) { 608 if (drag_dest_delegate_) {
594 drag_dest_delegate_->OnReceiveDragData(event.data()); 609 drag_dest_delegate_->OnReceiveDragData(event.data());
595 drag_dest_delegate_->OnDragEnter(); 610 drag_dest_delegate_->OnDragEnter();
596 } 611 }
597 } 612 }
598 613
599 int WebContentsViewAura::OnDragUpdated(const aura::DropTargetEvent& event) { 614 int WebContentsViewAura::OnDragUpdated(const aura::DropTargetEvent& event) {
600 DCHECK(current_rvh_for_drag_); 615 DCHECK(current_rvh_for_drag_);
601 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) 616 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost())
602 OnDragEntered(event); 617 OnDragEntered(event);
603 618
604 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); 619 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations());
605 gfx::Point screen_pt = 620 gfx::Point screen_pt =
606 GetNativeView()->GetRootWindow()->last_mouse_location(); 621 GetNativeView()->GetRootWindow()->last_mouse_location();
607 web_contents_->GetRenderViewHost()->DragTargetDragOver( 622 web_contents_->GetRenderViewHost()->DragTargetDragOver(
608 event.location(), screen_pt, op); 623 event.location(), screen_pt, op,
624 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags()));
609 625
610 if (drag_dest_delegate_) 626 if (drag_dest_delegate_)
611 drag_dest_delegate_->OnDragOver(); 627 drag_dest_delegate_->OnDragOver();
612 628
613 return ConvertFromWeb(current_drag_op_); 629 return ConvertFromWeb(current_drag_op_);
614 } 630 }
615 631
616 void WebContentsViewAura::OnDragExited() { 632 void WebContentsViewAura::OnDragExited() {
617 DCHECK(current_rvh_for_drag_); 633 DCHECK(current_rvh_for_drag_);
618 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) 634 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost())
619 return; 635 return;
620 636
621 web_contents_->GetRenderViewHost()->DragTargetDragLeave(); 637 web_contents_->GetRenderViewHost()->DragTargetDragLeave();
622 if (drag_dest_delegate_) 638 if (drag_dest_delegate_)
623 drag_dest_delegate_->OnDragLeave(); 639 drag_dest_delegate_->OnDragLeave();
624 } 640 }
625 641
626 int WebContentsViewAura::OnPerformDrop(const aura::DropTargetEvent& event) { 642 int WebContentsViewAura::OnPerformDrop(const aura::DropTargetEvent& event) {
627 DCHECK(current_rvh_for_drag_); 643 DCHECK(current_rvh_for_drag_);
628 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) 644 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost())
629 OnDragEntered(event); 645 OnDragEntered(event);
630 646
631 web_contents_->GetRenderViewHost()->DragTargetDrop( 647 web_contents_->GetRenderViewHost()->DragTargetDrop(
632 event.location(), 648 event.location(),
633 GetNativeView()->GetRootWindow()->last_mouse_location()); 649 GetNativeView()->GetRootWindow()->last_mouse_location(),
650 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags()));
634 if (drag_dest_delegate_) 651 if (drag_dest_delegate_)
635 drag_dest_delegate_->OnDrop(); 652 drag_dest_delegate_->OnDrop();
636 return current_drag_op_; 653 return current_drag_op_;
637 } 654 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_unittest.cc ('k') | content/browser/web_contents/web_drag_dest_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698