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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 } | 1035 } |
1036 | 1036 |
1037 //////////////////////////////////////////////////////////////////////////////// | 1037 //////////////////////////////////////////////////////////////////////////////// |
1038 // WebContentsViewAura, aura::client::DragDropDelegate implementation: | 1038 // WebContentsViewAura, aura::client::DragDropDelegate implementation: |
1039 | 1039 |
1040 void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) { | 1040 void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) { |
1041 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); | 1041 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); |
1042 current_drop_data_.reset(new DropData()); | 1042 current_drop_data_.reset(new DropData()); |
1043 | 1043 |
1044 PrepareDropData(current_drop_data_.get(), event.data()); | 1044 PrepareDropData(current_drop_data_.get(), event.data()); |
| 1045 |
| 1046 web_contents_->GetRenderViewHost()->FilterDropData(current_drop_data_.get()); |
| 1047 |
1045 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 1048 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
1046 | 1049 |
1047 // Give the delegate an opportunity to cancel the drag. | 1050 // Give the delegate an opportunity to cancel the drag. |
1048 if (web_contents_->GetDelegate() && | 1051 if (web_contents_->GetDelegate() && |
1049 !web_contents_->GetDelegate()->CanDragEnter( | 1052 !web_contents_->GetDelegate()->CanDragEnter( |
1050 web_contents_, *current_drop_data_.get(), op)) { | 1053 web_contents_, *current_drop_data_.get(), op)) { |
1051 current_drop_data_.reset(NULL); | 1054 current_drop_data_.reset(NULL); |
1052 return; | 1055 return; |
1053 } | 1056 } |
1054 | 1057 |
1055 if (drag_dest_delegate_) | 1058 if (drag_dest_delegate_) |
1056 drag_dest_delegate_->DragInitialize(web_contents_); | 1059 drag_dest_delegate_->DragInitialize(web_contents_); |
1057 | 1060 |
1058 gfx::Point screen_pt = display::Screen::GetScreen()->GetCursorScreenPoint(); | 1061 gfx::Point screen_pt = display::Screen::GetScreen()->GetCursorScreenPoint(); |
1059 web_contents_->GetRenderViewHost()->DragTargetDragEnter( | 1062 web_contents_->GetRenderViewHost()->DragTargetDragEnter( |
1060 *current_drop_data_.get(), event.location(), screen_pt, op, | 1063 *current_drop_data_, event.location(), screen_pt, op, |
1061 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1064 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1062 | 1065 |
1063 if (drag_dest_delegate_) { | 1066 if (drag_dest_delegate_) { |
1064 drag_dest_delegate_->OnReceiveDragData(event.data()); | 1067 drag_dest_delegate_->OnReceiveDragData(event.data()); |
1065 drag_dest_delegate_->OnDragEnter(); | 1068 drag_dest_delegate_->OnDragEnter(); |
1066 } | 1069 } |
1067 } | 1070 } |
1068 | 1071 |
1069 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { | 1072 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { |
1070 DCHECK(current_rvh_for_drag_); | 1073 DCHECK(current_rvh_for_drag_); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 | 1106 |
1104 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { | 1107 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
1105 DCHECK(current_rvh_for_drag_); | 1108 DCHECK(current_rvh_for_drag_); |
1106 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) | 1109 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) |
1107 OnDragEntered(event); | 1110 OnDragEntered(event); |
1108 | 1111 |
1109 if (!current_drop_data_) | 1112 if (!current_drop_data_) |
1110 return ui::DragDropTypes::DRAG_NONE; | 1113 return ui::DragDropTypes::DRAG_NONE; |
1111 | 1114 |
1112 web_contents_->GetRenderViewHost()->DragTargetDrop( | 1115 web_contents_->GetRenderViewHost()->DragTargetDrop( |
1113 event.location(), display::Screen::GetScreen()->GetCursorScreenPoint(), | 1116 *current_drop_data_, event.location(), |
| 1117 display::Screen::GetScreen()->GetCursorScreenPoint(), |
1114 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1118 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1115 if (drag_dest_delegate_) | 1119 if (drag_dest_delegate_) |
1116 drag_dest_delegate_->OnDrop(); | 1120 drag_dest_delegate_->OnDrop(); |
1117 current_drop_data_.reset(); | 1121 current_drop_data_.reset(); |
1118 return ConvertFromWeb(current_drag_op_); | 1122 return ConvertFromWeb(current_drag_op_); |
1119 } | 1123 } |
1120 | 1124 |
1121 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, | 1125 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, |
1122 bool visible) { | 1126 bool visible) { |
1123 // Ignore any visibility changes in the hierarchy below. | 1127 // Ignore any visibility changes in the hierarchy below. |
1124 if (window != window_.get() && window_->Contains(window)) | 1128 if (window != window_.get() && window_->Contains(window)) |
1125 return; | 1129 return; |
1126 | 1130 |
1127 web_contents_->UpdateWebContentsVisibility(visible); | 1131 web_contents_->UpdateWebContentsVisibility(visible); |
1128 } | 1132 } |
1129 | 1133 |
1130 } // namespace content | 1134 } // namespace content |
OLD | NEW |