blob: 76949be2f0e273b6429fa3150c17ca5bfe64f8c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "views/controls/native/native_view_host_aura.h"
#include "base/logging.h"
#include "ui/aura/focus_manager.h"
#include "ui/aura/window.h"
#include "views/controls/native/native_view_host.h"
#include "views/widget/widget.h"
namespace views {
NativeViewHostAura::NativeViewHostAura(NativeViewHost* host)
: host_(host),
installed_clip_(false) {
}
NativeViewHostAura::~NativeViewHostAura() {
}
////////////////////////////////////////////////////////////////////////////////
// NativeViewHostAura, NativeViewHostWrapper implementation:
void NativeViewHostAura::NativeViewAttached() {
host_->GetWidget()->GetNativeView()->AddChild(host_->native_view());
host_->Layout();
}
void NativeViewHostAura::NativeViewDetaching(bool destroyed) {
}
void NativeViewHostAura::AddedToWidget() {
if (!host_->native_view())
return;
aura::Window* widget_window = host_->GetWidget()->GetNativeView();
if (host_->native_view()->parent() != widget_window)
widget_window->AddChild(host_->native_view());
if (host_->IsVisibleInRootView())
host_->native_view()->Show();
else
host_->native_view()->Hide();
host_->Layout();
}
void NativeViewHostAura::RemovedFromWidget() {
if (host_->native_view() && host_->native_view()->parent())
host_->native_view()->parent()->RemoveChild(host_->native_view());
}
void NativeViewHostAura::InstallClip(int x, int y, int w, int h) {
NOTIMPLEMENTED();
}
bool NativeViewHostAura::HasInstalledClip() {
return installed_clip_;
}
void NativeViewHostAura::UninstallClip() {
installed_clip_ = false;
}
void NativeViewHostAura::ShowWidget(int x, int y, int w, int h) {
// TODO: need to support fast resize.
host_->native_view()->SetBounds(gfx::Rect(x, y, w, h));
}
void NativeViewHostAura::HideWidget() {
host_->native_view()->Hide();
}
void NativeViewHostAura::SetFocus() {
aura::Window* window = host_->native_view();
if (window->GetFocusManager())
window->GetFocusManager()->SetFocusedWindow(window);
}
gfx::NativeViewAccessible NativeViewHostAura::GetNativeViewAccessible() {
return NULL;
}
// static
NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper(
NativeViewHost* host) {
return new NativeViewHostAura(host);
}
} // namespace views
|