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

Side by Side Diff: chrome/browser/chromeos/system/ash_system_tray_delegate.cc

Issue 14269004: Add LoginState class to src/chromeos/login (redux) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chromeos/system/ash_system_tray_delegate.h" 5 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 #include "chrome/common/chrome_notification_types.h" 84 #include "chrome/common/chrome_notification_types.h"
85 #include "chrome/common/pref_names.h" 85 #include "chrome/common/pref_names.h"
86 #include "chrome/common/time_format.h" 86 #include "chrome/common/time_format.h"
87 #include "chrome/common/url_constants.h" 87 #include "chrome/common/url_constants.h"
88 #include "chromeos/chromeos_switches.h" 88 #include "chromeos/chromeos_switches.h"
89 #include "chromeos/dbus/dbus_thread_manager.h" 89 #include "chromeos/dbus/dbus_thread_manager.h"
90 #include "chromeos/dbus/power_manager_client.h" 90 #include "chromeos/dbus/power_manager_client.h"
91 #include "chromeos/dbus/session_manager_client.h" 91 #include "chromeos/dbus/session_manager_client.h"
92 #include "chromeos/dbus/system_clock_client.h" 92 #include "chromeos/dbus/system_clock_client.h"
93 #include "chromeos/ime/xkeyboard.h" 93 #include "chromeos/ime/xkeyboard.h"
94 #include "chromeos/login/login_state.h"
94 #include "content/public/browser/browser_thread.h" 95 #include "content/public/browser/browser_thread.h"
95 #include "content/public/browser/notification_observer.h" 96 #include "content/public/browser/notification_observer.h"
96 #include "content/public/browser/notification_service.h" 97 #include "content/public/browser/notification_service.h"
97 #include "content/public/browser/user_metrics.h" 98 #include "content/public/browser/user_metrics.h"
98 #include "device/bluetooth/bluetooth_adapter.h" 99 #include "device/bluetooth/bluetooth_adapter.h"
99 #include "device/bluetooth/bluetooth_adapter_factory.h" 100 #include "device/bluetooth/bluetooth_adapter_factory.h"
100 #include "device/bluetooth/bluetooth_device.h" 101 #include "device/bluetooth/bluetooth_device.h"
101 #include "grit/ash_strings.h" 102 #include "grit/ash_strings.h"
102 #include "grit/generated_resources.h" 103 #include "grit/generated_resources.h"
103 #include "grit/locale_settings.h" 104 #include "grit/locale_settings.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 360 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
360 g_browser_process->browser_policy_connector()-> 361 g_browser_process->browser_policy_connector()->
361 GetDeviceCloudPolicyManager(); 362 GetDeviceCloudPolicyManager();
362 if (policy_manager) 363 if (policy_manager)
363 policy_manager->core()->store()->RemoveObserver(this); 364 policy_manager->core()->store()->RemoveObserver(this);
364 } 365 }
365 366
366 // Overridden from ash::SystemTrayDelegate: 367 // Overridden from ash::SystemTrayDelegate:
367 virtual bool GetTrayVisibilityOnStartup() OVERRIDE { 368 virtual bool GetTrayVisibilityOnStartup() OVERRIDE {
368 // In case of OOBE / sign in screen tray will be shown later. 369 // In case of OOBE / sign in screen tray will be shown later.
369 return UserManager::Get()->IsUserLoggedIn(); 370 return LoginState::Get()->IsUserLoggedIn();
370 } 371 }
371 372
372 virtual const string16 GetUserDisplayName() const OVERRIDE { 373 virtual const string16 GetUserDisplayName() const OVERRIDE {
373 return UserManager::Get()->GetActiveUser()->GetDisplayName(); 374 return UserManager::Get()->GetActiveUser()->GetDisplayName();
374 } 375 }
375 376
376 virtual const std::string GetUserEmail() const OVERRIDE { 377 virtual const std::string GetUserEmail() const OVERRIDE {
377 return UserManager::Get()->GetActiveUser()->display_email(); 378 return UserManager::Get()->GetActiveUser()->display_email();
378 } 379 }
379 380
380 virtual const gfx::ImageSkia& GetUserImage() const OVERRIDE { 381 virtual const gfx::ImageSkia& GetUserImage() const OVERRIDE {
381 return UserManager::Get()->GetActiveUser()->image(); 382 return UserManager::Get()->GetActiveUser()->image();
382 } 383 }
383 384
384 virtual ash::user::LoginStatus GetUserLoginStatus() const OVERRIDE { 385 virtual ash::user::LoginStatus GetUserLoginStatus() const OVERRIDE {
385 UserManager* manager = UserManager::Get(); 386 // Map ChromeOS specific LOGGED_IN states to Ash LOGGED_IN states.
386 // At new user image screen manager->IsUserLoggedIn() would return true 387 LoginState::LoggedInState state = LoginState::Get()->GetLoggedInState();
387 // but there's no browser session available yet so use SessionStarted(). 388 if (state == LoginState::LOGGED_IN_OOBE ||
388 if (!manager->IsSessionStarted()) 389 state == LoginState::LOGGED_IN_NONE) {
389 return ash::user::LOGGED_IN_NONE; 390 return ash::user::LOGGED_IN_NONE;
391 }
390 if (screen_locked_) 392 if (screen_locked_)
391 return ash::user::LOGGED_IN_LOCKED; 393 return ash::user::LOGGED_IN_LOCKED;
392 if (manager->IsCurrentUserOwner()) 394
393 return ash::user::LOGGED_IN_OWNER; 395 LoginState::LoggedInUserType user_type =
394 if (manager->IsLoggedInAsGuest()) 396 LoginState::Get()->GetLoggedInUserType();
395 return ash::user::LOGGED_IN_GUEST; 397 switch (user_type) {
396 if (manager->IsLoggedInAsDemoUser()) 398 case LoginState::LOGGED_IN_USER_NONE:
397 return ash::user::LOGGED_IN_RETAIL_MODE; 399 return ash::user::LOGGED_IN_NONE;
398 if (manager->IsLoggedInAsPublicAccount()) 400 case LoginState::LOGGED_IN_USER_REGULAR:
399 return ash::user::LOGGED_IN_PUBLIC; 401 return ash::user::LOGGED_IN_USER;
400 return ash::user::LOGGED_IN_USER; 402 case LoginState::LOGGED_IN_USER_OWNER:
403 return ash::user::LOGGED_IN_OWNER;
404 case LoginState::LOGGED_IN_USER_GUEST:
405 return ash::user::LOGGED_IN_GUEST;
406 case LoginState::LOGGED_IN_USER_RETAIL_MODE:
407 return ash::user::LOGGED_IN_RETAIL_MODE;
408 case LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT:
409 return ash::user::LOGGED_IN_PUBLIC;
410 case LoginState::LOGGED_IN_USER_LOCALLY_MANAGED:
411 return ash::user::LOGGED_IN_LOCALLY_MANAGED;
412 case LoginState::LOGGED_IN_USER_KIOSK_APP:
413 return ash::user::LOGGED_IN_KIOSK_APP;
414 }
415 NOTREACHED();
416 return ash::user::LOGGED_IN_NONE;
401 } 417 }
402 418
403 virtual bool IsOobeCompleted() const OVERRIDE { 419 virtual bool IsOobeCompleted() const OVERRIDE {
404 return WizardController::IsOobeCompleted(); 420 return WizardController::IsOobeCompleted();
405 } 421 }
406 422
407 virtual void GetLoggedInUsers(ash::UserEmailList* users) OVERRIDE { 423 virtual void GetLoggedInUsers(ash::UserEmailList* users) OVERRIDE {
408 const UserList& logged_in_users = UserManager::Get()->GetLoggedInUsers(); 424 const UserList& logged_in_users = UserManager::Get()->GetLoggedInUsers();
409 for (UserList::const_iterator it = logged_in_users.begin(); 425 for (UserList::const_iterator it = logged_in_users.begin();
410 it != logged_in_users.end(); ++it) { 426 it != logged_in_users.end(); ++it) {
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); 1599 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate);
1584 }; 1600 };
1585 1601
1586 } // namespace 1602 } // namespace
1587 1603
1588 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1604 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1589 return new chromeos::SystemTrayDelegate(); 1605 return new chromeos::SystemTrayDelegate();
1590 } 1606 }
1591 1607
1592 } // namespace chromeos 1608 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/status/data_promo_notification.cc ('k') | chrome/browser/extensions/extension_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698