summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc16
-rw-r--r--chrome/browser/ui/ash/system_tray_delegate_chromeos.cc47
2 files changed, 33 insertions, 30 deletions
diff --git a/chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc b/chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc
index 14e5255..6cdf4b8 100644
--- a/chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc
@@ -38,6 +38,7 @@
#include "chrome/browser/chromeos/profiles/multiprofiles_session_aborted_dialog.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/session_length_limiter.h"
+#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/system/timezone_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/easy_unlock_service.h"
@@ -80,6 +81,11 @@ const char kPublicAccounts[] = "PublicAccounts";
const char kPublicAccountPendingDataRemoval[] =
"PublicAccountPendingDataRemoval";
+bool FakeOwnership() {
+ return base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kStubCrosSettings);
+}
+
} // namespace
// static
@@ -644,6 +650,13 @@ void ChromeUserManagerImpl::GuestUserLoggedIn() {
void ChromeUserManagerImpl::RegularUserLoggedIn(const std::string& user_id) {
ChromeUserManager::RegularUserLoggedIn(user_id);
+ if (FakeOwnership()) {
+ std::string owner_email = GetActiveUser()->email();
+ VLOG(1) << "Set device owner to: " << owner_email;
+ CrosSettings::Get()->SetString(kDeviceOwner, owner_email);
+ SetOwnerEmail(owner_email);
+ }
+
if (IsCurrentUserNew())
WallpaperManager::Get()->SetUserWallpaperNow(user_id);
@@ -811,7 +824,8 @@ void ChromeUserManagerImpl::NotifyOnLogin() {
}
void ChromeUserManagerImpl::UpdateOwnership() {
- bool is_owner = DeviceSettingsService::Get()->HasPrivateOwnerKey();
+ bool is_owner =
+ FakeOwnership() || DeviceSettingsService::Get()->HasPrivateOwnerKey();
VLOG(1) << "Current user " << (is_owner ? "is owner" : "is not owner");
SetCurrentUserIsOwner(is_owner);
diff --git a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
index f4e1284..535d9f2 100644
--- a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
@@ -185,6 +185,19 @@ void OnAcceptMultiprofilesIntro(bool no_show_again) {
UserAddingScreen::Get()->Start();
}
+void SetShouldUse24HourClock(bool use_24_hour_clock) {
+ user_manager::User* const user =
+ user_manager::UserManager::Get()->GetActiveUser();
+ CHECK(user);
+ Profile* const profile = ProfileHelper::Get()->GetProfileByUser(user);
+ if (!profile)
+ return; // May occur in tests or if not running on a device.
+ OwnerSettingsServiceChromeOS* const service =
+ OwnerSettingsServiceChromeOSFactory::GetForBrowserContext(profile);
+ CHECK(service);
+ service->SetBoolean(kSystemUse24HourClock, use_24_hour_clock);
+}
+
} // namespace
SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS()
@@ -1027,17 +1040,8 @@ void SystemTrayDelegateChromeOS::UpdateClockType() {
GetSystemTrayNotifier()->NotifyDateFormatChanged();
// This also works for enterprise-managed devices because they never have
// local owner.
- if (user_manager::UserManager::Get()->IsCurrentUserOwner()) {
- user_manager::User* const user =
- user_manager::UserManager::Get()->GetActiveUser();
- CHECK(user);
- Profile* const profile = ProfileHelper::Get()->GetProfileByUser(user);
- CHECK(profile);
- OwnerSettingsServiceChromeOS* const service =
- OwnerSettingsServiceChromeOSFactory::GetForBrowserContext(profile);
- CHECK(service);
- service->SetBoolean(kSystemUse24HourClock, use_24_hour_clock);
- }
+ if (user_manager::UserManager::Get()->IsCurrentUserOwner())
+ SetShouldUse24HourClock(use_24_hour_clock);
}
void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() {
@@ -1130,24 +1134,9 @@ void SystemTrayDelegateChromeOS::NotifyIfLastWindowClosed() {
void SystemTrayDelegateChromeOS::LoggedInStateChanged() {
// It apparently sometimes takes a while after login before the current user
// is recognized as the owner. Make sure that the system-wide clock setting
- // is updated when the recognition eventually happens
- // (http://crbug.com/278601).
- //
- // Note that it isn't safe to blindly call UpdateClockType() from this
- // method, as LoggedInStateChanged() is also called before the logged-in
- // user's profile has actually been loaded (http://crbug.com/317745). The
- // system tray's time format is updated at login via SetProfile().
- if (user_manager::UserManager::Get()->IsCurrentUserOwner()) {
- user_manager::User* const user =
- user_manager::UserManager::Get()->GetActiveUser();
- CHECK(user);
- Profile* const profile = ProfileHelper::Get()->GetProfileByUser(user);
- CHECK(profile);
- OwnerSettingsServiceChromeOS* const service =
- OwnerSettingsServiceChromeOSFactory::GetForBrowserContext(profile);
- CHECK(service);
- service->SetBoolean(kSystemUse24HourClock, ShouldUse24HourClock());
- }
+ // is updated when the recognition eventually happens (crbug.com/278601).
+ if (user_manager::UserManager::Get()->IsCurrentUserOwner())
+ SetShouldUse24HourClock(ShouldUse24HourClock());
}
// Overridden from SessionManagerClient::Observer.