[go: nahoru, domu]

Add lock screen app window to lock screen focus cycle

Adds lock screen app windows to the lock screen focus cycle for views
based lock screen. The focus cycle is as follows:
Lock screen -> lock screen apps -> system shelf -> system tray

On lock screen apps side nothing changed, though views screen locker now
implements lock_screen_apps::FocusCyclerDelegate interface, and adds itself
to lock screen apps state as the focus cycler delegate implementation).
FocusCyclerDelegate is used by state controller to accept and hand off focus
between lock screen app windows and the rest of lock screen UI (and is
already in use for Web UI lock screen).

As lock_screen_apps::FocusCyclerDelegate, ViewsScreenLocker delegates
focus handout requests between lock_screen_apps::StateController and
LockContentsView using lock_screen mojo interface.

General flow is as follows:
1.  LockContentsView is notified that system tray or lock screen apps
    have lost focus.
2.  LockContentsView determines whether it is next in line to get focus
    *   if it is, it focuses the appropriate child
    *   if not, it passes focus on - either
            *   to lock screen apps using FocusLockScreenApps
                mojo message
            *   to system tray/shelf using shell's focus cycler
3.  Once the focus is leaving lock screen apps or system shelf/tray
    they notify LockScreenContents view the focus should be handed off:
    *   lock screen apps using HandleFocusLeavingLockScreenApps mojo
        request (which gets passed on to LockContentsView using
        LoginDataDispatcher)
    *   system tray/shelf using system tray notifier

BUG=746596

Change-Id: Ic4e1edd77193ae90203358671a2dd000c9aeefa2
Reviewed-on: https://chromium-review.googlesource.com/696673
Commit-Queue: Toni Barzic <tbarzic@chromium.org>
Reviewed-by: James Cook <jamescook@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Jacob Dufault <jdufault@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506640}
diff --git a/ash/login/lock_screen_controller.cc b/ash/login/lock_screen_controller.cc
index 4e25b6f..5e9de90f 100644
--- a/ash/login/lock_screen_controller.cc
+++ b/ash/login/lock_screen_controller.cc
@@ -4,6 +4,7 @@
 
 #include "ash/login/lock_screen_controller.h"
 
+#include "ash/login/lock_screen_apps_focus_observer.h"
 #include "ash/login/ui/lock_screen.h"
 #include "ash/login/ui/login_data_dispatcher.h"
 #include "ash/public/cpp/ash_pref_names.h"
@@ -122,6 +123,11 @@
       &LockScreenController::OnGetSystemSalt, base::Unretained(this)));
 }
 
+void LockScreenController::HandleFocusLeavingLockScreenApps(bool reverse) {
+  for (auto& observer : lock_screen_apps_focus_observers_)
+    observer.OnFocusLeavingLockScreenApps(reverse);
+}
+
 void LockScreenController::AttemptUnlock(const AccountId& account_id) {
   if (!lock_screen_client_)
     return;
@@ -177,6 +183,26 @@
   lock_screen_client_->OnMaxIncorrectPasswordAttempted(account_id);
 }
 
+void LockScreenController::FocusLockScreenApps(bool reverse) {
+  if (!lock_screen_client_)
+    return;
+  lock_screen_client_->FocusLockScreenApps(reverse);
+}
+
+void LockScreenController::AddLockScreenAppsFocusObserver(
+    LockScreenAppsFocusObserver* observer) {
+  lock_screen_apps_focus_observers_.AddObserver(observer);
+}
+
+void LockScreenController::RemoveLockScreenAppsFocusObserver(
+    LockScreenAppsFocusObserver* observer) {
+  lock_screen_apps_focus_observers_.RemoveObserver(observer);
+}
+
+void LockScreenController::FlushForTesting() {
+  lock_screen_client_.FlushForTesting();
+}
+
 void LockScreenController::DoAuthenticateUser(
     const AccountId& account_id,
     const std::string& password,