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

Side by Side Diff: views/widget/native_widget_aura.cc

Issue 8450018: First shot at implementing drag&drop for Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor changes Created 9 years, 1 month 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
« views/views.gyp ('K') | « views/widget/native_widget_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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/widget/native_widget_aura.h" 5 #include "views/widget/native_widget_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/string_util.h"
8 #include "ui/aura/client/aura_constants.h" 9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/client/drag_drop_client.h"
9 #include "ui/aura/desktop.h" 11 #include "ui/aura/desktop.h"
10 #include "ui/aura/desktop_observer.h" 12 #include "ui/aura/desktop_observer.h"
11 #include "ui/aura/event.h" 13 #include "ui/aura/event.h"
12 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
13 #include "ui/aura/window_types.h" 15 #include "ui/aura/window_types.h"
16 #include "ui/base/dragdrop/os_exchange_data.h"
14 #include "ui/base/ui_base_types.h" 17 #include "ui/base/ui_base_types.h"
15 #include "ui/gfx/canvas.h" 18 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/compositor/layer.h" 19 #include "ui/gfx/compositor/layer.h"
17 #include "ui/gfx/font.h" 20 #include "ui/gfx/font.h"
18 #include "ui/gfx/screen.h" 21 #include "ui/gfx/screen.h"
22 #include "views/widget/drop_helper.h"
19 #include "views/widget/native_widget_delegate.h" 23 #include "views/widget/native_widget_delegate.h"
20 #include "views/widget/tooltip_manager_views.h" 24 #include "views/widget/tooltip_manager_views.h"
21 25
22 #if defined(OS_WIN) 26 #if defined(OS_WIN)
23 #include "base/win/scoped_gdi_object.h" 27 #include "base/win/scoped_gdi_object.h"
24 #include "base/win/win_util.h" 28 #include "base/win/win_util.h"
25 #include "ui/base/l10n/l10n_util_win.h" 29 #include "ui/base/l10n/l10n_util_win.h"
26 #endif 30 #endif
27 31
28 #if defined(HAVE_IBUS) 32 #if defined(HAVE_IBUS)
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 gfx::NativeView parent = params.GetParent(); 147 gfx::NativeView parent = params.GetParent();
144 if (parent) 148 if (parent)
145 parent->AddTransientChild(window_); 149 parent->AddTransientChild(window_);
146 // SetAlwaysOnTop before SetParent so that always-on-top container is used. 150 // SetAlwaysOnTop before SetParent so that always-on-top container is used.
147 SetAlwaysOnTop(params.keep_on_top); 151 SetAlwaysOnTop(params.keep_on_top);
148 window_->SetParent(NULL); 152 window_->SetParent(NULL);
149 } 153 }
150 // TODO(beng): do this some other way. 154 // TODO(beng): do this some other way.
151 delegate_->OnNativeWidgetSizeChanged(params.bounds.size()); 155 delegate_->OnNativeWidgetSizeChanged(params.bounds.size());
152 can_activate_ = params.can_activate; 156 can_activate_ = params.can_activate;
157 DCHECK(GetWidget()->GetRootView());
153 if (params.type != Widget::InitParams::TYPE_TOOLTIP && !params.child) { 158 if (params.type != Widget::InitParams::TYPE_TOOLTIP && !params.child) {
154 DCHECK(GetWidget()->GetRootView());
155 views::TooltipManagerViews* manager = new views::TooltipManagerViews( 159 views::TooltipManagerViews* manager = new views::TooltipManagerViews(
156 GetWidget()->GetRootView()); 160 GetWidget()->GetRootView());
157 tooltip_manager_.reset(manager); 161 tooltip_manager_.reset(manager);
158 } 162 }
163 drop_helper_.reset(new DropHelper(GetWidget()->GetRootView()));
164 if (params.type != Widget::InitParams::TYPE_TOOLTIP &&
165 params.type != Widget::InitParams::TYPE_POPUP) {
166 window_->SetProperty(aura::kDragDropDelegateKey,
167 static_cast<aura::WindowDragDropDelegate*>(this));
168 }
159 } 169 }
160 170
161 NonClientFrameView* NativeWidgetAura::CreateNonClientFrameView() { 171 NonClientFrameView* NativeWidgetAura::CreateNonClientFrameView() {
162 return NULL; 172 return NULL;
163 } 173 }
164 174
165 void NativeWidgetAura::UpdateFrameAfterFrameChange() { 175 void NativeWidgetAura::UpdateFrameAfterFrameChange() {
166 // We don't support changing the frame type. 176 // We don't support changing the frame type.
167 NOTREACHED(); 177 NOTREACHED();
168 } 178 }
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 468
459 bool NativeWidgetAura::IsAccessibleWidget() const { 469 bool NativeWidgetAura::IsAccessibleWidget() const {
460 // http://crbug.com/102570 470 // http://crbug.com/102570
461 //NOTIMPLEMENTED(); 471 //NOTIMPLEMENTED();
462 return false; 472 return false;
463 } 473 }
464 474
465 void NativeWidgetAura::RunShellDrag(View* view, 475 void NativeWidgetAura::RunShellDrag(View* view,
466 const ui::OSExchangeData& data, 476 const ui::OSExchangeData& data,
467 int operation) { 477 int operation) {
468 // http://crbug.com/97845 478 aura::DragDropClient* client = static_cast<aura::DragDropClient*>(
469 NOTIMPLEMENTED(); 479 aura::Desktop::GetInstance()->GetProperty(
480 aura::kDesktopDragDropClientKey));
481 if (client)
482 client->StartDragAndDrop(data, operation);
470 } 483 }
471 484
472 void NativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { 485 void NativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) {
473 if (window_) 486 if (window_)
474 window_->SchedulePaintInRect(rect); 487 window_->SchedulePaintInRect(rect);
475 } 488 }
476 489
477 void NativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { 490 void NativeWidgetAura::SetCursor(gfx::NativeCursor cursor) {
478 cursor_ = cursor; 491 cursor_ = cursor;
479 aura::Desktop::GetInstance()->SetCursor(cursor); 492 aura::Desktop::GetInstance()->SetCursor(cursor);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 624
612 void NativeWidgetAura::OnCaptureLost() { 625 void NativeWidgetAura::OnCaptureLost() {
613 delegate_->OnMouseCaptureLost(); 626 delegate_->OnMouseCaptureLost();
614 } 627 }
615 628
616 void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) { 629 void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) {
617 delegate_->OnNativeWidgetPaint(canvas); 630 delegate_->OnNativeWidgetPaint(canvas);
618 } 631 }
619 632
620 void NativeWidgetAura::OnWindowDestroying() { 633 void NativeWidgetAura::OnWindowDestroying() {
634 window_->SetProperty(aura::kDragDropDelegateKey, NULL);
621 delegate_->OnNativeWidgetDestroying(); 635 delegate_->OnNativeWidgetDestroying();
622 636
623 // If the aura::Window is destroyed, we can no longer show tooltips. 637 // If the aura::Window is destroyed, we can no longer show tooltips.
624 tooltip_manager_.reset(); 638 tooltip_manager_.reset();
625 } 639 }
626 640
627 void NativeWidgetAura::OnWindowDestroyed() { 641 void NativeWidgetAura::OnWindowDestroyed() {
628 window_ = NULL; 642 window_ = NULL;
629 tooltip_manager_.reset(); 643 tooltip_manager_.reset();
630 delegate_->OnNativeWidgetDestroyed(); 644 delegate_->OnNativeWidgetDestroyed();
631 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) 645 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
632 delete this; 646 delete this;
633 } 647 }
634 648
635 void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) { 649 void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) {
636 delegate_->OnNativeWidgetVisibilityChanged(visible); 650 delegate_->OnNativeWidgetVisibilityChanged(visible);
637 } 651 }
638 652
653 bool NativeWidgetAura::CanDrop(const aura::DropTargetEvent& event) {
654 DCHECK(drop_helper_.get() != NULL);
655 View* view = drop_helper_->target_view();
656 if (view)
657 return view->CanDrop(event.data());
658 return false;
659 }
660
661 void NativeWidgetAura::OnDragEntered(const aura::DropTargetEvent& event) {
662 DCHECK(drop_helper_.get() != NULL);
663 drop_helper_->OnDragOver(event.data(), event.location(),
664 event.source_operations());
665 }
666
667 int NativeWidgetAura::OnDragUpdated(const aura::DropTargetEvent& event) {
668 DCHECK(drop_helper_.get() != NULL);
669 return drop_helper_->OnDragOver(event.data(), event.location(),
670 event.source_operations());
671 }
672
673 void NativeWidgetAura::OnDragExited() {
674 DCHECK(drop_helper_.get() != NULL);
675 drop_helper_->OnDragExit();
676 }
677
678 int NativeWidgetAura::OnPerformDrop(const aura::DropTargetEvent& event) {
679 DCHECK(drop_helper_.get() != NULL);
680 return drop_helper_->OnDrop(event.data(), event.location(),
681 event.source_operations());
682 }
683
639 //////////////////////////////////////////////////////////////////////////////// 684 ////////////////////////////////////////////////////////////////////////////////
640 // Widget, public: 685 // Widget, public:
641 686
642 // static 687 // static
643 void Widget::NotifyLocaleChanged() { 688 void Widget::NotifyLocaleChanged() {
644 // http://crbug.com/102574 689 // http://crbug.com/102574
645 NOTIMPLEMENTED(); 690 NOTIMPLEMENTED();
646 } 691 }
647 692
648 // static 693 // static
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 NOTIMPLEMENTED(); 767 NOTIMPLEMENTED();
723 } 768 }
724 769
725 // static 770 // static
726 bool NativeWidgetPrivate::IsMouseButtonDown() { 771 bool NativeWidgetPrivate::IsMouseButtonDown() {
727 return aura::Desktop::GetInstance()->IsMouseButtonDown(); 772 return aura::Desktop::GetInstance()->IsMouseButtonDown();
728 } 773 }
729 774
730 } // namespace internal 775 } // namespace internal
731 } // namespace views 776 } // namespace views
OLDNEW
« views/views.gyp ('K') | « views/widget/native_widget_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698