OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/keyboard/keyboard_controller.h" | 5 #include "ui/keyboard/keyboard_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "ui/aura/layout_manager.h" | 8 #include "ui/aura/layout_manager.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/aura/window_delegate.h" | 10 #include "ui/aura/window_delegate.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 | 122 |
123 KeyboardController::KeyboardController(KeyboardControllerProxy* proxy) | 123 KeyboardController::KeyboardController(KeyboardControllerProxy* proxy) |
124 : proxy_(proxy), | 124 : proxy_(proxy), |
125 container_(NULL), | 125 container_(NULL), |
126 input_method_(NULL), | 126 input_method_(NULL), |
127 keyboard_visible_(false), | 127 keyboard_visible_(false), |
128 weak_factory_(this) { | 128 weak_factory_(this) { |
129 CHECK(proxy); | 129 CHECK(proxy); |
130 input_method_ = proxy_->GetInputMethod(); | 130 input_method_ = proxy_->GetInputMethod(); |
131 input_method_->AddObserver(this); | 131 input_method_->AddObserver(this); |
132 container_ = new aura::Window(new KeyboardWindowDelegate()); | |
133 container_->SetName("KeyboardContainer"); | |
134 container_->Init(ui::LAYER_NOT_DRAWN); | |
135 container_->AddObserver(this); | |
136 container_->SetLayoutManager(new KeyboardLayoutManager(container_)); | |
sadrul
2013/10/03 15:26:28
Is this change necessary?
bshe
2013/10/03 15:57:13
dooh. noop. It was from one of my experimental ref
bshe
2013/10/04 00:58:08
Done.
| |
132 } | 137 } |
133 | 138 |
134 KeyboardController::~KeyboardController() { | 139 KeyboardController::~KeyboardController() { |
135 if (container_) | 140 if (container_) |
136 container_->RemoveObserver(this); | 141 container_->RemoveObserver(this); |
137 if (input_method_) | 142 if (input_method_) |
138 input_method_->RemoveObserver(this); | 143 input_method_->RemoveObserver(this); |
139 } | 144 } |
140 | 145 |
141 aura::Window* KeyboardController::GetContainerWindow() { | 146 aura::Window* KeyboardController::GetContainerWindow() { |
142 if (!container_) { | |
143 container_ = new aura::Window(new KeyboardWindowDelegate()); | |
144 container_->SetName("KeyboardContainer"); | |
145 container_->Init(ui::LAYER_NOT_DRAWN); | |
146 container_->AddObserver(this); | |
147 container_->SetLayoutManager(new KeyboardLayoutManager(container_)); | |
148 } | |
149 return container_; | 147 return container_; |
150 } | 148 } |
151 | 149 |
152 void KeyboardController::HideKeyboard() { | 150 void KeyboardController::HideKeyboard() { |
153 keyboard_visible_ = false; | 151 keyboard_visible_ = false; |
154 | 152 |
155 FOR_EACH_OBSERVER(KeyboardControllerObserver, | 153 FOR_EACH_OBSERVER(KeyboardControllerObserver, |
156 observer_list_, | 154 observer_list_, |
157 OnKeyboardBoundsChanging(gfx::Rect())); | 155 OnKeyboardBoundsChanging(gfx::Rect())); |
158 | 156 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 const ui::InputMethod* input_method) { | 231 const ui::InputMethod* input_method) { |
234 DCHECK_EQ(input_method_, input_method); | 232 DCHECK_EQ(input_method_, input_method); |
235 input_method_ = NULL; | 233 input_method_ = NULL; |
236 } | 234 } |
237 | 235 |
238 bool KeyboardController::WillHideKeyboard() const { | 236 bool KeyboardController::WillHideKeyboard() const { |
239 return weak_factory_.HasWeakPtrs(); | 237 return weak_factory_.HasWeakPtrs(); |
240 } | 238 } |
241 | 239 |
242 } // namespace keyboard | 240 } // namespace keyboard |
OLD | NEW |