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

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: 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 = web_input_event_modifiers |
173 WebKit::WebInputEvent::ShiftKey;
174 }
175 if (aura_event_flags & ui::EF_CONTROL_DOWN) {
176 web_input_event_modifiers = web_input_event_modifiers |
177 WebKit::WebInputEvent::ControlKey;
178 }
179 if (aura_event_flags & ui::EF_ALT_DOWN) {
180 web_input_event_modifiers = web_input_event_modifiers |
181 WebKit::WebInputEvent::AltKey;
182 }
183 if (aura_event_flags & ui::EF_COMMAND_DOWN) {
184 web_input_event_modifiers = web_input_event_modifiers |
185 WebKit::WebInputEvent::MetaKey;
186 }
187 return web_input_event_modifiers;
188 }
189
168 } // namespace 190 } // namespace
169 191
170 192
171 //////////////////////////////////////////////////////////////////////////////// 193 ////////////////////////////////////////////////////////////////////////////////
172 // WebContentsViewAura, public: 194 // WebContentsViewAura, public:
173 195
174 WebContentsViewAura::WebContentsViewAura( 196 WebContentsViewAura::WebContentsViewAura(
175 WebContentsImpl* web_contents, 197 WebContentsImpl* web_contents,
176 content::WebContentsViewDelegate* delegate) 198 content::WebContentsViewDelegate* delegate)
177 : web_contents_(web_contents), 199 : web_contents_(web_contents),
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 if (drag_dest_delegate_) 599 if (drag_dest_delegate_)
578 drag_dest_delegate_->DragInitialize(web_contents_); 600 drag_dest_delegate_->DragInitialize(web_contents_);
579 601
580 WebDropData drop_data; 602 WebDropData drop_data;
581 PrepareWebDropData(&drop_data, event.data()); 603 PrepareWebDropData(&drop_data, event.data());
582 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); 604 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations());
583 605
584 gfx::Point screen_pt = 606 gfx::Point screen_pt =
585 GetNativeView()->GetRootWindow()->last_mouse_location(); 607 GetNativeView()->GetRootWindow()->last_mouse_location();
586 web_contents_->GetRenderViewHost()->DragTargetDragEnter( 608 web_contents_->GetRenderViewHost()->DragTargetDragEnter(
587 drop_data, event.location(), screen_pt, op); 609 drop_data, event.location(), screen_pt, op,
610 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags()));
588 611
589 if (drag_dest_delegate_) { 612 if (drag_dest_delegate_) {
590 drag_dest_delegate_->OnReceiveDragData(event.data()); 613 drag_dest_delegate_->OnReceiveDragData(event.data());
591 drag_dest_delegate_->OnDragEnter(); 614 drag_dest_delegate_->OnDragEnter();
592 } 615 }
593 } 616 }
594 617
595 int WebContentsViewAura::OnDragUpdated(const aura::DropTargetEvent& event) { 618 int WebContentsViewAura::OnDragUpdated(const aura::DropTargetEvent& event) {
596 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); 619 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations());
597 gfx::Point screen_pt = 620 gfx::Point screen_pt =
598 GetNativeView()->GetRootWindow()->last_mouse_location(); 621 GetNativeView()->GetRootWindow()->last_mouse_location();
599 web_contents_->GetRenderViewHost()->DragTargetDragOver( 622 web_contents_->GetRenderViewHost()->DragTargetDragOver(
600 event.location(), screen_pt, op); 623 event.location(), screen_pt, op,
624 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags()));
601 625
602 if (drag_dest_delegate_) 626 if (drag_dest_delegate_)
603 drag_dest_delegate_->OnDragOver(); 627 drag_dest_delegate_->OnDragOver();
604 628
605 return ConvertFromWeb(current_drag_op_); 629 return ConvertFromWeb(current_drag_op_);
606 } 630 }
607 631
608 void WebContentsViewAura::OnDragExited() { 632 void WebContentsViewAura::OnDragExited() {
609 web_contents_->GetRenderViewHost()->DragTargetDragLeave(); 633 web_contents_->GetRenderViewHost()->DragTargetDragLeave();
610 if (drag_dest_delegate_) 634 if (drag_dest_delegate_)
611 drag_dest_delegate_->OnDragLeave(); 635 drag_dest_delegate_->OnDragLeave();
612 } 636 }
613 637
614 int WebContentsViewAura::OnPerformDrop(const aura::DropTargetEvent& event) { 638 int WebContentsViewAura::OnPerformDrop(const aura::DropTargetEvent& event) {
615 web_contents_->GetRenderViewHost()->DragTargetDrop( 639 web_contents_->GetRenderViewHost()->DragTargetDrop(
616 event.location(), 640 event.location(),
617 GetNativeView()->GetRootWindow()->last_mouse_location()); 641 GetNativeView()->GetRootWindow()->last_mouse_location(),
642 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags()));
618 if (drag_dest_delegate_) 643 if (drag_dest_delegate_)
619 drag_dest_delegate_->OnDrop(); 644 drag_dest_delegate_->OnDrop();
620 return current_drag_op_; 645 return current_drag_op_;
621 } 646 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698