| 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/controls/native/native_view_host_aura.h" | 5 #include "views/controls/native/native_view_host_aura.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/aura/focus_manager.h" | 8 #include "ui/aura/focus_manager.h" |
| 9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 10 #include "views/controls/native/native_view_host.h" | 10 #include "views/controls/native/native_view_host.h" |
| 11 #include "views/widget/widget.h" | 11 #include "views/widget/widget.h" |
| 12 | 12 |
| 13 namespace views { | 13 namespace views { |
| 14 | 14 |
| 15 NativeViewHostAura::NativeViewHostAura(NativeViewHost* host) | 15 NativeViewHostAura::NativeViewHostAura(NativeViewHost* host) |
| 16 : host_(host), | 16 : host_(host), |
| 17 installed_clip_(false) { | 17 installed_clip_(false) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 NativeViewHostAura::~NativeViewHostAura() { | 20 NativeViewHostAura::~NativeViewHostAura() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 //////////////////////////////////////////////////////////////////////////////// | 23 //////////////////////////////////////////////////////////////////////////////// |
| 24 // NativeViewHostAura, NativeViewHostWrapper implementation: | 24 // NativeViewHostAura, NativeViewHostWrapper implementation: |
| 25 void NativeViewHostAura::NativeViewAttached() { | 25 void NativeViewHostAura::NativeViewAttached() { |
| 26 if (host_->native_view()->parent()) | 26 if (host_->native_view()->parent()) |
| 27 host_->native_view()->parent()->RemoveChild(host_->native_view()); | 27 host_->native_view()->parent()->RemoveChild(host_->native_view()); |
| 28 host_->GetWidget()->GetNativeView()->AddChild(host_->native_view()); | 28 host_->GetWidget()->GetNativeView()->AddChild(host_->native_view()); |
| 29 host_->native_view()->Show(); | |
| 30 host_->Layout(); | 29 host_->Layout(); |
| 31 } | 30 } |
| 32 | 31 |
| 33 void NativeViewHostAura::NativeViewDetaching(bool destroyed) { | 32 void NativeViewHostAura::NativeViewDetaching(bool destroyed) { |
| 34 host_->native_view()->Hide(); | 33 host_->native_view()->Hide(); |
| 35 host_->GetWidget()->GetNativeView()->RemoveChild(host_->native_view()); | 34 host_->GetWidget()->GetNativeView()->RemoveChild(host_->native_view()); |
| 36 } | 35 } |
| 37 | 36 |
| 38 void NativeViewHostAura::AddedToWidget() { | 37 void NativeViewHostAura::AddedToWidget() { |
| 39 if (!host_->native_view()) | 38 if (!host_->native_view()) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 62 return installed_clip_; | 61 return installed_clip_; |
| 63 } | 62 } |
| 64 | 63 |
| 65 void NativeViewHostAura::UninstallClip() { | 64 void NativeViewHostAura::UninstallClip() { |
| 66 installed_clip_ = false; | 65 installed_clip_ = false; |
| 67 } | 66 } |
| 68 | 67 |
| 69 void NativeViewHostAura::ShowWidget(int x, int y, int w, int h) { | 68 void NativeViewHostAura::ShowWidget(int x, int y, int w, int h) { |
| 70 // TODO: need to support fast resize. | 69 // TODO: need to support fast resize. |
| 71 host_->native_view()->SetBounds(gfx::Rect(x, y, w, h)); | 70 host_->native_view()->SetBounds(gfx::Rect(x, y, w, h)); |
| 71 host_->native_view()->Show(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void NativeViewHostAura::HideWidget() { | 74 void NativeViewHostAura::HideWidget() { |
| 75 host_->native_view()->Hide(); | 75 host_->native_view()->Hide(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void NativeViewHostAura::SetFocus() { | 78 void NativeViewHostAura::SetFocus() { |
| 79 aura::Window* window = host_->native_view(); | 79 aura::Window* window = host_->native_view(); |
| 80 if (window->GetFocusManager()) | 80 if (window->GetFocusManager()) |
| 81 window->GetFocusManager()->SetFocusedWindow(window); | 81 window->GetFocusManager()->SetFocusedWindow(window); |
| 82 } | 82 } |
| 83 | 83 |
| 84 gfx::NativeViewAccessible NativeViewHostAura::GetNativeViewAccessible() { | 84 gfx::NativeViewAccessible NativeViewHostAura::GetNativeViewAccessible() { |
| 85 return NULL; | 85 return NULL; |
| 86 } | 86 } |
| 87 | 87 |
| 88 // static | 88 // static |
| 89 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( | 89 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( |
| 90 NativeViewHost* host) { | 90 NativeViewHost* host) { |
| 91 return new NativeViewHostAura(host); | 91 return new NativeViewHostAura(host); |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace views | 94 } // namespace views |
| OLD | NEW |