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

Unified Diff: chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc

Issue 22887021: Pass focus to browser after login. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 4 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 | « chrome/browser/chromeos/login/user_adding_screen_browsertest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc
index 36e3f4b47c1c615f422021bac89d84753d35232d..57e7eba49d1b26178fcff8c7c450a48366ab4aa4 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc
@@ -7,6 +7,7 @@
#include "apps/native_app_window.h"
#include "apps/shell_window_registry.h"
#include "ash/keyboard_overlay/keyboard_overlay_view.h"
+#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "base/prefs/pref_service.h"
@@ -43,6 +44,21 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
+namespace {
+
+// This function is used for restoring focus after the user session is started.
+// It's needed because some windows can be opened in background while login UI
+// is still active because we currently restore browser windows before login UI
+// is deleted.
+void RestoreFocus() {
+ ash::MruWindowTracker::WindowList mru_list =
+ ash::Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList();
+ if (!mru_list.empty())
+ mru_list.front()->Focus();
+}
+
+} // anonymous namespace
+
bool ChromeShellDelegate::IsFirstRunAfterBoot() const {
return CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kFirstExecAfterBoot);
@@ -243,6 +259,7 @@ void ChromeShellDelegate::Observe(int type,
ash::Shell::GetInstance()->CreateLauncher();
break;
case chrome::NOTIFICATION_SESSION_STARTED:
+ RestoreFocus();
ash::Shell::GetInstance()->ShowLauncher();
break;
default:
« no previous file with comments | « chrome/browser/chromeos/login/user_adding_screen_browsertest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698