Commit 0974143f authored by mlerman@chromium.org's avatar mlerman@chromium.org

Make the user manager UI not permit guest mode when preferences dictate

(either ones blocking guest mode in particular or guest mode).

Follow-up to the CL http://codereview.chromium.org/385073008

CL is currently blocked on crbug.com/394413. No more, it landed!

BUG=306322

Review URL: https://codereview.chromium.org/471973003

Cr-Commit-Position: refs/heads/master@{#290069}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290069 0039d316-1c4b-4281-b951-d872f2087c98
parent ddec41e5
...@@ -34,13 +34,17 @@ cr.define('cr.ui', function() { ...@@ -34,13 +34,17 @@ cr.define('cr.ui', function() {
* Shows the given screen. * Shows the given screen.
* @param {Object} screen Screen params dict, e.g. {id: screenId, data: data} * @param {Object} screen Screen params dict, e.g. {id: screenId, data: data}
*/ */
Oobe.showUserManagerScreen = function() { Oobe.showUserManagerScreen = function(showGuest) {
Oobe.getInstance().showScreen({id: 'account-picker', Oobe.getInstance().showScreen({id: 'account-picker',
data: {disableAddUser: false}}); data: {disableAddUser: false}});
// The ChromeOS account-picker will hide the AddUser button if a user is // The ChromeOS account-picker will hide the AddUser button if a user is
// logged in and the screen is "locked", so we must re-enabled it // logged in and the screen is "locked", so we must re-enabled it
$('add-user-header-bar-item').hidden = false; $('add-user-header-bar-item').hidden = false;
// Hide the Guest Mode option if the user is not permitted to select it.
$('guest-user-button').hidden = !showGuest;
$('login-header-bar').hidden = false;
// Disable the context menu, as the Print/Inspect element items don't // Disable the context menu, as the Print/Inspect element items don't
// make sense when displayed as a widget. // make sense when displayed as a widget.
document.addEventListener('contextmenu', function(e) {e.preventDefault();}); document.addEventListener('contextmenu', function(e) {e.preventDefault();});
...@@ -130,6 +134,10 @@ cr.define('UserManager', function() { ...@@ -130,6 +134,10 @@ cr.define('UserManager', function() {
login.AccountPickerScreen.register(); login.AccountPickerScreen.register();
cr.ui.Bubble.decorate($('bubble')); cr.ui.Bubble.decorate($('bubble'));
login.HeaderBar.decorate($('login-header-bar')); login.HeaderBar.decorate($('login-header-bar'));
// Hide the header bar until the showUserManagerMethod can apply function
// parameters that affect widget visiblity.
$('login-header-bar').hidden = true;
chrome.send('userManagerInitialize'); chrome.send('userManagerInitialize');
} }
......
...@@ -144,6 +144,12 @@ extensions::ScreenlockPrivateEventRouter* GetScreenlockRouter( ...@@ -144,6 +144,12 @@ extensions::ScreenlockPrivateEventRouter* GetScreenlockRouter(
profile); profile);
} }
bool IsGuestModeEnabled() {
PrefService* service = g_browser_process->local_state();
DCHECK(service);
return service->GetBoolean(prefs::kBrowserGuestModeEnabled);
}
} // namespace } // namespace
// ProfileUpdateObserver ------------------------------------------------------ // ProfileUpdateObserver ------------------------------------------------------
...@@ -280,7 +286,8 @@ void UserManagerScreenHandler::Unlock(const std::string& user_email) { ...@@ -280,7 +286,8 @@ void UserManagerScreenHandler::Unlock(const std::string& user_email) {
void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) {
SendUserList(); SendUserList();
web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen"); web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen",
base::FundamentalValue(IsGuestModeEnabled()));
desktop_type_ = chrome::GetHostDesktopTypeForNativeView( desktop_type_ = chrome::GetHostDesktopTypeForNativeView(
web_ui()->GetWebContents()->GetNativeView()); web_ui()->GetWebContents()->GetNativeView());
...@@ -368,9 +375,15 @@ void UserManagerScreenHandler::HandleRemoveUser(const base::ListValue* args) { ...@@ -368,9 +375,15 @@ void UserManagerScreenHandler::HandleRemoveUser(const base::ListValue* args) {
} }
void UserManagerScreenHandler::HandleLaunchGuest(const base::ListValue* args) { void UserManagerScreenHandler::HandleLaunchGuest(const base::ListValue* args) {
profiles::SwitchToGuestProfile(desktop_type_, if (IsGuestModeEnabled()) {
base::Bind(&OnSwitchToProfileComplete)); profiles::SwitchToGuestProfile(desktop_type_,
ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_GUEST); base::Bind(&OnSwitchToProfileComplete));
ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_GUEST);
} else {
// The UI should have prevented the user from allowing the selection of
// guest mode.
NOTREACHED();
}
} }
void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) { void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) {
...@@ -624,7 +637,7 @@ void UserManagerScreenHandler::SendUserList() { ...@@ -624,7 +637,7 @@ void UserManagerScreenHandler::SendUserList() {
} }
web_ui()->CallJavascriptFunction("login.AccountPickerScreen.loadUsers", web_ui()->CallJavascriptFunction("login.AccountPickerScreen.loadUsers",
users_list, base::FundamentalValue(true)); users_list, base::FundamentalValue(IsGuestModeEnabled()));
} }
void UserManagerScreenHandler::ReportAuthenticationResult( void UserManagerScreenHandler::ReportAuthenticationResult(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment