| 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 "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" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 // |drag_handler_->CancelDrag()| is async. Instead, set a flag to cancel | 332 // |drag_handler_->CancelDrag()| is async. Instead, set a flag to cancel |
| 333 // the drag and when the drag nested message loop ends, close the tab. | 333 // the drag and when the drag nested message loop ends, close the tab. |
| 334 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); | 334 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); |
| 335 if (aura::client::GetDragDropClient(root_window)) | 335 if (aura::client::GetDragDropClient(root_window)) |
| 336 aura::client::GetDragDropClient(root_window)->DragCancel(); | 336 aura::client::GetDragDropClient(root_window)->DragCancel(); |
| 337 | 337 |
| 338 close_tab_after_drag_ends_ = true; | 338 close_tab_after_drag_ends_ = true; |
| 339 } | 339 } |
| 340 | 340 |
| 341 WebDropData* WebContentsViewAura::GetDropData() const { | 341 WebDropData* WebContentsViewAura::GetDropData() const { |
| 342 return NULL; | 342 return current_incoming_drop_data_.get(); |
| 343 } | 343 } |
| 344 | 344 |
| 345 bool WebContentsViewAura::IsEventTracking() const { | 345 bool WebContentsViewAura::IsEventTracking() const { |
| 346 return false; | 346 return false; |
| 347 } | 347 } |
| 348 | 348 |
| 349 void WebContentsViewAura::CloseTabAfterEventTracking() { | 349 void WebContentsViewAura::CloseTabAfterEventTracking() { |
| 350 } | 350 } |
| 351 | 351 |
| 352 void WebContentsViewAura::GetViewBounds(gfx::Rect* out) const { | 352 void WebContentsViewAura::GetViewBounds(gfx::Rect* out) const { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 else | 558 else |
| 559 web_contents_->HideContents(); | 559 web_contents_->HideContents(); |
| 560 } | 560 } |
| 561 //////////////////////////////////////////////////////////////////////////////// | 561 //////////////////////////////////////////////////////////////////////////////// |
| 562 // WebContentsViewAura, aura::client::DragDropDelegate implementation: | 562 // WebContentsViewAura, aura::client::DragDropDelegate implementation: |
| 563 | 563 |
| 564 void WebContentsViewAura::OnDragEntered(const aura::DropTargetEvent& event) { | 564 void WebContentsViewAura::OnDragEntered(const aura::DropTargetEvent& event) { |
| 565 if (drag_dest_delegate_) | 565 if (drag_dest_delegate_) |
| 566 drag_dest_delegate_->DragInitialize(web_contents_); | 566 drag_dest_delegate_->DragInitialize(web_contents_); |
| 567 | 567 |
| 568 WebDropData drop_data; | 568 current_incoming_drop_data_.reset(new WebDropData()); |
| 569 PrepareWebDropData(&drop_data, event.data()); | 569 PrepareWebDropData(current_incoming_drop_data_.get(), event.data()); |
| 570 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 570 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
| 571 | 571 |
| 572 gfx::Point screen_pt = | 572 gfx::Point screen_pt = |
| 573 GetNativeView()->GetRootWindow()->last_mouse_location(); | 573 GetNativeView()->GetRootWindow()->last_mouse_location(); |
| 574 web_contents_->GetRenderViewHost()->DragTargetDragEnter( | 574 web_contents_->GetRenderViewHost()->DragTargetDragEnter( |
| 575 drop_data, event.location(), screen_pt, op); | 575 *current_incoming_drop_data_, event.location(), screen_pt, op); |
| 576 | 576 |
| 577 if (drag_dest_delegate_) { | 577 if (drag_dest_delegate_) { |
| 578 drag_dest_delegate_->OnReceiveDragData(event.data()); | 578 drag_dest_delegate_->OnReceiveDragData(event.data()); |
| 579 drag_dest_delegate_->OnDragEnter(); | 579 drag_dest_delegate_->OnDragEnter(); |
| 580 } | 580 } |
| 581 } | 581 } |
| 582 | 582 |
| 583 int WebContentsViewAura::OnDragUpdated(const aura::DropTargetEvent& event) { | 583 int WebContentsViewAura::OnDragUpdated(const aura::DropTargetEvent& event) { |
| 584 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); | 584 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); |
| 585 gfx::Point screen_pt = | 585 gfx::Point screen_pt = |
| 586 GetNativeView()->GetRootWindow()->last_mouse_location(); | 586 GetNativeView()->GetRootWindow()->last_mouse_location(); |
| 587 web_contents_->GetRenderViewHost()->DragTargetDragOver( | 587 web_contents_->GetRenderViewHost()->DragTargetDragOver( |
| 588 event.location(), screen_pt, op); | 588 event.location(), screen_pt, op); |
| 589 | 589 |
| 590 if (drag_dest_delegate_) | 590 if (drag_dest_delegate_) |
| 591 drag_dest_delegate_->OnDragOver(); | 591 drag_dest_delegate_->OnDragOver(); |
| 592 | 592 |
| 593 return ConvertFromWeb(current_drag_op_); | 593 return ConvertFromWeb(current_drag_op_); |
| 594 } | 594 } |
| 595 | 595 |
| 596 void WebContentsViewAura::OnDragExited() { | 596 void WebContentsViewAura::OnDragExited() { |
| 597 web_contents_->GetRenderViewHost()->DragTargetDragLeave(); | 597 web_contents_->GetRenderViewHost()->DragTargetDragLeave(); |
| 598 if (drag_dest_delegate_) | 598 if (drag_dest_delegate_) |
| 599 drag_dest_delegate_->OnDragLeave(); | 599 drag_dest_delegate_->OnDragLeave(); |
| 600 current_incoming_drop_data_.reset(); |
| 600 } | 601 } |
| 601 | 602 |
| 602 int WebContentsViewAura::OnPerformDrop(const aura::DropTargetEvent& event) { | 603 int WebContentsViewAura::OnPerformDrop(const aura::DropTargetEvent& event) { |
| 603 web_contents_->GetRenderViewHost()->DragTargetDrop( | 604 web_contents_->GetRenderViewHost()->DragTargetDrop( |
| 604 event.location(), | 605 event.location(), |
| 605 GetNativeView()->GetRootWindow()->last_mouse_location()); | 606 GetNativeView()->GetRootWindow()->last_mouse_location()); |
| 606 if (drag_dest_delegate_) | 607 if (drag_dest_delegate_) |
| 607 drag_dest_delegate_->OnDrop(); | 608 drag_dest_delegate_->OnDrop(); |
| 609 current_incoming_drop_data_.reset(); |
| 608 return current_drag_op_; | 610 return current_drag_op_; |
| 609 } | 611 } |
| OLD | NEW |