Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" | 5 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
| 6 | 6 |
| 7 #include "apps/native_app_window.h" | 7 #include "apps/native_app_window.h" |
| 8 #include "apps/shell_window_registry.h" | 8 #include "apps/shell_window_registry.h" |
| 9 #include "ash/keyboard_overlay/keyboard_overlay_view.h" | 9 #include "ash/keyboard_overlay/keyboard_overlay_view.h" |
| 10 #include "ash/wm/mru_window_tracker.h" | |
| 10 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
| 11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 12 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 15 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 15 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 16 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 16 #include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h" | 17 #include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h" |
| 17 #include "chrome/browser/chromeos/display/display_preferences.h" | 18 #include "chrome/browser/chromeos/display/display_preferences.h" |
| 18 #include "chrome/browser/chromeos/extensions/file_manager/app_id.h" | 19 #include "chrome/browser/chromeos/extensions/file_manager/app_id.h" |
| 19 #include "chrome/browser/chromeos/extensions/media_player_api.h" | 20 #include "chrome/browser/chromeos/extensions/media_player_api.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 36 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
| 37 #include "chromeos/chromeos_switches.h" | 38 #include "chromeos/chromeos_switches.h" |
| 38 #include "chromeos/dbus/dbus_thread_manager.h" | 39 #include "chromeos/dbus/dbus_thread_manager.h" |
| 39 #include "chromeos/dbus/power_manager_client.h" | 40 #include "chromeos/dbus/power_manager_client.h" |
| 40 #include "chromeos/ime/input_method_manager.h" | 41 #include "chromeos/ime/input_method_manager.h" |
| 41 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
| 42 #include "content/public/browser/user_metrics.h" | 43 #include "content/public/browser/user_metrics.h" |
| 43 #include "content/public/browser/web_contents.h" | 44 #include "content/public/browser/web_contents.h" |
| 44 #include "content/public/browser/web_contents_view.h" | 45 #include "content/public/browser/web_contents_view.h" |
| 45 | 46 |
| 47 namespace { | |
| 48 | |
| 49 // This function used for restoring focus after user session was started. | |
| 50 // It's needed because some windows can be opened in background while login UI | |
|
oshima
2013/08/20 14:56:01
because we currently restore browser windows befor
Nikita (slow)
2013/08/20 16:04:39
Done.
| |
| 51 // is still active. | |
| 52 void RestoreFocus() { | |
| 53 ash::MruWindowTracker::WindowList mru_list = | |
| 54 ash::Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList(); | |
| 55 if (!mru_list.empty()) | |
| 56 mru_list.front()->Focus(); | |
| 57 } | |
| 58 | |
| 59 } // anonymous namespace | |
| 60 | |
| 46 bool ChromeShellDelegate::IsFirstRunAfterBoot() const { | 61 bool ChromeShellDelegate::IsFirstRunAfterBoot() const { |
| 47 return CommandLine::ForCurrentProcess()->HasSwitch( | 62 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 48 chromeos::switches::kFirstExecAfterBoot); | 63 chromeos::switches::kFirstExecAfterBoot); |
| 49 } | 64 } |
| 50 | 65 |
| 51 void ChromeShellDelegate::PreInit() { | 66 void ChromeShellDelegate::PreInit() { |
| 52 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot()); | 67 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot()); |
| 53 } | 68 } |
| 54 | 69 |
| 55 void ChromeShellDelegate::Shutdown() { | 70 void ChromeShellDelegate::Shutdown() { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 } | 251 } |
| 237 | 252 |
| 238 void ChromeShellDelegate::Observe(int type, | 253 void ChromeShellDelegate::Observe(int type, |
| 239 const content::NotificationSource& source, | 254 const content::NotificationSource& source, |
| 240 const content::NotificationDetails& details) { | 255 const content::NotificationDetails& details) { |
| 241 switch (type) { | 256 switch (type) { |
| 242 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: | 257 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: |
| 243 ash::Shell::GetInstance()->CreateLauncher(); | 258 ash::Shell::GetInstance()->CreateLauncher(); |
| 244 break; | 259 break; |
| 245 case chrome::NOTIFICATION_SESSION_STARTED: | 260 case chrome::NOTIFICATION_SESSION_STARTED: |
| 261 RestoreFocus(); | |
| 246 ash::Shell::GetInstance()->ShowLauncher(); | 262 ash::Shell::GetInstance()->ShowLauncher(); |
| 247 break; | 263 break; |
| 248 default: | 264 default: |
| 249 NOTREACHED() << "Unexpected notification " << type; | 265 NOTREACHED() << "Unexpected notification " << type; |
| 250 } | 266 } |
| 251 } | 267 } |
| 252 | 268 |
| 253 void ChromeShellDelegate::PlatformInit() { | 269 void ChromeShellDelegate::PlatformInit() { |
| 254 registrar_.Add(this, | 270 registrar_.Add(this, |
| 255 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 271 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 256 content::NotificationService::AllSources()); | 272 content::NotificationService::AllSources()); |
| 257 registrar_.Add(this, | 273 registrar_.Add(this, |
| 258 chrome::NOTIFICATION_SESSION_STARTED, | 274 chrome::NOTIFICATION_SESSION_STARTED, |
| 259 content::NotificationService::AllSources()); | 275 content::NotificationService::AllSources()); |
| 260 } | 276 } |
| OLD | NEW |