Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(817)

Side by Side Diff: ui/keyboard/keyboard_controller.cc

Issue 219503003: Make keyboard controller a singleton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 return; 173 return;
174 animator_->RemoveObserver(this); 174 animator_->RemoveObserver(this);
175 callback_.Run(); 175 callback_.Run();
176 } 176 }
177 177
178 void CallbackAnimationObserver::OnLayerAnimationAborted( 178 void CallbackAnimationObserver::OnLayerAnimationAborted(
179 ui::LayerAnimationSequence* seq) { 179 ui::LayerAnimationSequence* seq) {
180 animator_->RemoveObserver(this); 180 animator_->RemoveObserver(this);
181 } 181 }
182 182
183 // static
184 KeyboardController* KeyboardController::instance_ = NULL;
185
183 KeyboardController::KeyboardController(KeyboardControllerProxy* proxy) 186 KeyboardController::KeyboardController(KeyboardControllerProxy* proxy)
184 : proxy_(proxy), 187 : proxy_(proxy),
185 input_method_(NULL), 188 input_method_(NULL),
186 keyboard_visible_(false), 189 keyboard_visible_(false),
187 lock_keyboard_(false), 190 lock_keyboard_(false),
188 type_(ui::TEXT_INPUT_TYPE_NONE), 191 type_(ui::TEXT_INPUT_TYPE_NONE),
189 weak_factory_(this) { 192 weak_factory_(this) {
190 CHECK(proxy); 193 CHECK(proxy);
191 input_method_ = proxy_->GetInputMethod(); 194 input_method_ = proxy_->GetInputMethod();
192 input_method_->AddObserver(this); 195 input_method_->AddObserver(this);
193 } 196 }
194 197
195 KeyboardController::~KeyboardController() { 198 KeyboardController::~KeyboardController() {
196 if (container_) 199 if (container_)
197 container_->RemoveObserver(this); 200 container_->RemoveObserver(this);
198 if (input_method_) 201 if (input_method_)
199 input_method_->RemoveObserver(this); 202 input_method_->RemoveObserver(this);
200 } 203 }
201 204
205 // static
206 void KeyboardController::ResetInstance(KeyboardController* controller) {
207 if (instance_ && instance_ != controller)
208 delete instance_;
209 instance_ = controller;
210 }
211
212 // static
213 KeyboardController* KeyboardController::GetInstance() {
214 return instance_;
215 }
216
202 aura::Window* KeyboardController::GetContainerWindow() { 217 aura::Window* KeyboardController::GetContainerWindow() {
203 if (!container_.get()) { 218 if (!container_.get()) {
204 container_.reset(new aura::Window( 219 container_.reset(new aura::Window(
205 new KeyboardWindowDelegate(proxy_.get()))); 220 new KeyboardWindowDelegate(proxy_.get())));
206 container_->SetEventTargeter(scoped_ptr<ui::EventTargeter>( 221 container_->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
207 new KeyboardContainerTargeter(container_.get(), proxy_.get()))); 222 new KeyboardContainerTargeter(container_.get(), proxy_.get())));
208 container_->SetName("KeyboardContainer"); 223 container_->SetName("KeyboardContainer");
209 container_->set_owned_by_parent(false); 224 container_->set_owned_by_parent(false);
210 container_->Init(aura::WINDOW_LAYER_NOT_DRAWN); 225 container_->Init(aura::WINDOW_LAYER_NOT_DRAWN);
211 container_->AddObserver(this); 226 container_->AddObserver(this);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 // background during animation. 426 // background during animation.
412 NotifyKeyboardBoundsChanging(proxy_->GetKeyboardWindow()->bounds()); 427 NotifyKeyboardBoundsChanging(proxy_->GetKeyboardWindow()->bounds());
413 proxy_->EnsureCaretInWorkArea(); 428 proxy_->EnsureCaretInWorkArea();
414 } 429 }
415 430
416 void KeyboardController::HideAnimationFinished() { 431 void KeyboardController::HideAnimationFinished() {
417 proxy_->HideKeyboardContainer(container_.get()); 432 proxy_->HideKeyboardContainer(container_.get());
418 } 433 }
419 434
420 } // namespace keyboard 435 } // namespace keyboard
OLDNEW
« ui/keyboard/keyboard_controller.h ('K') | « ui/keyboard/keyboard_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698