| 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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 543 |
| 544 void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) { | 544 void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) { |
| 545 if (web_contents_->GetInterstitialPage()) | 545 if (web_contents_->GetInterstitialPage()) |
| 546 web_contents_->GetInterstitialPage()->SetSize(size); | 546 web_contents_->GetInterstitialPage()->SetSize(size); |
| 547 RenderWidgetHostView* rwhv = | 547 RenderWidgetHostView* rwhv = |
| 548 web_contents_->GetRenderWidgetHostView(); | 548 web_contents_->GetRenderWidgetHostView(); |
| 549 if (rwhv) | 549 if (rwhv) |
| 550 rwhv->SetSize(size); | 550 rwhv->SetSize(size); |
| 551 } | 551 } |
| 552 | 552 |
| 553 void WebContentsViewAura::EndDrag(blink::WebDragOperationsMask ops) { | 553 void WebContentsViewAura::EndDrag(RenderWidgetHost* source_rwh, |
| 554 blink::WebDragOperationsMask ops) { |
| 554 if (!web_contents_) | 555 if (!web_contents_) |
| 555 return; | 556 return; |
| 556 | 557 |
| 557 aura::Window* window = GetContentNativeView(); | 558 aura::Window* window = GetContentNativeView(); |
| 558 gfx::Point screen_loc = display::Screen::GetScreen()->GetCursorScreenPoint(); | 559 gfx::Point screen_loc = display::Screen::GetScreen()->GetCursorScreenPoint(); |
| 559 gfx::Point client_loc = screen_loc; | 560 gfx::Point client_loc = screen_loc; |
| 560 aura::client::ScreenPositionClient* screen_position_client = | 561 aura::client::ScreenPositionClient* screen_position_client = |
| 561 aura::client::GetScreenPositionClient(window->GetRootWindow()); | 562 aura::client::GetScreenPositionClient(window->GetRootWindow()); |
| 562 if (screen_position_client) | 563 if (screen_position_client) |
| 563 screen_position_client->ConvertPointFromScreen(window, &client_loc); | 564 screen_position_client->ConvertPointFromScreen(window, &client_loc); |
| 564 | 565 |
| 565 // TODO(paulmeyer): In the OOPIF case, should |client_loc| be converted to | 566 // TODO(paulmeyer): In the OOPIF case, should |client_loc| be converted to |
| 566 // the coordinates local to |drag_start_rwh_|? See crbug.com/647249. | 567 // the coordinates local to |drag_start_rwh_|? See crbug.com/647249. |
| 567 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), | 568 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), |
| 568 screen_loc.x(), screen_loc.y(), ops, | 569 screen_loc.x(), screen_loc.y(), ops, |
| 569 drag_start_rwh_.get()); | 570 source_rwh); |
| 571 |
| 572 web_contents_->SystemDragEnded(source_rwh); |
| 570 } | 573 } |
| 571 | 574 |
| 572 void WebContentsViewAura::InstallOverscrollControllerDelegate( | 575 void WebContentsViewAura::InstallOverscrollControllerDelegate( |
| 573 RenderWidgetHostViewAura* view) { | 576 RenderWidgetHostViewAura* view) { |
| 574 const std::string value = base::CommandLine::ForCurrentProcess()-> | 577 const std::string value = base::CommandLine::ForCurrentProcess()-> |
| 575 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation); | 578 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation); |
| 576 if (value == "0") { | 579 if (value == "0") { |
| 577 navigation_overlay_.reset(); | 580 navigation_overlay_.reset(); |
| 578 return; | 581 return; |
| 579 } | 582 } |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 const gfx::ImageSkia& image, | 892 const gfx::ImageSkia& image, |
| 890 const gfx::Vector2d& image_offset, | 893 const gfx::Vector2d& image_offset, |
| 891 const DragEventSourceInfo& event_info, | 894 const DragEventSourceInfo& event_info, |
| 892 RenderWidgetHostImpl* source_rwh) { | 895 RenderWidgetHostImpl* source_rwh) { |
| 893 aura::Window* root_window = GetNativeView()->GetRootWindow(); | 896 aura::Window* root_window = GetNativeView()->GetRootWindow(); |
| 894 if (!aura::client::GetDragDropClient(root_window)) { | 897 if (!aura::client::GetDragDropClient(root_window)) { |
| 895 web_contents_->SystemDragEnded(source_rwh); | 898 web_contents_->SystemDragEnded(source_rwh); |
| 896 return; | 899 return; |
| 897 } | 900 } |
| 898 | 901 |
| 899 drag_start_rwh_ = source_rwh->GetWeakPtr(); | 902 // Grab a weak pointer to the RenderWidgetHost, since it can be destroyed |
| 903 // during the drag and drop nested message loop in StartDragAndDrop. |
| 904 // For example, the RenderWidgetHost can be deleted if a cross-process |
| 905 // transfer happens while dragging, since the RenderWidgetHost is deleted in |
| 906 // that case. |
| 907 base::WeakPtr<RenderWidgetHostImpl> source_rwh_weak_ptr = |
| 908 source_rwh->GetWeakPtr(); |
| 900 | 909 |
| 901 ui::TouchSelectionController* selection_controller = GetSelectionController(); | 910 ui::TouchSelectionController* selection_controller = GetSelectionController(); |
| 902 if (selection_controller) | 911 if (selection_controller) |
| 903 selection_controller->HideAndDisallowShowingAutomatically(); | 912 selection_controller->HideAndDisallowShowingAutomatically(); |
| 904 std::unique_ptr<ui::OSExchangeData::Provider> provider = | 913 std::unique_ptr<ui::OSExchangeData::Provider> provider = |
| 905 ui::OSExchangeDataProviderFactory::CreateProvider(); | 914 ui::OSExchangeDataProviderFactory::CreateProvider(); |
| 906 PrepareDragData(drop_data, provider.get(), web_contents_); | 915 PrepareDragData(drop_data, provider.get(), web_contents_); |
| 907 | 916 |
| 908 ui::OSExchangeData data( | 917 ui::OSExchangeData data( |
| 909 std::move(provider)); // takes ownership of |provider|. | 918 std::move(provider)); // takes ownership of |provider|. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 933 // Bail out immediately if the contents view window is gone. Note that it is | 942 // Bail out immediately if the contents view window is gone. Note that it is |
| 934 // not safe to access any class members in this case since |this| may already | 943 // not safe to access any class members in this case since |this| may already |
| 935 // be destroyed. The local variable |drag_source| will still be valid though, | 944 // be destroyed. The local variable |drag_source| will still be valid though, |
| 936 // so we can use it to determine if the window is gone. | 945 // so we can use it to determine if the window is gone. |
| 937 if (!drag_source->window()) { | 946 if (!drag_source->window()) { |
| 938 // Note that in this case, we don't need to call SystemDragEnded() since the | 947 // Note that in this case, we don't need to call SystemDragEnded() since the |
| 939 // renderer is going away. | 948 // renderer is going away. |
| 940 return; | 949 return; |
| 941 } | 950 } |
| 942 | 951 |
| 943 EndDrag(ConvertToWeb(result_op)); | 952 EndDrag(source_rwh_weak_ptr.get(), ConvertToWeb(result_op)); |
| 944 web_contents_->SystemDragEnded(source_rwh); | |
| 945 } | 953 } |
| 946 | 954 |
| 947 void WebContentsViewAura::UpdateDragCursor(blink::WebDragOperation operation) { | 955 void WebContentsViewAura::UpdateDragCursor(blink::WebDragOperation operation) { |
| 948 current_drag_op_ = operation; | 956 current_drag_op_ = operation; |
| 949 } | 957 } |
| 950 | 958 |
| 951 void WebContentsViewAura::GotFocus() { | 959 void WebContentsViewAura::GotFocus() { |
| 952 web_contents_->NotifyWebContentsFocused(); | 960 web_contents_->NotifyWebContentsFocused(); |
| 953 } | 961 } |
| 954 | 962 |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 bool allow_multiple_selection) { | 1255 bool allow_multiple_selection) { |
| 1248 NOTIMPLEMENTED() << " show " << items.size() << " menu items"; | 1256 NOTIMPLEMENTED() << " show " << items.size() << " menu items"; |
| 1249 } | 1257 } |
| 1250 | 1258 |
| 1251 void WebContentsViewAura::HidePopupMenu() { | 1259 void WebContentsViewAura::HidePopupMenu() { |
| 1252 NOTIMPLEMENTED(); | 1260 NOTIMPLEMENTED(); |
| 1253 } | 1261 } |
| 1254 #endif | 1262 #endif |
| 1255 | 1263 |
| 1256 } // namespace content | 1264 } // namespace content |
| OLD | NEW |