OLD | NEW |
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 Loading... |
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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 | 475 |
466 bool NativeWidgetAura::IsAccessibleWidget() const { | 476 bool NativeWidgetAura::IsAccessibleWidget() const { |
467 // http://crbug.com/102570 | 477 // http://crbug.com/102570 |
468 //NOTIMPLEMENTED(); | 478 //NOTIMPLEMENTED(); |
469 return false; | 479 return false; |
470 } | 480 } |
471 | 481 |
472 void NativeWidgetAura::RunShellDrag(View* view, | 482 void NativeWidgetAura::RunShellDrag(View* view, |
473 const ui::OSExchangeData& data, | 483 const ui::OSExchangeData& data, |
474 int operation) { | 484 int operation) { |
475 // http://crbug.com/97845 | 485 aura::DragDropClient* client = static_cast<aura::DragDropClient*>( |
476 NOTIMPLEMENTED(); | 486 aura::Desktop::GetInstance()->GetProperty( |
| 487 aura::kDesktopDragDropClientKey)); |
| 488 if (client) |
| 489 client->StartDragAndDrop(data, operation); |
477 } | 490 } |
478 | 491 |
479 void NativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { | 492 void NativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { |
480 if (window_) | 493 if (window_) |
481 window_->SchedulePaintInRect(rect); | 494 window_->SchedulePaintInRect(rect); |
482 } | 495 } |
483 | 496 |
484 void NativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { | 497 void NativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { |
485 cursor_ = cursor; | 498 cursor_ = cursor; |
486 aura::Desktop::GetInstance()->SetCursor(cursor); | 499 aura::Desktop::GetInstance()->SetCursor(cursor); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 | 631 |
619 void NativeWidgetAura::OnCaptureLost() { | 632 void NativeWidgetAura::OnCaptureLost() { |
620 delegate_->OnMouseCaptureLost(); | 633 delegate_->OnMouseCaptureLost(); |
621 } | 634 } |
622 | 635 |
623 void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) { | 636 void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) { |
624 delegate_->OnNativeWidgetPaint(canvas); | 637 delegate_->OnNativeWidgetPaint(canvas); |
625 } | 638 } |
626 | 639 |
627 void NativeWidgetAura::OnWindowDestroying() { | 640 void NativeWidgetAura::OnWindowDestroying() { |
| 641 window_->SetProperty(aura::kDragDropDelegateKey, NULL); |
628 delegate_->OnNativeWidgetDestroying(); | 642 delegate_->OnNativeWidgetDestroying(); |
629 | 643 |
630 // If the aura::Window is destroyed, we can no longer show tooltips. | 644 // If the aura::Window is destroyed, we can no longer show tooltips. |
631 tooltip_manager_.reset(); | 645 tooltip_manager_.reset(); |
632 } | 646 } |
633 | 647 |
634 void NativeWidgetAura::OnWindowDestroyed() { | 648 void NativeWidgetAura::OnWindowDestroyed() { |
635 window_ = NULL; | 649 window_ = NULL; |
636 tooltip_manager_.reset(); | 650 tooltip_manager_.reset(); |
637 delegate_->OnNativeWidgetDestroyed(); | 651 delegate_->OnNativeWidgetDestroyed(); |
638 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 652 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
639 delete this; | 653 delete this; |
640 } | 654 } |
641 | 655 |
642 void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) { | 656 void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) { |
643 delegate_->OnNativeWidgetVisibilityChanged(visible); | 657 delegate_->OnNativeWidgetVisibilityChanged(visible); |
644 } | 658 } |
645 | 659 |
| 660 bool NativeWidgetAura::CanDrop(const aura::DropTargetEvent& event) { |
| 661 DCHECK(drop_helper_.get() != NULL); |
| 662 View* view = drop_helper_->target_view(); |
| 663 if (view) |
| 664 return view->CanDrop(event.data()); |
| 665 return false; |
| 666 } |
| 667 |
| 668 void NativeWidgetAura::OnDragEntered(const aura::DropTargetEvent& event) { |
| 669 DCHECK(drop_helper_.get() != NULL); |
| 670 drop_helper_->OnDragOver(event.data(), event.location(), |
| 671 event.source_operations()); |
| 672 } |
| 673 |
| 674 int NativeWidgetAura::OnDragUpdated(const aura::DropTargetEvent& event) { |
| 675 DCHECK(drop_helper_.get() != NULL); |
| 676 return drop_helper_->OnDragOver(event.data(), event.location(), |
| 677 event.source_operations()); |
| 678 } |
| 679 |
| 680 void NativeWidgetAura::OnDragExited() { |
| 681 DCHECK(drop_helper_.get() != NULL); |
| 682 drop_helper_->OnDragExit(); |
| 683 } |
| 684 |
| 685 int NativeWidgetAura::OnPerformDrop(const aura::DropTargetEvent& event) { |
| 686 DCHECK(drop_helper_.get() != NULL); |
| 687 return drop_helper_->OnDrop(event.data(), event.location(), |
| 688 event.source_operations()); |
| 689 } |
| 690 |
646 //////////////////////////////////////////////////////////////////////////////// | 691 //////////////////////////////////////////////////////////////////////////////// |
647 // Widget, public: | 692 // Widget, public: |
648 | 693 |
649 // static | 694 // static |
650 void Widget::NotifyLocaleChanged() { | 695 void Widget::NotifyLocaleChanged() { |
651 // http://crbug.com/102574 | 696 // http://crbug.com/102574 |
652 NOTIMPLEMENTED(); | 697 NOTIMPLEMENTED(); |
653 } | 698 } |
654 | 699 |
655 // static | 700 // static |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 NOTIMPLEMENTED(); | 774 NOTIMPLEMENTED(); |
730 } | 775 } |
731 | 776 |
732 // static | 777 // static |
733 bool NativeWidgetPrivate::IsMouseButtonDown() { | 778 bool NativeWidgetPrivate::IsMouseButtonDown() { |
734 return aura::Desktop::GetInstance()->IsMouseButtonDown(); | 779 return aura::Desktop::GetInstance()->IsMouseButtonDown(); |
735 } | 780 } |
736 | 781 |
737 } // namespace internal | 782 } // namespace internal |
738 } // namespace views | 783 } // namespace views |
OLD | NEW |