Index: ui/events/ozone/layout/keyboard_layout_engine_manager.cc |
diff --git a/ui/events/ozone/layout/keyboard_layout_engine_manager.cc b/ui/events/ozone/layout/keyboard_layout_engine_manager.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..72a430e089002944b36a04502a319f52d392b763 |
--- /dev/null |
+++ b/ui/events/ozone/layout/keyboard_layout_engine_manager.cc |
@@ -0,0 +1,39 @@ |
+// Copyright 2014 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 "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
+ |
+#include "base/logging.h" |
+#include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" |
+ |
+namespace ui { |
+ |
+// static |
+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.
|
+ |
+KeyboardLayoutEngineManager::KeyboardLayoutEngineManager( |
+ KeyboardLayoutEngine* engine) |
+ : keyboard_layout_engine_(engine) { |
+ CHECK(!instance_) << "Only one keyboard layout manager can be created."; |
+ instance_ = this; |
+} |
+ |
+KeyboardLayoutEngineManager::~KeyboardLayoutEngineManager() { |
+ CHECK_EQ(this, instance_); |
+ instance_ = NULL; |
+} |
+ |
+void KeyboardLayoutEngineManager::Create( |
+ scoped_ptr<KeyboardLayoutEngine> engine) { |
+ new KeyboardLayoutEngineManager(engine.release()); |
+} |
+ |
+KeyboardLayoutEngine* KeyboardLayoutEngineManager::GetKeyboardLayoutEngine() { |
+ // TODO(kpschoedel): Initialize KLEM in tests and remove lazy initialization. |
+ if (!instance_) |
+ new KeyboardLayoutEngineManager(new StubKeyboardLayoutEngine()); |
+ return instance_->keyboard_layout_engine_.get(); |
+} |
+ |
+} // namespace ui |