Chromium Code Reviews| 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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 509 //////////////////////////////////////////////////////////////////////////////// | 509 //////////////////////////////////////////////////////////////////////////////// |
| 510 // WebContentsViewAura, public: | 510 // WebContentsViewAura, public: |
| 511 | 511 |
| 512 WebContentsViewAura::WebContentsViewAura(WebContentsImpl* web_contents, | 512 WebContentsViewAura::WebContentsViewAura(WebContentsImpl* web_contents, |
| 513 WebContentsViewDelegate* delegate) | 513 WebContentsViewDelegate* delegate) |
| 514 : web_contents_(web_contents), | 514 : web_contents_(web_contents), |
| 515 delegate_(delegate), | 515 delegate_(delegate), |
| 516 current_drag_op_(blink::WebDragOperationNone), | 516 current_drag_op_(blink::WebDragOperationNone), |
| 517 drag_dest_delegate_(nullptr), | 517 drag_dest_delegate_(nullptr), |
| 518 current_rvh_for_drag_(nullptr), | 518 current_rvh_for_drag_(nullptr), |
| 519 drag_source_rph_(nullptr), | |
| 520 drag_source_rvh_(nullptr), | |
| 519 current_overscroll_gesture_(OVERSCROLL_NONE), | 521 current_overscroll_gesture_(OVERSCROLL_NONE), |
| 520 completed_overscroll_gesture_(OVERSCROLL_NONE), | 522 completed_overscroll_gesture_(OVERSCROLL_NONE), |
| 521 navigation_overlay_(nullptr), | 523 navigation_overlay_(nullptr), |
| 522 init_rwhv_with_null_parent_for_testing_(false) {} | 524 init_rwhv_with_null_parent_for_testing_(false) {} |
| 523 | 525 |
| 524 void WebContentsViewAura::SetDelegateForTesting( | 526 void WebContentsViewAura::SetDelegateForTesting( |
| 525 WebContentsViewDelegate* delegate) { | 527 WebContentsViewDelegate* delegate) { |
| 526 delegate_.reset(delegate); | 528 delegate_.reset(delegate); |
| 527 } | 529 } |
| 528 | 530 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 556 return; | 558 return; |
| 557 | 559 |
| 558 aura::Window* window = GetContentNativeView(); | 560 aura::Window* window = GetContentNativeView(); |
| 559 gfx::Point screen_loc = display::Screen::GetScreen()->GetCursorScreenPoint(); | 561 gfx::Point screen_loc = display::Screen::GetScreen()->GetCursorScreenPoint(); |
| 560 gfx::Point client_loc = screen_loc; | 562 gfx::Point client_loc = screen_loc; |
| 561 aura::client::ScreenPositionClient* screen_position_client = | 563 aura::client::ScreenPositionClient* screen_position_client = |
| 562 aura::client::GetScreenPositionClient(window->GetRootWindow()); | 564 aura::client::GetScreenPositionClient(window->GetRootWindow()); |
| 563 if (screen_position_client) | 565 if (screen_position_client) |
| 564 screen_position_client->ConvertPointFromScreen(window, &client_loc); | 566 screen_position_client->ConvertPointFromScreen(window, &client_loc); |
| 565 | 567 |
| 566 // TODO(paulmeyer): In the OOPIF case, should |client_loc| be converted to | 568 // TODO(paulmeyer): In the OOPIF case, should |client_loc| be converted to the |
| 567 // the coordinates local to |drag_start_rwh_|? See crbug.com/647249. | 569 // coordinates local to |source_rwh|? See crbug.com/647249. |
| 568 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), | 570 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), |
| 569 screen_loc.x(), screen_loc.y(), ops, | 571 screen_loc.x(), screen_loc.y(), ops, |
| 570 source_rwh); | 572 source_rwh); |
| 571 | 573 |
| 572 web_contents_->SystemDragEnded(source_rwh); | 574 web_contents_->SystemDragEnded(source_rwh); |
| 573 } | 575 } |
| 574 | 576 |
| 575 void WebContentsViewAura::InstallOverscrollControllerDelegate( | 577 void WebContentsViewAura::InstallOverscrollControllerDelegate( |
| 576 RenderWidgetHostViewAura* view) { | 578 RenderWidgetHostViewAura* view) { |
| 577 const std::string value = base::CommandLine::ForCurrentProcess()-> | 579 const std::string value = base::CommandLine::ForCurrentProcess()-> |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 900 } | 902 } |
| 901 | 903 |
| 902 // Grab a weak pointer to the RenderWidgetHost, since it can be destroyed | 904 // Grab a weak pointer to the RenderWidgetHost, since it can be destroyed |
| 903 // during the drag and drop nested message loop in StartDragAndDrop. | 905 // during the drag and drop nested message loop in StartDragAndDrop. |
| 904 // For example, the RenderWidgetHost can be deleted if a cross-process | 906 // For example, the RenderWidgetHost can be deleted if a cross-process |
| 905 // transfer happens while dragging, since the RenderWidgetHost is deleted in | 907 // transfer happens while dragging, since the RenderWidgetHost is deleted in |
| 906 // that case. | 908 // that case. |
| 907 base::WeakPtr<RenderWidgetHostImpl> source_rwh_weak_ptr = | 909 base::WeakPtr<RenderWidgetHostImpl> source_rwh_weak_ptr = |
| 908 source_rwh->GetWeakPtr(); | 910 source_rwh->GetWeakPtr(); |
| 909 | 911 |
| 912 drag_source_rph_ = source_rwh->GetProcess(); | |
|
lfg
2016/12/12 20:34:21
Would it be possible that a RenderProcessHost is d
Charlie Reis
2016/12/12 20:57:02
Yes, I'm concerned about the void* pointers as wel
paulmeyer
2016/12/13 20:57:30
Done.
paulmeyer
2016/12/13 20:57:30
Done.
| |
| 913 drag_source_rvh_ = web_contents_->GetRenderViewHost(); | |
| 914 | |
| 910 ui::TouchSelectionController* selection_controller = GetSelectionController(); | 915 ui::TouchSelectionController* selection_controller = GetSelectionController(); |
| 911 if (selection_controller) | 916 if (selection_controller) |
| 912 selection_controller->HideAndDisallowShowingAutomatically(); | 917 selection_controller->HideAndDisallowShowingAutomatically(); |
| 913 std::unique_ptr<ui::OSExchangeData::Provider> provider = | 918 std::unique_ptr<ui::OSExchangeData::Provider> provider = |
| 914 ui::OSExchangeDataProviderFactory::CreateProvider(); | 919 ui::OSExchangeDataProviderFactory::CreateProvider(); |
| 915 PrepareDragData(drop_data, provider.get(), web_contents_); | 920 PrepareDragData(drop_data, provider.get(), web_contents_); |
| 916 | 921 |
| 917 ui::OSExchangeData data( | 922 ui::OSExchangeData data( |
| 918 std::move(provider)); // takes ownership of |provider|. | 923 std::move(provider)); // takes ownership of |provider|. |
| 919 | 924 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1123 web_contents_->GetDelegate()->ContentsMouseEvent( | 1128 web_contents_->GetDelegate()->ContentsMouseEvent( |
| 1124 web_contents_, display::Screen::GetScreen()->GetCursorScreenPoint(), | 1129 web_contents_, display::Screen::GetScreen()->GetCursorScreenPoint(), |
| 1125 type == ui::ET_MOUSE_MOVED, type == ui::ET_MOUSE_EXITED); | 1130 type == ui::ET_MOUSE_MOVED, type == ui::ET_MOUSE_EXITED); |
| 1126 } | 1131 } |
| 1127 | 1132 |
| 1128 //////////////////////////////////////////////////////////////////////////////// | 1133 //////////////////////////////////////////////////////////////////////////////// |
| 1129 // WebContentsViewAura, aura::client::DragDropDelegate implementation: | 1134 // WebContentsViewAura, aura::client::DragDropDelegate implementation: |
| 1130 | 1135 |
| 1131 void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) { | 1136 void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) { |
| 1132 gfx::Point transformed_pt; | 1137 gfx::Point transformed_pt; |
| 1133 current_rwh_for_drag_ = | 1138 RenderWidgetHostImpl* target_rwh = |
| 1134 web_contents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( | 1139 web_contents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( |
| 1135 web_contents_->GetRenderViewHost()->GetWidget()->GetView(), | 1140 web_contents_->GetRenderViewHost()->GetWidget()->GetView(), |
| 1136 event.location(), &transformed_pt)->GetWeakPtr(); | 1141 event.location(), &transformed_pt); |
| 1142 | |
| 1143 if (drag_source_rvh_ == web_contents_->GetRenderViewHost() && | |
|
lfg
2016/12/12 20:34:21
I don't understand this check. This would only be
paulmeyer
2016/12/13 20:57:30
Per offline discussion, I will continue checking t
| |
| 1144 drag_source_rph_ != target_rwh->GetProcess()) { | |
| 1145 return; | |
| 1146 } | |
| 1147 | |
| 1148 current_rwh_for_drag_ = target_rwh->GetWeakPtr(); | |
| 1137 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); | 1149 current_rvh_for_drag_ = web_contents_->GetRenderViewHost(); |
| 1138 | |
| 1139 current_drop_data_.reset(new DropData()); | 1150 current_drop_data_.reset(new DropData()); |
| 1140 PrepareDropData(current_drop_data_.get(), event.data()); | 1151 PrepareDropData(current_drop_data_.get(), event.data()); |
| 1141 current_rwh_for_drag_->FilterDropData(current_drop_data_.get()); | 1152 current_rwh_for_drag_->FilterDropData(current_drop_data_.get()); |
| 1142 | 1153 |
| 1143 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 1154 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
| 1144 | 1155 |
| 1145 // Give the delegate an opportunity to cancel the drag. | 1156 // Give the delegate an opportunity to cancel the drag. |
| 1146 if (web_contents_->GetDelegate() && | 1157 if (web_contents_->GetDelegate() && |
| 1147 !web_contents_->GetDelegate()->CanDragEnter( | 1158 !web_contents_->GetDelegate()->CanDragEnter( |
| 1148 web_contents_, *current_drop_data_.get(), op)) { | 1159 web_contents_, *current_drop_data_.get(), op)) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1164 } | 1175 } |
| 1165 } | 1176 } |
| 1166 | 1177 |
| 1167 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { | 1178 int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { |
| 1168 gfx::Point transformed_pt; | 1179 gfx::Point transformed_pt; |
| 1169 RenderWidgetHostImpl* target_rwh = | 1180 RenderWidgetHostImpl* target_rwh = |
| 1170 web_contents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( | 1181 web_contents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( |
| 1171 web_contents_->GetRenderViewHost()->GetWidget()->GetView(), | 1182 web_contents_->GetRenderViewHost()->GetWidget()->GetView(), |
| 1172 event.location(), &transformed_pt); | 1183 event.location(), &transformed_pt); |
| 1173 | 1184 |
| 1185 if (drag_source_rvh_ == web_contents_->GetRenderViewHost() && | |
| 1186 drag_source_rph_ != target_rwh->GetProcess()) { | |
| 1187 return ui::DragDropTypes::DRAG_NONE; | |
| 1188 } | |
| 1189 | |
| 1174 if (target_rwh != current_rwh_for_drag_.get()) { | 1190 if (target_rwh != current_rwh_for_drag_.get()) { |
| 1175 if (current_rwh_for_drag_) | 1191 if (current_rwh_for_drag_) |
| 1176 current_rwh_for_drag_->DragTargetDragLeave(); | 1192 current_rwh_for_drag_->DragTargetDragLeave(); |
| 1177 OnDragEntered(event); | 1193 OnDragEntered(event); |
| 1178 } | 1194 } |
| 1179 | 1195 |
| 1180 if (!current_drop_data_) | 1196 if (!current_drop_data_) |
| 1181 return ui::DragDropTypes::DRAG_NONE; | 1197 return ui::DragDropTypes::DRAG_NONE; |
| 1182 | 1198 |
| 1183 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 1199 blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1209 current_drop_data_.reset(); | 1225 current_drop_data_.reset(); |
| 1210 } | 1226 } |
| 1211 | 1227 |
| 1212 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { | 1228 int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
| 1213 gfx::Point transformed_pt; | 1229 gfx::Point transformed_pt; |
| 1214 RenderWidgetHostImpl* target_rwh = | 1230 RenderWidgetHostImpl* target_rwh = |
| 1215 web_contents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( | 1231 web_contents_->GetInputEventRouter()->GetRenderWidgetHostAtPoint( |
| 1216 web_contents_->GetRenderViewHost()->GetWidget()->GetView(), | 1232 web_contents_->GetRenderViewHost()->GetWidget()->GetView(), |
| 1217 event.location(), &transformed_pt); | 1233 event.location(), &transformed_pt); |
| 1218 | 1234 |
| 1235 if (drag_source_rvh_ == web_contents_->GetRenderViewHost() && | |
| 1236 drag_source_rph_ != target_rwh->GetProcess()) { | |
| 1237 return ui::DragDropTypes::DRAG_NONE; | |
| 1238 } | |
| 1239 | |
| 1219 if (target_rwh != current_rwh_for_drag_.get()) { | 1240 if (target_rwh != current_rwh_for_drag_.get()) { |
| 1220 if (current_rwh_for_drag_) | 1241 if (current_rwh_for_drag_) |
| 1221 current_rwh_for_drag_->DragTargetDragLeave(); | 1242 current_rwh_for_drag_->DragTargetDragLeave(); |
| 1222 OnDragEntered(event); | 1243 OnDragEntered(event); |
| 1223 } | 1244 } |
| 1224 | 1245 |
| 1225 if (!current_drop_data_) | 1246 if (!current_drop_data_) |
| 1226 return ui::DragDropTypes::DRAG_NONE; | 1247 return ui::DragDropTypes::DRAG_NONE; |
| 1227 | 1248 |
| 1228 target_rwh->DragTargetDrop( | 1249 target_rwh->DragTargetDrop( |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1255 bool allow_multiple_selection) { | 1276 bool allow_multiple_selection) { |
| 1256 NOTIMPLEMENTED() << " show " << items.size() << " menu items"; | 1277 NOTIMPLEMENTED() << " show " << items.size() << " menu items"; |
| 1257 } | 1278 } |
| 1258 | 1279 |
| 1259 void WebContentsViewAura::HidePopupMenu() { | 1280 void WebContentsViewAura::HidePopupMenu() { |
| 1260 NOTIMPLEMENTED(); | 1281 NOTIMPLEMENTED(); |
| 1261 } | 1282 } |
| 1262 #endif | 1283 #endif |
| 1263 | 1284 |
| 1264 } // namespace content | 1285 } // namespace content |
| OLD | NEW |