| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 //////////////////////////////////////////////////////////////////////////////// | 90 //////////////////////////////////////////////////////////////////////////////// |
| 87 // NativeWidgetAura, public: | 91 // NativeWidgetAura, public: |
| 88 | 92 |
| 89 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) | 93 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) |
| 90 : delegate_(delegate), | 94 : delegate_(delegate), |
| 91 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), | 95 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), |
| 92 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 96 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 93 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), | 97 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), |
| 94 can_activate_(true), | 98 can_activate_(true), |
| 95 cursor_(gfx::kNullCursor) { | 99 cursor_(gfx::kNullCursor) { |
| 100 window_->set_drag_drop_delegate(this); |
| 96 } | 101 } |
| 97 | 102 |
| 98 NativeWidgetAura::~NativeWidgetAura() { | 103 NativeWidgetAura::~NativeWidgetAura() { |
| 99 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 104 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
| 100 delete delegate_; | 105 delete delegate_; |
| 101 else | 106 else |
| 102 CloseNow(); | 107 CloseNow(); |
| 103 } | 108 } |
| 104 | 109 |
| 105 // static | 110 // static |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // Set up the transient child before the window is added. This way the | 146 // Set up the transient child before the window is added. This way the |
| 142 // LayoutManager knows the window has a transient parent. | 147 // LayoutManager knows the window has a transient parent. |
| 143 gfx::NativeView parent = params.GetParent(); | 148 gfx::NativeView parent = params.GetParent(); |
| 144 if (parent) | 149 if (parent) |
| 145 parent->AddTransientChild(window_); | 150 parent->AddTransientChild(window_); |
| 146 window_->SetParent(NULL); | 151 window_->SetParent(NULL); |
| 147 } | 152 } |
| 148 // TODO(beng): do this some other way. | 153 // TODO(beng): do this some other way. |
| 149 delegate_->OnNativeWidgetSizeChanged(params.bounds.size()); | 154 delegate_->OnNativeWidgetSizeChanged(params.bounds.size()); |
| 150 can_activate_ = params.can_activate; | 155 can_activate_ = params.can_activate; |
| 156 DCHECK(GetWidget()->GetRootView()); |
| 151 if (params.type != Widget::InitParams::TYPE_TOOLTIP && !params.child) { | 157 if (params.type != Widget::InitParams::TYPE_TOOLTIP && !params.child) { |
| 152 DCHECK(GetWidget()->GetRootView()); | |
| 153 views::TooltipManagerViews* manager = new views::TooltipManagerViews( | 158 views::TooltipManagerViews* manager = new views::TooltipManagerViews( |
| 154 GetWidget()->GetRootView()); | 159 GetWidget()->GetRootView()); |
| 155 tooltip_manager_.reset(manager); | 160 tooltip_manager_.reset(manager); |
| 156 } | 161 } |
| 162 drop_helper_.reset(new DropHelper(GetWidget()->GetRootView())); |
| 157 } | 163 } |
| 158 | 164 |
| 159 NonClientFrameView* NativeWidgetAura::CreateNonClientFrameView() { | 165 NonClientFrameView* NativeWidgetAura::CreateNonClientFrameView() { |
| 160 return NULL; | 166 return NULL; |
| 161 } | 167 } |
| 162 | 168 |
| 163 void NativeWidgetAura::UpdateFrameAfterFrameChange() { | 169 void NativeWidgetAura::UpdateFrameAfterFrameChange() { |
| 164 // We don't support changing the frame type. | 170 // We don't support changing the frame type. |
| 165 NOTREACHED(); | 171 NOTREACHED(); |
| 166 } | 172 } |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 | 463 |
| 458 bool NativeWidgetAura::IsAccessibleWidget() const { | 464 bool NativeWidgetAura::IsAccessibleWidget() const { |
| 459 // http://crbug.com/102570 | 465 // http://crbug.com/102570 |
| 460 //NOTIMPLEMENTED(); | 466 //NOTIMPLEMENTED(); |
| 461 return false; | 467 return false; |
| 462 } | 468 } |
| 463 | 469 |
| 464 void NativeWidgetAura::RunShellDrag(View* view, | 470 void NativeWidgetAura::RunShellDrag(View* view, |
| 465 const ui::OSExchangeData& data, | 471 const ui::OSExchangeData& data, |
| 466 int operation) { | 472 int operation) { |
| 467 // http://crbug.com/97845 | 473 aura::Desktop::GetInstance()->drag_drop_client()->StartDragAndDrop( |
| 468 NOTIMPLEMENTED(); | 474 data, operation); |
| 469 } | 475 } |
| 470 | 476 |
| 471 void NativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { | 477 void NativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { |
| 472 if (window_) | 478 if (window_) |
| 473 window_->SchedulePaintInRect(rect); | 479 window_->SchedulePaintInRect(rect); |
| 474 } | 480 } |
| 475 | 481 |
| 476 void NativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { | 482 void NativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { |
| 477 cursor_ = cursor; | 483 cursor_ = cursor; |
| 478 aura::Desktop::GetInstance()->SetCursor(cursor); | 484 aura::Desktop::GetInstance()->SetCursor(cursor); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 tooltip_manager_.reset(); | 632 tooltip_manager_.reset(); |
| 627 delegate_->OnNativeWidgetDestroyed(); | 633 delegate_->OnNativeWidgetDestroyed(); |
| 628 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 634 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
| 629 delete this; | 635 delete this; |
| 630 } | 636 } |
| 631 | 637 |
| 632 void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) { | 638 void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) { |
| 633 delegate_->OnNativeWidgetVisibilityChanged(visible); | 639 delegate_->OnNativeWidgetVisibilityChanged(visible); |
| 634 } | 640 } |
| 635 | 641 |
| 642 bool NativeWidgetAura::CanDrop(const aura::DropTargetEvent& event) { |
| 643 DCHECK(drop_helper_.get() != NULL); |
| 644 View* view = drop_helper_->target_view(); |
| 645 if (view) |
| 646 return view->CanDrop(event.data()); |
| 647 return false; |
| 648 } |
| 649 |
| 650 void NativeWidgetAura::OnDragEntered(const aura::DropTargetEvent& event) { |
| 651 DCHECK(drop_helper_.get() != NULL); |
| 652 drop_helper_->OnDragOver(event.data(), event.location(), |
| 653 event.source_operations()); |
| 654 } |
| 655 |
| 656 int NativeWidgetAura::OnDragUpdated(const aura::DropTargetEvent& event) { |
| 657 DCHECK(drop_helper_.get() != NULL); |
| 658 return drop_helper_->OnDragOver(event.data(), event.location(), |
| 659 event.source_operations()); |
| 660 } |
| 661 |
| 662 void NativeWidgetAura::OnDragExited() { |
| 663 DCHECK(drop_helper_.get() != NULL); |
| 664 drop_helper_->OnDragExit(); |
| 665 } |
| 666 |
| 667 int NativeWidgetAura::OnPerformDrop(const aura::DropTargetEvent& event) { |
| 668 DCHECK(drop_helper_.get() != NULL); |
| 669 return drop_helper_->OnDrop(event.data(), event.location(), |
| 670 event.source_operations()); |
| 671 } |
| 672 |
| 636 //////////////////////////////////////////////////////////////////////////////// | 673 //////////////////////////////////////////////////////////////////////////////// |
| 637 // Widget, public: | 674 // Widget, public: |
| 638 | 675 |
| 639 // static | 676 // static |
| 640 void Widget::NotifyLocaleChanged() { | 677 void Widget::NotifyLocaleChanged() { |
| 641 // http://crbug.com/102574 | 678 // http://crbug.com/102574 |
| 642 NOTIMPLEMENTED(); | 679 NOTIMPLEMENTED(); |
| 643 } | 680 } |
| 644 | 681 |
| 645 // static | 682 // static |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 | 758 |
| 722 // static | 759 // static |
| 723 bool NativeWidgetPrivate::IsMouseButtonDown() { | 760 bool NativeWidgetPrivate::IsMouseButtonDown() { |
| 724 // http://crbug.com/102577 | 761 // http://crbug.com/102577 |
| 725 NOTIMPLEMENTED(); | 762 NOTIMPLEMENTED(); |
| 726 return false; | 763 return false; |
| 727 } | 764 } |
| 728 | 765 |
| 729 } // namespace internal | 766 } // namespace internal |
| 730 } // namespace views | 767 } // namespace views |
| OLD | NEW |