GoogleURLTrackerInfoBarDelegate: Initialize uninitialized member in constructor.
[chromium-blink-merge.git] / ui / views / controls / native / native_view_host_aura.cc
blob49bf733bbe2ae06567f1b9d148db2255b743ab85
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
3 // found in the LICENSE file.
5 #include "ui/views/controls/native/native_view_host_aura.h"
7 #include "base/logging.h"
8 #include "ui/aura/client/focus_client.h"
9 #include "ui/aura/window.h"
10 #include "ui/base/cursor/cursor.h"
11 #include "ui/views/controls/native/native_view_host.h"
12 #include "ui/views/view_constants_aura.h"
13 #include "ui/views/widget/widget.h"
15 namespace views {
17 NativeViewHostAura::NativeViewHostAura(NativeViewHost* host)
18 : host_(host),
19 installed_clip_(false) {
22 NativeViewHostAura::~NativeViewHostAura() {
23 if (host_->native_view()) {
24 host_->native_view()->ClearProperty(views::kHostViewKey);
25 host_->native_view()->RemoveObserver(this);
29 ////////////////////////////////////////////////////////////////////////////////
30 // NativeViewHostAura, NativeViewHostWrapper implementation:
31 void NativeViewHostAura::NativeViewWillAttach() {
32 host_->native_view()->AddObserver(this);
33 host_->native_view()->SetProperty(views::kHostViewKey,
34 static_cast<View*>(host_));
37 void NativeViewHostAura::NativeViewDetaching(bool destroyed) {
38 if (!destroyed) {
39 host_->native_view()->ClearProperty(views::kHostViewKey);
40 host_->native_view()->RemoveObserver(this);
41 host_->native_view()->Hide();
42 if (host_->native_view()->parent())
43 Widget::ReparentNativeView(host_->native_view(), NULL);
47 void NativeViewHostAura::AddedToWidget() {
48 if (!host_->native_view())
49 return;
51 aura::Window* widget_window = host_->GetWidget()->GetNativeView();
52 if (host_->native_view()->parent() != widget_window)
53 widget_window->AddChild(host_->native_view());
54 if (host_->IsDrawn())
55 host_->native_view()->Show();
56 else
57 host_->native_view()->Hide();
58 host_->Layout();
61 void NativeViewHostAura::RemovedFromWidget() {
62 if (host_->native_view()) {
63 host_->native_view()->Hide();
64 if (host_->native_view()->parent())
65 host_->native_view()->parent()->RemoveChild(host_->native_view());
69 void NativeViewHostAura::InstallClip(int x, int y, int w, int h) {
70 // Note that this does not pose a problem functionality wise - it might
71 // however pose a speed degradation if not implemented.
72 LOG(WARNING) << "NativeViewHostAura::InstallClip is not implemented yet.";
75 bool NativeViewHostAura::HasInstalledClip() {
76 return installed_clip_;
79 void NativeViewHostAura::UninstallClip() {
80 installed_clip_ = false;
83 void NativeViewHostAura::ShowWidget(int x, int y, int w, int h) {
84 // TODO: need to support fast resize.
85 host_->native_view()->SetBounds(gfx::Rect(x, y, w, h));
86 host_->native_view()->Show();
89 void NativeViewHostAura::HideWidget() {
90 host_->native_view()->Hide();
93 void NativeViewHostAura::SetFocus() {
94 aura::Window* window = host_->native_view();
95 aura::client::FocusClient* client = aura::client::GetFocusClient(window);
96 if (client)
97 client->FocusWindow(window);
100 gfx::NativeViewAccessible NativeViewHostAura::GetNativeViewAccessible() {
101 return NULL;
104 gfx::NativeCursor NativeViewHostAura::GetCursor(int x, int y) {
105 if (host_->native_view())
106 return host_->native_view()->GetCursor(gfx::Point(x, y));
107 return gfx::kNullCursor;
110 void NativeViewHostAura::OnWindowDestroyed(aura::Window* window) {
111 DCHECK(window == host_->native_view());
112 host_->NativeViewDestroyed();
115 // static
116 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper(
117 NativeViewHost* host) {
118 return new NativeViewHostAura(host);
121 } // namespace views