[go: nahoru, domu]

cros: Make it possible to tab-focus from OOBE dialog to shelf widget.

This CL includes a few major changes:

OobeUIDialogDelegate is now a WebContentsDelegate for the OOBE WebDialogView, so
that it can be notified of focus reaching the end of the WebContents and move
the focus over to the shelf. Because of this change, HandleKeyboardEvent must
be implemented to send accelerators to the webui.

During login, AshFocusRules has a special case that allows the ShelfContainer to
be activated even when the LockSystemModalContainer is active.

Bug: 871184
Change-Id: Ia5437705304831dbf2f21e29a39f6bbcb3a15307
Reviewed-on: https://chromium-review.googlesource.com/1197785
Commit-Queue: Quan Nguyen <qnnguyen@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: Dominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588703}
diff --git a/ash/login/login_screen_controller.cc b/ash/login/login_screen_controller.cc
index 9d8bd01..7c97190d 100644
--- a/ash/login/login_screen_controller.cc
+++ b/ash/login/login_screen_controller.cc
@@ -4,6 +4,7 @@
 
 #include "ash/login/login_screen_controller.h"
 
+#include "ash/focus_cycler.h"
 #include "ash/login/ui/lock_screen.h"
 #include "ash/login/ui/lock_window.h"
 #include "ash/login/ui/login_data_dispatcher.h"
@@ -15,6 +16,7 @@
 #include "ash/shelf/shelf_widget.h"
 #include "ash/shell.h"
 #include "ash/system/status_area_widget.h"
+#include "ash/system/status_area_widget_delegate.h"
 #include "base/debug/alias.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
@@ -436,6 +438,21 @@
       ->SetShowGuestButtonForGaiaScreen(can_show);
 }
 
+void LoginScreenController::FocusLoginShelf(bool reverse) {
+  Shelf* shelf = Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow());
+  // Tell the focus direction to the status area or the shelf so they can focus
+  // the correct child view.
+  if (reverse) {
+    shelf->GetStatusAreaWidget()
+        ->status_area_widget_delegate()
+        ->set_default_last_focusable_child(reverse);
+    Shell::Get()->focus_cycler()->FocusWidget(shelf->GetStatusAreaWidget());
+  } else {
+    shelf->shelf_widget()->set_default_last_focusable_child(reverse);
+    Shell::Get()->focus_cycler()->FocusWidget(shelf->shelf_widget());
+  }
+}
+
 void LoginScreenController::SetAddUserButtonEnabled(bool enable) {
   Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
       ->shelf_widget()
@@ -459,6 +476,10 @@
   login_screen_client_->ShowAccountAccessHelpApp();
 }
 
+void LoginScreenController::FocusOobeDialog() {
+  login_screen_client_->FocusOobeDialog();
+}
+
 void LoginScreenController::DoAuthenticateUser(const AccountId& account_id,
                                                const std::string& password,
                                                bool authenticated_by_pin,