| Index: chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
|
| ===================================================================
|
| --- chrome/browser/extensions/api/autotest_private/autotest_private_api.cc (revision 191644)
|
| +++ chrome/browser/extensions/api/autotest_private/autotest_private_api.cc (working copy)
|
| @@ -10,51 +10,12 @@
|
| #include "chrome/common/extensions/api/autotest_private.h"
|
|
|
| #if defined(OS_CHROMEOS)
|
| -#include "ash/shell.h"
|
| -#include "ash/system/tray/system_tray_delegate.h"
|
| +#include "chrome/browser/chromeos/login/screen_locker.h"
|
| +#include "chrome/browser/chromeos/login/user_manager.h"
|
| #endif
|
|
|
| namespace extensions {
|
| -namespace {
|
|
|
| -std::string GetUserLoginStatus() {
|
| -#if defined(OS_CHROMEOS)
|
| - const ash::user::LoginStatus status =
|
| - ash::Shell::GetInstance()->system_tray_delegate() ?
|
| - ash::Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus() :
|
| - ash::user::LOGGED_IN_NONE;
|
| -
|
| - switch (status) {
|
| - case ash::user::LOGGED_IN_LOCKED:
|
| - return std::string("locked");
|
| - case ash::user::LOGGED_IN_USER:
|
| - return std::string("user");
|
| - case ash::user::LOGGED_IN_OWNER:
|
| - return std::string("owner");
|
| - case ash::user::LOGGED_IN_GUEST:
|
| - return std::string("guest");
|
| - case ash::user::LOGGED_IN_RETAIL_MODE:
|
| - return std::string("retail");
|
| - case ash::user::LOGGED_IN_PUBLIC:
|
| - return std::string("public");
|
| - case ash::user::LOGGED_IN_LOCALLY_MANAGED:
|
| - return std::string("local");
|
| - case ash::user::LOGGED_IN_KIOSK_APP:
|
| - return std::string("kiosk");
|
| - case ash::user::LOGGED_IN_NONE:
|
| - return std::string("none");
|
| - // Intentionally leaves out default so that compiler catches missing
|
| - // branches when new login status is added.
|
| - }
|
| -
|
| - NOTREACHED();
|
| -#endif
|
| -
|
| - return std::string("none");
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| bool AutotestPrivateLogoutFunction::RunImpl() {
|
| DVLOG(1) << "AutotestPrivateLogoutFunction";
|
| if (!AutotestPrivateAPIFactory::GetForProfile(profile())->test_mode())
|
| @@ -90,7 +51,45 @@
|
|
|
| bool AutotestPrivateLoginStatusFunction::RunImpl() {
|
| DVLOG(1) << "AutotestPrivateLoginStatusFunction";
|
| - SetResult(base::Value::CreateStringValue(GetUserLoginStatus()));
|
| +
|
| + DictionaryValue* return_value(new DictionaryValue);
|
| +#if defined(OS_CHROMEOS)
|
| + const chromeos::UserManager* user_manager = chromeos::UserManager::Get();
|
| + const chromeos::ScreenLocker* screen_locker =
|
| + chromeos::ScreenLocker::default_screen_locker();
|
| +
|
| + if (user_manager) {
|
| + return_value->SetBoolean("is_logged_in", user_manager->IsUserLoggedIn());
|
| + return_value->SetBoolean("is_owner", user_manager->IsCurrentUserOwner());
|
| + return_value->SetBoolean("is_screen_locked", screen_locker);
|
| + if (user_manager->IsUserLoggedIn()) {
|
| + return_value->SetBoolean("is_regular_user",
|
| + user_manager->IsLoggedInAsRegularUser());
|
| + return_value->SetBoolean("is_guest", user_manager->IsLoggedInAsGuest());
|
| + return_value->SetBoolean("is_kiosk",
|
| + user_manager->IsLoggedInAsKioskApp());
|
| +
|
| + const chromeos::User* user = user_manager->GetLoggedInUser();
|
| + return_value->SetString("email", user->email());
|
| + return_value->SetString("display_email", user->display_email());
|
| + switch (user->image_index()) {
|
| + case chromeos::User::kExternalImageIndex:
|
| + return_value->SetString("user_image", "file");
|
| + break;
|
| +
|
| + case chromeos::User::kProfileImageIndex:
|
| + return_value->SetString("user_image", "profile");
|
| + break;
|
| +
|
| + default:
|
| + return_value->SetInteger("user_image", user->image_index());
|
| + break;
|
| + }
|
| + }
|
| + }
|
| +#endif
|
| +
|
| + SetResult(return_value);
|
| return true;
|
| }
|
|
|
|
|