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

Side by Side Diff: chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc

Issue 14295008: Add ash SessionStateDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 7 years, 8 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 unified diff | Download patch
OLDNEW
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 "ash/keyboard_overlay/keyboard_overlay_view.h" 7 #include "ash/keyboard_overlay/keyboard_overlay_view.h"
8 #include "ash/system/chromeos/network/network_observer.h" 8 #include "ash/system/chromeos/network/network_observer.h"
9 #include "ash/system/tray/system_tray_notifier.h" 9 #include "ash/system/tray/system_tray_notifier.h"
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
11 #include "base/chromeos/chromeos_version.h"
12 #include "base/command_line.h" 11 #include "base/command_line.h"
13 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
14 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 14 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
16 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 15 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
17 #include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h" 16 #include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h"
18 #include "chrome/browser/chromeos/cros/cros_library.h" 17 #include "chrome/browser/chromeos/cros/cros_library.h"
19 #include "chrome/browser/chromeos/cros/network_library.h" 18 #include "chrome/browser/chromeos/cros/network_library.h"
20 #include "chrome/browser/chromeos/display/display_preferences.h" 19 #include "chrome/browser/chromeos/display/display_preferences.h"
21 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h" 20 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h"
22 #include "chrome/browser/chromeos/extensions/media_player_api.h" 21 #include "chrome/browser/chromeos/extensions/media_player_api.h"
23 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" 22 #include "chrome/browser/chromeos/extensions/media_player_event_router.h"
24 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" 23 #include "chrome/browser/chromeos/input_method/input_method_configuration.h"
25 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 24 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
26 #include "chrome/browser/chromeos/login/screen_locker.h" 25 #include "chrome/browser/chromeos/login/screen_locker.h"
27 #include "chrome/browser/chromeos/login/user_manager.h"
28 #include "chrome/browser/chromeos/login/webui_login_display_host.h" 26 #include "chrome/browser/chromeos/login/webui_login_display_host.h"
29 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" 27 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h"
30 #include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h" 28 #include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h"
31 #include "chrome/browser/profiles/profile_manager.h" 29 #include "chrome/browser/profiles/profile_manager.h"
32 #include "chrome/browser/ui/ash/caps_lock_delegate_chromeos.h" 30 #include "chrome/browser/ui/ash/caps_lock_delegate_chromeos.h"
33 #include "chrome/browser/ui/ash/window_positioner.h" 31 #include "chrome/browser/ui/ash/window_positioner.h"
34 #include "chrome/browser/ui/browser.h" 32 #include "chrome/browser/ui/browser.h"
35 #include "chrome/browser/ui/browser_finder.h" 33 #include "chrome/browser/ui/browser_finder.h"
36 #include "chrome/browser/ui/browser_window.h" 34 #include "chrome/browser/ui/browser_window.h"
37 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" 35 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
38 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" 36 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
39 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h" 37 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
40 #include "chrome/common/chrome_switches.h" 38 #include "chrome/common/chrome_switches.h"
41 #include "chrome/common/pref_names.h" 39 #include "chrome/common/pref_names.h"
42 #include "chrome/common/url_constants.h" 40 #include "chrome/common/url_constants.h"
43 #include "chromeos/chromeos_switches.h" 41 #include "chromeos/chromeos_switches.h"
44 #include "chromeos/dbus/dbus_thread_manager.h" 42 #include "chromeos/dbus/dbus_thread_manager.h"
45 #include "chromeos/dbus/power_manager_client.h" 43 #include "chromeos/dbus/power_manager_client.h"
46 #include "chromeos/dbus/session_manager_client.h"
47 #include "content/public/browser/user_metrics.h" 44 #include "content/public/browser/user_metrics.h"
48 #include "content/public/browser/web_contents.h" 45 #include "content/public/browser/web_contents.h"
49 #include "content/public/browser/web_contents_view.h" 46 #include "content/public/browser/web_contents_view.h"
50 #include "grit/generated_resources.h" 47 #include "grit/generated_resources.h"
51 #include "ui/base/l10n/l10n_util.h" 48 #include "ui/base/l10n/l10n_util.h"
52 49
53 bool ChromeShellDelegate::IsUserLoggedIn() const {
54 // When running a Chrome OS build outside of a device (i.e. on a developer's
55 // workstation) and not running as login-manager, pretend like we're always
56 // logged in.
57 if (!base::chromeos::IsRunningOnChromeOS() &&
58 !CommandLine::ForCurrentProcess()->HasSwitch(
59 chromeos::switches::kLoginManager)) {
60 return true;
61 }
62
63 return chromeos::UserManager::Get()->IsUserLoggedIn();
64 }
65
66 bool ChromeShellDelegate::IsSessionStarted() const {
67 // Returns true if we're logged in and browser has been started
68 return chromeos::UserManager::Get()->IsSessionStarted();
69 }
70
71 bool ChromeShellDelegate::IsGuestSession() const {
72 return CommandLine::ForCurrentProcess()->HasSwitch(
73 chromeos::switches::kGuestSession);
74 }
75
76 bool ChromeShellDelegate::IsFirstRunAfterBoot() const { 50 bool ChromeShellDelegate::IsFirstRunAfterBoot() const {
77 return CommandLine::ForCurrentProcess()->HasSwitch( 51 return CommandLine::ForCurrentProcess()->HasSwitch(
78 chromeos::switches::kFirstBoot); 52 chromeos::switches::kFirstBoot);
79 } 53 }
80 54
81 bool ChromeShellDelegate::CanLockScreen() const {
82 return chromeos::UserManager::Get()->CanCurrentUserLock();
83 }
84
85 void ChromeShellDelegate::LockScreen() {
86 if (CanLockScreen()) {
87 // TODO(antrim) : additional logging for crbug/173178
88 LOG(WARNING) << "Requesting screen lock from ChromeShellDelegate";
89 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
90 RequestLockScreen();
91 }
92 }
93
94 bool ChromeShellDelegate::IsScreenLocked() const {
95 if (!chromeos::ScreenLocker::default_screen_locker())
96 return false;
97 return chromeos::ScreenLocker::default_screen_locker()->locked();
98 }
99
100 void ChromeShellDelegate::PreInit() { 55 void ChromeShellDelegate::PreInit() {
101 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot()); 56 chromeos::LoadDisplayPreferences(IsFirstRunAfterBoot());
102 } 57 }
103 58
104 void ChromeShellDelegate::Shutdown() { 59 void ChromeShellDelegate::Shutdown() {
105 content::RecordAction(content::UserMetricsAction("Shutdown")); 60 content::RecordAction(content::UserMetricsAction("Shutdown"));
106 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 61 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
107 RequestShutdown(); 62 RequestShutdown();
108 } 63 }
109 64
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 void ChromeShellDelegate::ShowKeyboardOverlay() { 195 void ChromeShellDelegate::ShowKeyboardOverlay() {
241 // TODO(mazda): Move the show logic to ash (http://crbug.com/124222). 196 // TODO(mazda): Move the show logic to ash (http://crbug.com/124222).
242 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); 197 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
243 std::string url(chrome::kChromeUIKeyboardOverlayURL); 198 std::string url(chrome::kChromeUIKeyboardOverlayURL);
244 ash::KeyboardOverlayView::ShowDialog(profile, 199 ash::KeyboardOverlayView::ShowDialog(profile,
245 new ChromeWebContentsHandler, 200 new ChromeWebContentsHandler,
246 GURL(url)); 201 GURL(url));
247 } 202 }
248 203
249 bool ChromeShellDelegate::ShouldAlwaysShowAccessibilityMenu() const { 204 bool ChromeShellDelegate::ShouldAlwaysShowAccessibilityMenu() const {
250 if (!IsUserLoggedIn())
251 return true;
252
253 Profile* profile = ProfileManager::GetDefaultProfile(); 205 Profile* profile = ProfileManager::GetDefaultProfile();
254 if (!profile) 206 if (!profile)
255 return false; 207 return false;
256 208
257 PrefService* user_pref_service = profile->GetPrefs(); 209 PrefService* user_pref_service = profile->GetPrefs();
258 return user_pref_service && 210 return user_pref_service &&
259 user_pref_service->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu); 211 user_pref_service->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu);
260 } 212 }
261 213
262 ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate() { 214 ash::SystemTrayDelegate* ChromeShellDelegate::CreateSystemTrayDelegate() {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 } 253 }
302 254
303 void ChromeShellDelegate::PlatformInit() { 255 void ChromeShellDelegate::PlatformInit() {
304 registrar_.Add(this, 256 registrar_.Add(this,
305 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 257 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
306 content::NotificationService::AllSources()); 258 content::NotificationService::AllSources());
307 registrar_.Add(this, 259 registrar_.Add(this,
308 chrome::NOTIFICATION_SESSION_STARTED, 260 chrome::NOTIFICATION_SESSION_STARTED,
309 content::NotificationService::AllSources()); 261 content::NotificationService::AllSources());
310 } 262 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/chrome_shell_delegate.cc ('k') | chrome/browser/ui/ash/chrome_shell_delegate_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698