Skip to content

Commit

Permalink
Revert 193699 "Add LoginState class to src/chromeos/login"
Browse files Browse the repository at this point in the history
> Add LoginState class to src/chromeos/login
> 
> 
> BUG=226495
> For Misc. chromeos-specific chrome/browser login related changes:
> TBR=sky@chromium.org
> 
> 
> Review URL: https://chromiumcodereview.appspot.com/13495003

TBR=stevenjb@chromium.org
Review URL: https://codereview.chromium.org/14137015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193708 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
michaeln@google.com committed Apr 11, 2013
1 parent bb9110b commit df235b3
Show file tree
Hide file tree
Showing 25 changed files with 99 additions and 394 deletions.
16 changes: 8 additions & 8 deletions ash/system/user/login_status.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ namespace ash {
namespace user {

enum LoginStatus {
LOGGED_IN_NONE, // Not logged in
LOGGED_IN_LOCKED, // A user has locked the screen
LOGGED_IN_USER, // A regular user is logged in
LOGGED_IN_OWNER, // The owner of the device is logged in
LOGGED_IN_LOCKED, // A user has locked the screen.
LOGGED_IN_USER, // A normal user is logged in.
LOGGED_IN_OWNER, // The owner of the device is logged in.
LOGGED_IN_GUEST, // A guest is logged in (i.e. incognito)
LOGGED_IN_RETAIL_MODE, // Is in retail mode
LOGGED_IN_PUBLIC, // A public account is logged in
LOGGED_IN_LOCALLY_MANAGED, // A locally managed user is logged in
LOGGED_IN_KIOSK_APP // Is in kiosk app mode
LOGGED_IN_RETAIL_MODE, // Is in retail mode.
LOGGED_IN_PUBLIC, // A public account is logged in.
LOGGED_IN_LOCALLY_MANAGED, // A locally managed user is logged in.
LOGGED_IN_KIOSK_APP, // Is in kiosk app mode.
LOGGED_IN_NONE, // Not logged in.
};

base::string16 GetLocalizedSignOutStringForStatus(LoginStatus status,
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/automation/automation_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h"

#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/login/login_state.h"
#endif // defined(OS_CHROMEOS)

using WebKit::WebFindOptions;
Expand Down Expand Up @@ -219,7 +219,7 @@ bool AutomationProvider::InitializeChannel(const std::string& channel_id) {
// Observer will delete itself.
if (CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kLoginManager) &&
!chromeos::LoginState::Get()->IsUserLoggedIn()) {
!chromeos::UserManager::Get()->IsUserLoggedIn()) {
login_webui_ready_ = false;
new OOBEWebuiReadyObserver(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "chrome/browser/chromeos/extensions/wallpaper_manager_util.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/wallpaper_manager.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/profiles/profile_manager.h"
Expand All @@ -19,15 +20,14 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/login/login_state.h"
#include "content/public/browser/notification_service.h"

namespace chromeos {

namespace {

bool IsNormalWallpaperChange() {
if (chromeos::LoginState::Get()->IsUserLoggedIn() ||
if (chromeos::UserManager::Get()->IsUserLoggedIn() ||
!CommandLine::ForCurrentProcess()->HasSwitch(switches::kFirstBoot) ||
WizardController::IsZeroDelayEnabled() ||
!CommandLine::ForCurrentProcess()->HasSwitch(switches::kLoginManager)) {
Expand Down Expand Up @@ -84,7 +84,7 @@ class UserWallpaperDelegate : public ash::UserWallpaperDelegate {
}

virtual bool CanOpenSetWallpaperPage() OVERRIDE {
return LoginState::Get()->IsUserAuthenticated();
return !chromeos::UserManager::Get()->IsLoggedInAsGuest();
}

virtual void OnWallpaperAnimationFinished() OVERRIDE {
Expand Down
5 changes: 0 additions & 5 deletions chrome/browser/chromeos/chrome_browser_main_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
#include "chromeos/dbus/session_manager_client.h"
#include "chromeos/disks/disk_mount_manager.h"
#include "chromeos/ime/xkeyboard.h"
#include "chromeos/login/login_state.h"
#include "chromeos/network/geolocation_handler.h"
#include "chromeos/network/managed_network_configuration_handler.h"
#include "chromeos/network/network_change_notifier_chromeos.h"
Expand Down Expand Up @@ -293,8 +292,6 @@ class DBusServices {
disks::DiskMountManager::Initialize();
cryptohome::AsyncMethodCaller::Initialize();

chromeos::LoginState::Initialize();

// Always initialize these handlers which should not conflict with
// NetworkLibrary.
chromeos::network_event_log::Initialize();
Expand Down Expand Up @@ -349,8 +346,6 @@ class DBusServices {
chromeos::GeolocationHandler::Shutdown();
chromeos::network_event_log::Shutdown();

chromeos::LoginState::Shutdown();

cryptohome::AsyncMethodCaller::Shutdown();
disks::DiskMountManager::Shutdown();
input_method::Shutdown();
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/cros/cert_library.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
#include "chrome/browser/browser_process.h" // g_browser_process
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/cryptohome_library.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/net/x509_certificate_model.h"
#include "chromeos/dbus/cryptohome_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/login/login_state.h"
#include "content/public/browser/browser_thread.h"
#include "crypto/encryptor.h"
#include "crypto/nss_util.h"
Expand Down Expand Up @@ -453,7 +453,7 @@ class CertLibraryImpl

certificates_requested_ = true;

if (!LoginState::Get()->IsUserLoggedIn()) {
if (!UserManager::Get()->IsUserLoggedIn()) {
// If we are not logged in, we cannot load any certificates.
// Set 'loaded' to true for the UI, since we are not waiting on loading.
LOG(WARNING) << "Requesting certificates before login.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h"
#include "chrome/browser/chromeos/login/base_login_display_host.h"
#include "chrome/browser/chromeos/login/screen_locker.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/net/connectivity_state_helper.h"
#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
Expand All @@ -33,7 +34,6 @@
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_manager_client.h"
#include "chromeos/dbus/session_manager_client.h"
#include "chromeos/login/login_state.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_source.h"
#include "grit/generated_resources.h"
Expand Down Expand Up @@ -310,10 +310,8 @@ void FileManagerEventRouter::ObserveFileSystemEvents() {
NOTREACHED();
return;
}
if (!chromeos::LoginState::IsInitialized() ||
!chromeos::LoginState::Get()->IsUserLoggedIn()) {
if (!chromeos::UserManager::Get()->IsUserLoggedIn())
return;
}

DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance();
if (disk_mount_manager) {
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
#include "chrome/browser/chromeos/login/existing_user_controller.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/webui_login_display_host.h"
#include "chrome/browser/chromeos/policy/app_pack_updater.h"
#include "chrome/browser/extensions/extension_service.h"
Expand All @@ -24,7 +25,6 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_file_util.h"
#include "chromeos/login/login_state.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"

Expand Down Expand Up @@ -212,7 +212,7 @@ void KioskModeScreensaver::SetupScreensaver(
extension_base_path_ = extension_base_path;

// If the user is already logged in, don't need to display the screensaver.
if (chromeos::LoginState::Get()->IsUserLoggedIn())
if (chromeos::UserManager::Get()->IsUserLoggedIn())
return;

ash::Shell::GetInstance()->user_activity_detector()->AddObserver(this);
Expand Down Expand Up @@ -251,7 +251,7 @@ void KioskModeScreensaver::OnUserActivity() {
// Log us in.
ExistingUserController* controller =
ExistingUserController::current_controller();
if (controller && !chromeos::LoginState::Get()->IsUserLoggedIn())
if (controller && !chromeos::UserManager::Get()->IsUserLoggedIn())
controller->LoginAsRetailModeUser();
} else {
// No default host for the WebUiLoginDisplay means that we're already in the
Expand Down
8 changes: 0 additions & 8 deletions chrome/browser/chromeos/login/base_login_display_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include "chrome/common/pref_names.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
#include "chromeos/login/login_state.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "googleurl/src/gurl.h"
Expand Down Expand Up @@ -424,13 +423,6 @@ void ShowLoginWizard(const std::string& first_screen_name,

// Check whether we need to execute OOBE process.
bool oobe_complete = chromeos::WizardController::IsOobeCompleted();
if (!oobe_complete) {
LoginState::Get()->SetLoggedInState(
LoginState::LOGGED_IN_OOBE, LoginState::LOGGED_IN_USER_NONE);
} else {
LoginState::Get()->SetLoggedInState(
LoginState::LOGGED_IN_NONE, LoginState::LOGGED_IN_USER_NONE);
}
bool show_login_screen =
(first_screen_name.empty() && oobe_complete) ||
first_screen_name == chromeos::WizardController::kLoginScreenName;
Expand Down
4 changes: 0 additions & 4 deletions chrome/browser/chromeos/login/login_utils_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include "chromeos/dbus/mock_session_manager_client.h"
#include "chromeos/disks/disk_mount_manager.h"
#include "chromeos/disks/mock_disk_mount_manager.h"
#include "chromeos/login/login_state.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_browser_thread.h"
#include "content/public/test/test_utils.h"
Expand Down Expand Up @@ -219,7 +218,6 @@ class LoginUtilsTest : public testing::Test,
// which is part of io_thread_state_.
DBusThreadManager::InitializeForTesting(&mock_dbus_thread_manager_);

LoginState::Initialize();
ConnectivityStateHelper::InitializeForTesting(
&mock_connectivity_state_helper_);

Expand Down Expand Up @@ -324,8 +322,6 @@ class LoginUtilsTest : public testing::Test,
// LoginUtils instance must not outlive Profile instances.
LoginUtils::Set(NULL);

LoginState::Shutdown();

// These trigger some tasks that have to run while BrowserThread::UI
// exists. Delete all the profiles before deleting the connector.
browser_process_->SetProfileManager(NULL);
Expand Down
33 changes: 0 additions & 33 deletions chrome/browser/chromeos/login/user_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "chrome/common/pref_names.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/cryptohome/async_method_caller.h"
#include "chromeos/login/login_state.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "google_apis/gaia/gaia_auth_util.h"
Expand Down Expand Up @@ -207,7 +206,6 @@ UserManagerImpl::UserManagerImpl()
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED,
content::NotificationService::AllSources());
RetrieveTrustedDevicePolicies();
UpdateLoginState();
}

UserManagerImpl::~UserManagerImpl() {
Expand Down Expand Up @@ -415,7 +413,6 @@ void UserManagerImpl::RegularUserLoggedInAsEphemeral(const std::string& email) {
void UserManagerImpl::SessionStarted() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
session_started_ = true;
UpdateLoginState();
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_SESSION_STARTED,
content::NotificationService::AllSources(),
Expand Down Expand Up @@ -717,7 +714,6 @@ void UserManagerImpl::SetCurrentUserIsOwner(bool is_current_user_owner) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
base::AutoLock lk(is_current_user_owner_lock_);
is_current_user_owner_ = is_current_user_owner;
UpdateLoginState();
}

bool UserManagerImpl::IsCurrentUserNew() const {
Expand Down Expand Up @@ -991,7 +987,6 @@ const User* UserManagerImpl::FindUserInList(const std::string& email) const {

void UserManagerImpl::NotifyOnLogin() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
UpdateLoginState();
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_LOGIN_USER_CHANGED,
content::Source<UserManager>(this),
Expand Down Expand Up @@ -1305,32 +1300,4 @@ void UserManagerImpl::NotifyMergeSessionStateChanged() {
MergeSessionStateChanged(merge_session_state_));
}

void UserManagerImpl::UpdateLoginState() {
if (!LoginState::IsInitialized())
return; // LoginState may not be intialized in tests.
LoginState::LoggedInState logged_in_state;
logged_in_state = logged_in_user_ ? LoginState::LOGGED_IN_ACTIVE
: LoginState::LOGGED_IN_NONE;

LoginState::LoggedInUserType login_user_type;
if (logged_in_state == LoginState::LOGGED_IN_NONE)
login_user_type = LoginState::LOGGED_IN_USER_NONE;
else if (is_current_user_owner_)
login_user_type = LoginState::LOGGED_IN_USER_OWNER;
else if (logged_in_user_->GetType() == User::USER_TYPE_GUEST)
login_user_type = LoginState::LOGGED_IN_USER_GUEST;
else if (logged_in_user_->GetType() == User::USER_TYPE_RETAIL_MODE)
login_user_type = LoginState::LOGGED_IN_USER_RETAIL_MODE;
else if (logged_in_user_->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT)
login_user_type = LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT;
else if (logged_in_user_->GetType() == User::USER_TYPE_LOCALLY_MANAGED)
login_user_type = LoginState::LOGGED_IN_USER_LOCALLY_MANAGED;
else if (logged_in_user_->GetType() == User::USER_TYPE_KIOSK_APP)
login_user_type = LoginState::LOGGED_IN_USER_KIOSK_APP;
else
login_user_type = LoginState::LOGGED_IN_USER_REGULAR;

LoginState::Get()->SetLoggedInState(logged_in_state, login_user_type);
}

} // namespace chromeos
3 changes: 0 additions & 3 deletions chrome/browser/chromeos/login/user_manager_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,6 @@ class UserManagerImpl
// Lazily creates default user flow.
UserFlow* GetDefaultUserFlow() const;

// Update the global LoginState.
void UpdateLoginState();

// Interface to the signed settings store.
CrosSettings* cros_settings_;

Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/chromeos/options/wifi_config_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/enrollment_dialog_view.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chromeos/login/login_state.h"
#include "chromeos/network/onc/onc_constants.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
Expand Down Expand Up @@ -546,7 +546,7 @@ void WifiConfigView::RefreshShareCheckbox() {
// user certificates are enabled.
share_network_checkbox_->SetEnabled(false);
share_network_checkbox_->SetChecked(false);
} else if (!LoginState::Get()->IsUserLoggedIn()) {
} else if (!UserManager::Get()->IsUserLoggedIn()) {
// If not logged in, networks must be shared.
share_network_checkbox_->SetEnabled(false);
share_network_checkbox_->SetChecked(true);
Expand All @@ -560,7 +560,7 @@ void WifiConfigView::UpdateErrorLabel() {
std::string error_msg;
if (UserCertRequired() && cert_library_->CertificatesLoaded()) {
if (!HaveUserCerts()) {
if (!LoginState::Get()->IsUserLoggedIn()) {
if (!UserManager::Get()->IsUserLoggedIn()) {
error_msg = l10n_util::GetStringUTF8(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN_FOR_USER_CERT);
} else {
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/options/wimax_config_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/enrollment_dialog_view.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chromeos/login/login_state.h"
#include "chromeos/network/onc/onc_constants.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
Expand Down Expand Up @@ -294,7 +294,7 @@ void WimaxConfigView::Init(WimaxNetwork* wimax) {

// Checkboxes.

if (LoginState::Get()->IsUserLoggedIn()) {
if (UserManager::Get()->IsUserLoggedIn()) {
// Save credentials
layout->StartRow(0, column_view_set_id);
save_credentials_checkbox_ = new views::Checkbox(
Expand Down
Loading

0 comments on commit df235b3

Please sign in to comment.