Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: content/browser/web_contents/web_contents_view_aura.cc

Issue 10273030: Fix Bookmark manager DnD: WebDragDestinationDelegate was getting recreated with (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/web_contents/web_contents_view_aura.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); 191 aura::RootWindow* root_window = GetNativeView()->GetRootWindow();
192 gfx::Point screen_loc = root_window->last_mouse_location(); 192 gfx::Point screen_loc = root_window->last_mouse_location();
193 gfx::Point client_loc = screen_loc; 193 gfx::Point client_loc = screen_loc;
194 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); 194 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
195 aura::Window* window = rvh->GetView()->GetNativeView(); 195 aura::Window* window = rvh->GetView()->GetNativeView();
196 aura::Window::ConvertPointToWindow(root_window, window, &client_loc); 196 aura::Window::ConvertPointToWindow(root_window, window, &client_loc);
197 rvh->DragSourceEndedAt(client_loc.x(), client_loc.y(), screen_loc.x(), 197 rvh->DragSourceEndedAt(client_loc.x(), client_loc.y(), screen_loc.x(),
198 screen_loc.y(), ops); 198 screen_loc.y(), ops);
199 } 199 }
200 200
201 content::WebDragDestDelegate* WebContentsViewAura::GetDragDestDelegate() {
202 return delegate_.get() ? delegate_->GetDragDestDelegate() : NULL;
203 }
204
205 //////////////////////////////////////////////////////////////////////////////// 201 ////////////////////////////////////////////////////////////////////////////////
206 // WebContentsViewAura, WebContentsView implementation: 202 // WebContentsViewAura, WebContentsView implementation:
207 203
208 void WebContentsViewAura::CreateView(const gfx::Size& initial_size) { 204 void WebContentsViewAura::CreateView(const gfx::Size& initial_size) {
209 initial_size_ = initial_size; 205 initial_size_ = initial_size;
210 206
211 window_.reset(new aura::Window(this)); 207 window_.reset(new aura::Window(this));
212 window_->set_owned_by_parent(false); 208 window_->set_owned_by_parent(false);
213 window_->SetType(aura::client::WINDOW_TYPE_CONTROL); 209 window_->SetType(aura::client::WINDOW_TYPE_CONTROL);
214 window_->SetTransparent(false); 210 window_->SetTransparent(false);
215 window_->Init(ui::LAYER_NOT_DRAWN); 211 window_->Init(ui::LAYER_NOT_DRAWN);
216 #if defined(USE_ASH) 212 #if defined(USE_ASH)
217 window_->SetParent(NULL); 213 window_->SetParent(NULL);
218 #endif 214 #endif
219 window_->layer()->SetMasksToBounds(true); 215 window_->layer()->SetMasksToBounds(true);
220 window_->SetName("WebContentsViewAura"); 216 window_->SetName("WebContentsViewAura");
217 if (delegate_.get())
sky 2012/05/01 17:33:51 Add a comment as to why you're doing this. Also, y
varunjain 2012/05/01 17:56:35 added comment and initialized to NULL
218 drag_dest_delegate_ = delegate_->GetDragDestDelegate();
221 } 219 }
222 220
223 content::RenderWidgetHostView* WebContentsViewAura::CreateViewForWidget( 221 content::RenderWidgetHostView* WebContentsViewAura::CreateViewForWidget(
224 content::RenderWidgetHost* render_widget_host) { 222 content::RenderWidgetHost* render_widget_host) {
225 if (render_widget_host->GetView()) { 223 if (render_widget_host->GetView()) {
226 // During testing, the view will already be set up in most cases to the 224 // During testing, the view will already be set up in most cases to the
227 // test view, so we don't want to clobber it with a real one. To verify that 225 // test view, so we don't want to clobber it with a real one. To verify that
228 // this actually is happening (and somebody isn't accidentally creating the 226 // this actually is happening (and somebody isn't accidentally creating the
229 // view twice), we check for the RVH Factory, which will be set when we're 227 // view twice), we check for the RVH Factory, which will be set when we're
230 // making special ones (which go along with the special views). 228 // making special ones (which go along with the special views).
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 // always start from a mouse-event (e.g. a touch or gesture event could 441 // always start from a mouse-event (e.g. a touch or gesture event could
444 // initiate the drag). The location information should be carried over from 442 // initiate the drag). The location information should be carried over from
445 // webkit. http://crbug.com/114754 443 // webkit. http://crbug.com/114754
446 gfx::Point location(root_window->last_mouse_location()); 444 gfx::Point location(root_window->last_mouse_location());
447 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); 445 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
448 result_op = aura::client::GetDragDropClient(root_window)->StartDragAndDrop( 446 result_op = aura::client::GetDragDropClient(root_window)->StartDragAndDrop(
449 data, location, ConvertFromWeb(operations)); 447 data, location, ConvertFromWeb(operations));
450 } 448 }
451 449
452 EndDrag(ConvertToWeb(result_op)); 450 EndDrag(ConvertToWeb(result_op));
453 web_contents_->GetRenderViewHost()->DragSourceSystemDragEnded();} 451 web_contents_->GetRenderViewHost()->DragSourceSystemDragEnded();
452 }
454 453
455 void WebContentsViewAura::UpdateDragCursor(WebKit::WebDragOperation operation) { 454 void WebContentsViewAura::UpdateDragCursor(WebKit::WebDragOperation operation) {
456 current_drag_op_ = operation; 455 current_drag_op_ = operation;
457 } 456 }
458 457
459 void WebContentsViewAura::GotFocus() { 458 void WebContentsViewAura::GotFocus() {
460 if (web_contents_->GetDelegate()) 459 if (web_contents_->GetDelegate())
461 web_contents_->GetDelegate()->WebContentsFocused(web_contents_); 460 web_contents_->GetDelegate()->WebContentsFocused(web_contents_);
462 } 461 }
463 462
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 void WebContentsViewAura::OnWindowVisibilityChanged(bool visible) { 546 void WebContentsViewAura::OnWindowVisibilityChanged(bool visible) {
548 if (visible) 547 if (visible)
549 web_contents_->ShowContents(); 548 web_contents_->ShowContents();
550 else 549 else
551 web_contents_->HideContents(); 550 web_contents_->HideContents();
552 } 551 }
553 //////////////////////////////////////////////////////////////////////////////// 552 ////////////////////////////////////////////////////////////////////////////////
554 // WebContentsViewAura, aura::client::DragDropDelegate implementation: 553 // WebContentsViewAura, aura::client::DragDropDelegate implementation:
555 554
556 void WebContentsViewAura::OnDragEntered(const aura::DropTargetEvent& event) { 555 void WebContentsViewAura::OnDragEntered(const aura::DropTargetEvent& event) {
557 if (GetDragDestDelegate()) 556 if (drag_dest_delegate_)
558 GetDragDestDelegate()->DragInitialize(web_contents_); 557 drag_dest_delegate_->DragInitialize(web_contents_);
559 558
560 WebDropData drop_data; 559 WebDropData drop_data;
561 PrepareWebDropData(&drop_data, event.data()); 560 PrepareWebDropData(&drop_data, event.data());
562 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); 561 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations());
563 562
564 gfx::Point screen_pt = 563 gfx::Point screen_pt =
565 GetNativeView()->GetRootWindow()->last_mouse_location(); 564 GetNativeView()->GetRootWindow()->last_mouse_location();
566 web_contents_->GetRenderViewHost()->DragTargetDragEnter( 565 web_contents_->GetRenderViewHost()->DragTargetDragEnter(
567 drop_data, event.location(), screen_pt, op); 566 drop_data, event.location(), screen_pt, op);
568 567
569 if (GetDragDestDelegate()) { 568 if (drag_dest_delegate_) {
570 GetDragDestDelegate()->OnReceiveDragData(event.data()); 569 drag_dest_delegate_->OnReceiveDragData(event.data());
571 GetDragDestDelegate()->OnDragEnter(); 570 drag_dest_delegate_->OnDragEnter();
572 } 571 }
573 } 572 }
574 573
575 int WebContentsViewAura::OnDragUpdated(const aura::DropTargetEvent& event) { 574 int WebContentsViewAura::OnDragUpdated(const aura::DropTargetEvent& event) {
576 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); 575 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations());
577 gfx::Point screen_pt = 576 gfx::Point screen_pt =
578 GetNativeView()->GetRootWindow()->last_mouse_location(); 577 GetNativeView()->GetRootWindow()->last_mouse_location();
579 web_contents_->GetRenderViewHost()->DragTargetDragOver( 578 web_contents_->GetRenderViewHost()->DragTargetDragOver(
580 event.location(), screen_pt, op); 579 event.location(), screen_pt, op);
581 580
582 if (GetDragDestDelegate()) 581 if (drag_dest_delegate_)
583 GetDragDestDelegate()->OnDragOver(); 582 drag_dest_delegate_->OnDragOver();
584 583
585 return ConvertFromWeb(current_drag_op_); 584 return ConvertFromWeb(current_drag_op_);
586 } 585 }
587 586
588 void WebContentsViewAura::OnDragExited() { 587 void WebContentsViewAura::OnDragExited() {
589 web_contents_->GetRenderViewHost()->DragTargetDragLeave(); 588 web_contents_->GetRenderViewHost()->DragTargetDragLeave();
590 if (GetDragDestDelegate()) 589 if (drag_dest_delegate_)
591 GetDragDestDelegate()->OnDragLeave(); 590 drag_dest_delegate_->OnDragLeave();
592 } 591 }
593 592
594 int WebContentsViewAura::OnPerformDrop(const aura::DropTargetEvent& event) { 593 int WebContentsViewAura::OnPerformDrop(const aura::DropTargetEvent& event) {
595 web_contents_->GetRenderViewHost()->DragTargetDrop( 594 web_contents_->GetRenderViewHost()->DragTargetDrop(
596 event.location(), 595 event.location(),
597 GetNativeView()->GetRootWindow()->last_mouse_location()); 596 GetNativeView()->GetRootWindow()->last_mouse_location());
598 if (GetDragDestDelegate()) 597 if (drag_dest_delegate_)
599 GetDragDestDelegate()->OnDrop(); 598 drag_dest_delegate_->OnDrop();
600 return current_drag_op_; 599 return current_drag_op_;
601 } 600 }
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698