| 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 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 } | 1101 } |
| 1102 | 1102 |
| 1103 web_contents_->GetDelegate()->ContentsMouseEvent( | 1103 web_contents_->GetDelegate()->ContentsMouseEvent( |
| 1104 web_contents_, display::Screen::GetScreen()->GetCursorScreenPoint(), | 1104 web_contents_, display::Screen::GetScreen()->GetCursorScreenPoint(), |
| 1105 type == ui::ET_MOUSE_MOVED, type == ui::ET_MOUSE_EXITED); | 1105 type == ui::ET_MOUSE_MOVED, type == ui::ET_MOUSE_EXITED); |
| 1106 } | 1106 } |
| 1107 | 1107 |
| 1108 //////////////////////////////////////////////////////////////////////////////// | 1108 //////////////////////////////////////////////////////////////////////////////// |
| 1109 // WebContentsViewAura, aura::client::DragDropDelegate implementation: | 1109 // WebContentsViewAura, aura::client::DragDropDelegate implementation: |
| 1110 | 1110 |
| 1111 // TODO(paulmeyer): The drag-and-drop calls on GetRenderViewHost()->GetWidget() |
| 1112 // in the following functions will need to be targeted to specific |
| 1113 // RenderWidgetHosts in order to work with OOPIFs. See crbug.com/647249. |
| 1114 |
| 1111 void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) { | 1115 void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) { |
| 1112 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); | 1116 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); |
| 1113 current_drop_data_.reset(new DropData()); | 1117 current_drop_data_.reset(new DropData()); |
| 1114 | 1118 |
| 1115 PrepareDropData(current_drop_data_.get(), event.data()); | 1119 PrepareDropData(current_drop_data_.get(), event.data()); |
| 1116 | 1120 |
| 1117 web_contents_->GetRenderViewHost()->FilterDropData(current_drop_data_.get()); | 1121 web_contents_->GetRenderViewHost()->GetWidget()-> |
| 1122 FilterDropData(current_drop_data_.get()); |
| 1118 | 1123 |
| 1119 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 1124 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
| 1120 | 1125 |
| 1121 // Give the delegate an opportunity to cancel the drag. | 1126 // Give the delegate an opportunity to cancel the drag. |
| 1122 if (web_contents_->GetDelegate() && | 1127 if (web_contents_->GetDelegate() && |
| 1123 !web_contents_->GetDelegate()->CanDragEnter( | 1128 !web_contents_->GetDelegate()->CanDragEnter( |
| 1124 web_contents_, *current_drop_data_.get(), op)) { | 1129 web_contents_, *current_drop_data_.get(), op)) { |
| 1125 current_drop_data_.reset(NULL); | 1130 current_drop_data_.reset(NULL); |
| 1126 return; | 1131 return; |
| 1127 } | 1132 } |
| 1128 | 1133 |
| 1129 if (drag_dest_delegate_) | 1134 if (drag_dest_delegate_) |
| 1130 drag_dest_delegate_->DragInitialize(web_contents_); | 1135 drag_dest_delegate_->DragInitialize(web_contents_); |
| 1131 | 1136 |
| 1132 gfx::Point screen_pt = display::Screen::GetScreen()->GetCursorScreenPoint(); | 1137 gfx::Point screen_pt = display::Screen::GetScreen()->GetCursorScreenPoint(); |
| 1133 web_contents_->GetRenderViewHost()->DragTargetDragEnter( | 1138 web_contents_->GetRenderViewHost()->GetWidget()->DragTargetDragEnter( |
| 1134 *current_drop_data_, event.location(), screen_pt, op, | 1139 *current_drop_data_, event.location(), screen_pt, op, |
| 1135 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1140 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 1136 | 1141 |
| 1137 if (drag_dest_delegate_) { | 1142 if (drag_dest_delegate_) { |
| 1138 drag_dest_delegate_->OnReceiveDragData(event.data()); | 1143 drag_dest_delegate_->OnReceiveDragData(event.data()); |
| 1139 drag_dest_delegate_->OnDragEnter(); | 1144 drag_dest_delegate_->OnDragEnter(); |
| 1140 } | 1145 } |
| 1141 } | 1146 } |
| 1142 | 1147 |
| 1143 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { | 1148 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { |
| 1144 DCHECK(current_rvh_for_drag_); | 1149 DCHECK(current_rvh_for_drag_); |
| 1145 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) | 1150 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) |
| 1146 OnDragEntered(event); | 1151 OnDragEntered(event); |
| 1147 | 1152 |
| 1148 if (!current_drop_data_) | 1153 if (!current_drop_data_) |
| 1149 return ui::DragDropTypes::DRAG_NONE; | 1154 return ui::DragDropTypes::DRAG_NONE; |
| 1150 | 1155 |
| 1151 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 1156 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
| 1152 gfx::Point screen_pt = event.root_location(); | 1157 gfx::Point screen_pt = event.root_location(); |
| 1153 web_contents_->GetRenderViewHost()->DragTargetDragOver( | 1158 web_contents_->GetRenderViewHost()->GetWidget()->DragTargetDragOver( |
| 1154 event.location(), screen_pt, op, | 1159 event.location(), screen_pt, op, |
| 1155 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1160 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 1156 | 1161 |
| 1157 if (drag_dest_delegate_) | 1162 if (drag_dest_delegate_) |
| 1158 drag_dest_delegate_->OnDragOver(); | 1163 drag_dest_delegate_->OnDragOver(); |
| 1159 | 1164 |
| 1160 return ConvertFromWeb(current_drag_op_); | 1165 return ConvertFromWeb(current_drag_op_); |
| 1161 } | 1166 } |
| 1162 | 1167 |
| 1163 void WebContentsViewAura::OnDragExited() { | 1168 void WebContentsViewAura::OnDragExited() { |
| 1164 DCHECK(current_rvh_for_drag_); | 1169 DCHECK(current_rvh_for_drag_); |
| 1165 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) | 1170 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) |
| 1166 return; | 1171 return; |
| 1167 | 1172 |
| 1168 if (!current_drop_data_) | 1173 if (!current_drop_data_) |
| 1169 return; | 1174 return; |
| 1170 | 1175 |
| 1171 web_contents_->GetRenderViewHost()->DragTargetDragLeave(); | 1176 web_contents_->GetRenderViewHost()->GetWidget()->DragTargetDragLeave(); |
| 1172 if (drag_dest_delegate_) | 1177 if (drag_dest_delegate_) |
| 1173 drag_dest_delegate_->OnDragLeave(); | 1178 drag_dest_delegate_->OnDragLeave(); |
| 1174 | 1179 |
| 1175 current_drop_data_.reset(); | 1180 current_drop_data_.reset(); |
| 1176 } | 1181 } |
| 1177 | 1182 |
| 1178 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { | 1183 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
| 1179 DCHECK(current_rvh_for_drag_); | 1184 DCHECK(current_rvh_for_drag_); |
| 1180 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) | 1185 if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost()) |
| 1181 OnDragEntered(event); | 1186 OnDragEntered(event); |
| 1182 | 1187 |
| 1183 if (!current_drop_data_) | 1188 if (!current_drop_data_) |
| 1184 return ui::DragDropTypes::DRAG_NONE; | 1189 return ui::DragDropTypes::DRAG_NONE; |
| 1185 | 1190 |
| 1186 web_contents_->GetRenderViewHost()->DragTargetDrop( | 1191 web_contents_->GetRenderViewHost()->GetWidget()->DragTargetDrop( |
| 1187 *current_drop_data_, event.location(), | 1192 *current_drop_data_, event.location(), |
| 1188 display::Screen::GetScreen()->GetCursorScreenPoint(), | 1193 display::Screen::GetScreen()->GetCursorScreenPoint(), |
| 1189 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1194 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 1190 if (drag_dest_delegate_) | 1195 if (drag_dest_delegate_) |
| 1191 drag_dest_delegate_->OnDrop(); | 1196 drag_dest_delegate_->OnDrop(); |
| 1192 current_drop_data_.reset(); | 1197 current_drop_data_.reset(); |
| 1193 return ConvertFromWeb(current_drag_op_); | 1198 return ConvertFromWeb(current_drag_op_); |
| 1194 } | 1199 } |
| 1195 | 1200 |
| 1196 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, | 1201 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1213 bool allow_multiple_selection) { | 1218 bool allow_multiple_selection) { |
| 1214 NOTIMPLEMENTED() << " show " << items.size() << " menu items"; | 1219 NOTIMPLEMENTED() << " show " << items.size() << " menu items"; |
| 1215 } | 1220 } |
| 1216 | 1221 |
| 1217 void WebContentsViewAura::HidePopupMenu() { | 1222 void WebContentsViewAura::HidePopupMenu() { |
| 1218 NOTIMPLEMENTED(); | 1223 NOTIMPLEMENTED(); |
| 1219 } | 1224 } |
| 1220 #endif | 1225 #endif |
| 1221 | 1226 |
| 1222 } // namespace content | 1227 } // namespace content |
| OLD | NEW |