OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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. | |
4 | |
5 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" | |
9 | |
10 namespace ui { | |
11 | |
12 // static | |
13 KeyboardLayoutEngineManager* KeyboardLayoutEngineManager::instance_ = nullptr; | |
Wez
2014/12/09 07:00:33
Seems that this needs to be a leaky singleton scop
kpschoedel
2014/12/09 19:58:44
Intended after the TODO at line 33 below is done.
Wez
2014/12/12 20:04:17
OK; in general it's best to leave comments referri
kpschoedel
2014/12/12 21:20:39
Done.
| |
14 | |
15 KeyboardLayoutEngineManager::KeyboardLayoutEngineManager( | |
16 KeyboardLayoutEngine* engine) | |
17 : keyboard_layout_engine_(engine) { | |
18 CHECK(!instance_) << "Only one keyboard layout manager can be created."; | |
19 instance_ = this; | |
20 } | |
21 | |
22 KeyboardLayoutEngineManager::~KeyboardLayoutEngineManager() { | |
23 CHECK_EQ(this, instance_); | |
24 instance_ = NULL; | |
25 } | |
26 | |
27 void KeyboardLayoutEngineManager::Create( | |
28 scoped_ptr<KeyboardLayoutEngine> engine) { | |
29 new KeyboardLayoutEngineManager(engine.release()); | |
30 } | |
31 | |
32 KeyboardLayoutEngine* KeyboardLayoutEngineManager::GetKeyboardLayoutEngine() { | |
33 // TODO(kpschoedel): Initialize KLEM in tests and remove lazy initialization. | |
34 if (!instance_) | |
35 new KeyboardLayoutEngineManager(new StubKeyboardLayoutEngine()); | |
36 return instance_->keyboard_layout_engine_.get(); | |
37 } | |
38 | |
39 } // namespace ui | |
OLD | NEW |