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

Unified Diff: ash/common/keyboard/keyboard_observer_register.cc

Issue 2747543002: ash: Start/stop observing KeyboardController via ShellObserver (Closed)
Patch Set: update LockLayoutManager to use similar logic Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/keyboard/keyboard_observer_register.h ('k') | ash/common/shelf/shelf_layout_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/keyboard/keyboard_observer_register.cc
diff --git a/ash/common/keyboard/keyboard_observer_register.cc b/ash/common/keyboard/keyboard_observer_register.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ccd514dd29980991c34a713e4b174e5ca672971c
--- /dev/null
+++ b/ash/common/keyboard/keyboard_observer_register.cc
@@ -0,0 +1,31 @@
+// Copyright 2017 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 "ash/common/keyboard/keyboard_observer_register.h"
+
+#include "ui/keyboard/keyboard_controller.h"
+
+namespace ash {
+
+void UpdateKeyboardObserverFromStateChanged(
+ bool keyboard_activated,
+ WmWindow* keyboard_root_window,
+ WmWindow* observer_root_window,
+ ScopedObserver<keyboard::KeyboardController,
+ keyboard::KeyboardControllerObserver>* keyboard_observer) {
+ if (keyboard_root_window != observer_root_window)
+ return;
+
+ keyboard::KeyboardController* const keyboard_controller =
+ keyboard::KeyboardController::GetInstance();
+ if (keyboard_activated &&
+ !keyboard_observer->IsObserving(keyboard_controller)) {
+ keyboard_observer->Add(keyboard_controller);
+ } else if (!keyboard_activated &&
+ keyboard_observer->IsObserving(keyboard_controller)) {
+ keyboard_observer->Remove(keyboard_controller);
+ }
+}
+
+} // namespace ash
« no previous file with comments | « ash/common/keyboard/keyboard_observer_register.h ('k') | ash/common/shelf/shelf_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698