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 "base/command_line.h" | 8 #include "base/command_line.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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 return; | 171 return; |
172 animator_->RemoveObserver(this); | 172 animator_->RemoveObserver(this); |
173 callback_.Run(); | 173 callback_.Run(); |
174 } | 174 } |
175 | 175 |
176 void CallbackAnimationObserver::OnLayerAnimationAborted( | 176 void CallbackAnimationObserver::OnLayerAnimationAborted( |
177 ui::LayerAnimationSequence* seq) { | 177 ui::LayerAnimationSequence* seq) { |
178 animator_->RemoveObserver(this); | 178 animator_->RemoveObserver(this); |
179 } | 179 } |
180 | 180 |
181 // static | |
182 KeyboardController* KeyboardController::instance_ = NULL; | |
not at google - send to devlin
2014/04/01 16:05:12
typically you would use base::Singleton for single
| |
183 | |
181 KeyboardController::KeyboardController(KeyboardControllerProxy* proxy) | 184 KeyboardController::KeyboardController(KeyboardControllerProxy* proxy) |
182 : proxy_(proxy), | 185 : proxy_(proxy), |
183 input_method_(NULL), | 186 input_method_(NULL), |
184 keyboard_visible_(false), | 187 keyboard_visible_(false), |
185 lock_keyboard_(false), | 188 lock_keyboard_(false), |
186 type_(ui::TEXT_INPUT_TYPE_NONE), | 189 type_(ui::TEXT_INPUT_TYPE_NONE), |
187 weak_factory_(this) { | 190 weak_factory_(this) { |
188 CHECK(proxy); | 191 CHECK(proxy); |
189 input_method_ = proxy_->GetInputMethod(); | 192 input_method_ = proxy_->GetInputMethod(); |
190 input_method_->AddObserver(this); | 193 input_method_->AddObserver(this); |
191 } | 194 } |
192 | 195 |
193 KeyboardController::~KeyboardController() { | 196 KeyboardController::~KeyboardController() { |
194 if (container_) | 197 if (container_) |
195 container_->RemoveObserver(this); | 198 container_->RemoveObserver(this); |
196 if (input_method_) | 199 if (input_method_) |
197 input_method_->RemoveObserver(this); | 200 input_method_->RemoveObserver(this); |
198 } | 201 } |
199 | 202 |
203 // static | |
204 void KeyboardController::ResetInstance(KeyboardController* controller) { | |
205 if (instance_ && instance_ != controller) | |
206 delete instance_; | |
207 instance_ = controller; | |
208 } | |
209 | |
210 // static | |
211 KeyboardController* KeyboardController::GetInstance() { | |
212 return instance_; | |
213 } | |
214 | |
200 aura::Window* KeyboardController::GetContainerWindow() { | 215 aura::Window* KeyboardController::GetContainerWindow() { |
201 if (!container_.get()) { | 216 if (!container_.get()) { |
202 container_.reset(new aura::Window( | 217 container_.reset(new aura::Window( |
203 new KeyboardWindowDelegate(proxy_.get()))); | 218 new KeyboardWindowDelegate(proxy_.get()))); |
204 container_->SetEventTargeter(scoped_ptr<ui::EventTargeter>( | 219 container_->SetEventTargeter(scoped_ptr<ui::EventTargeter>( |
205 new KeyboardContainerTargeter(container_.get(), proxy_.get()))); | 220 new KeyboardContainerTargeter(container_.get(), proxy_.get()))); |
206 container_->SetName("KeyboardContainer"); | 221 container_->SetName("KeyboardContainer"); |
207 container_->set_owned_by_parent(false); | 222 container_->set_owned_by_parent(false); |
208 container_->Init(aura::WINDOW_LAYER_NOT_DRAWN); | 223 container_->Init(aura::WINDOW_LAYER_NOT_DRAWN); |
209 container_->AddObserver(this); | 224 container_->AddObserver(this); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 // background during animation. | 424 // background during animation. |
410 NotifyKeyboardBoundsChanging(proxy_->GetKeyboardWindow()->bounds()); | 425 NotifyKeyboardBoundsChanging(proxy_->GetKeyboardWindow()->bounds()); |
411 proxy_->EnsureCaretInWorkArea(); | 426 proxy_->EnsureCaretInWorkArea(); |
412 } | 427 } |
413 | 428 |
414 void KeyboardController::HideAnimationFinished() { | 429 void KeyboardController::HideAnimationFinished() { |
415 proxy_->HideKeyboardContainer(container_.get()); | 430 proxy_->HideKeyboardContainer(container_.get()); |
416 } | 431 } |
417 | 432 |
418 } // namespace keyboard | 433 } // namespace keyboard |
OLD | NEW |