Commit a2834c94 authored by Monica Basta's avatar Monica Basta Committed by Commit Bot

[ProfilePicker]: Add browse as a guest button to the main view.

Screenshot:
https://drive.google.com/file/d/1JFK-SPk-TANPt1g1i8wpIJc8nPsu8wzT/view?usp=sharing

Bug: 1063856
Change-Id: Ibe3f9c5086384dc7187fdd43d5eaea952e639b36
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2332709Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Reviewed-by: default avatarEsmael Elmoslimany <aee@chromium.org>
Commit-Queue: Monica Basta <msalama@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795052}
parent 9bea5be9
...@@ -667,6 +667,9 @@ ...@@ -667,6 +667,9 @@
<message name="IDS_PROFILE_PICKER_ASK_ON_STARTUP" desc="Text for the checkbox on the profile picker main view"> <message name="IDS_PROFILE_PICKER_ASK_ON_STARTUP" desc="Text for the checkbox on the profile picker main view">
Ask on startup Ask on startup
</message> </message>
<message name="IDS_PROFILE_PICKER_BROWSE_AS_GUEST_BUTTON" desc="Text for the profile picker main view button that launches guest session.">
Browse as Guest
</message>
<message name="IDS_PROFILE_PICKER_BACK_BUTTON_LABEL" desc="Label for a button that navigates user to the previous page"> <message name="IDS_PROFILE_PICKER_BACK_BUTTON_LABEL" desc="Label for a button that navigates user to the previous page">
Back Back
</message> </message>
......
12998557c02a35e50d016c53c9ab9bc3a778c724
\ No newline at end of file
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'chrome://resources/polymer/v3_0/iron-iconset-svg/iron-iconset-svg.js'; import 'chrome://resources/polymer/v3_0/iron-iconset-svg/iron-iconset-svg.js';
const element = document.createElement('iron-iconset-svg'); const element = document.createElement('iron-iconset-svg');
element.name = 'profiles'; element.name = 'profiles';
element.size = 74;
element.innerHTML = ` element.innerHTML = `
<svg> <svg>
<defs> <defs>
...@@ -10,6 +13,10 @@ element.innerHTML = ` ...@@ -10,6 +13,10 @@ element.innerHTML = `
<circle cx="37" cy="37" r="37" stroke="none"/> <circle cx="37" cy="37" r="37" stroke="none"/>
<path d="M36.9999 46.4349C36.1315 46.4349 35.4274 45.7309 35.4274 44.8624V38.5724H29.1374C28.269 38.5724 27.5649 37.8684 27.5649 36.9999C27.5649 36.1315 28.269 35.4274 29.1374 35.4274H35.4274V29.1374C35.4274 28.269 36.1315 27.5649 36.9999 27.5649C37.8684 27.5649 38.5724 28.269 38.5724 29.1374V35.4274H44.8624C45.7309 35.4274 46.4349 36.1315 46.4349 36.9999C46.4349 37.8684 45.7309 38.5724 44.8624 38.5724H38.5724V44.8624C38.5724 45.7309 37.8684 46.4349 36.9999 46.4349Z" fill="var(--iron-icon-stroke-color)"/> <path d="M36.9999 46.4349C36.1315 46.4349 35.4274 45.7309 35.4274 44.8624V38.5724H29.1374C28.269 38.5724 27.5649 37.8684 27.5649 36.9999C27.5649 36.1315 28.269 35.4274 29.1374 35.4274H35.4274V29.1374C35.4274 28.269 36.1315 27.5649 36.9999 27.5649C37.8684 27.5649 38.5724 28.269 38.5724 29.1374V35.4274H44.8624C45.7309 35.4274 46.4349 36.1315 46.4349 36.9999C46.4349 37.8684 45.7309 38.5724 44.8624 38.5724H38.5724V44.8624C38.5724 45.7309 37.8684 46.4349 36.9999 46.4349Z" fill="var(--iron-icon-stroke-color)"/>
</g> </g>
<g id="account-circle" viewBox="0 0 24 24" fill="var(--footer-text-color)" width="18px" height="18px">
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z"/>
</g>
</defs> </defs>
</svg>`; </svg>`;
document.head.appendChild(element); document.head.appendChild(element);
...@@ -37,6 +37,9 @@ export class ManageProfilesBrowserProxy { ...@@ -37,6 +37,9 @@ export class ManageProfilesBrowserProxy {
*/ */
launchSelectedProfile(profilePath) {} launchSelectedProfile(profilePath) {}
/** Launches Guest profile. */
launchGuestProfile() {}
/** /**
* Inform native the user's choice on whether to show the profile picker * Inform native the user's choice on whether to show the profile picker
* on startup or not. * on startup or not.
...@@ -67,6 +70,11 @@ export class ManageProfilesBrowserProxyImpl { ...@@ -67,6 +70,11 @@ export class ManageProfilesBrowserProxyImpl {
chrome.send('launchSelectedProfile', [profilePath]); chrome.send('launchSelectedProfile', [profilePath]);
} }
/** @override */
launchGuestProfile() {
chrome.send('launchGuestProfile');
}
/** @override */ /** @override */
askOnStartupChanged(shouldShow) { askOnStartupChanged(shouldShow) {
chrome.send('askOnStartupChanged', [shouldShow]); chrome.send('askOnStartupChanged', [shouldShow]);
......
...@@ -89,14 +89,6 @@ ...@@ -89,14 +89,6 @@
--cr-icon-button-stroke-color: var(--google-grey-refresh-700); --cr-icon-button-stroke-color: var(--google-grey-refresh-700);
} }
@media (prefers-color-scheme: dark) {
/* TODO(msalama): Dark mode mocks not ready yet.*/
cr-checkbox {
--cr-checkbox-label-color: var(--google-grey-refresh-500);
background-color: rgba(var(--md-background-color), .8);
}
}
.footer { .footer {
bottom: 0; bottom: 0;
display: flex; display: flex;
...@@ -105,14 +97,36 @@ ...@@ -105,14 +97,36 @@
width: 100%; width: 100%;
} }
.footer > * {
background-color: rgba(255, 255, 255, .8);
}
#browseAsGuestButton {
margin-inline-start: 40px;
}
#browseAsGuestButton > iron-icon {
margin-inline-end: 8px;
}
cr-checkbox { cr-checkbox {
--cr-checkbox-label-color: var(--google-grey-refresh-700); --cr-checkbox-label-color: var(--google-grey-refresh-700);
--cr-checkbox-label-padding-start: 8px; --cr-checkbox-label-padding-start: 8px;
background-color: rgba(255, 255, 255, .8);
justify-content: flex-end; justify-content: flex-end;
margin-inline-end: 40px; margin-inline-end: 40px;
margin-inline-start: auto; margin-inline-start: auto;
} }
@media (prefers-color-scheme: dark) {
/* TODO(msalama): Dark mode mocks not ready yet.*/
.footer > * {
background-color: rgba(0, 0, 0, .5);
}
cr-checkbox {
--cr-checkbox-label-color: var(--google-grey-refresh-500);
}
}
</style> </style>
<div id="leftBanner" class="banner"></div> <div id="leftBanner" class="banner"></div>
...@@ -139,6 +153,10 @@ ...@@ -139,6 +153,10 @@
<div id="rightBanner" class="banner"></div> <div id="rightBanner" class="banner"></div>
<div class="footer"> <div class="footer">
<cr-button id="browseAsGuestButton" on-click="onLaunchGuestProfileClick_">
<iron-icon icon="profiles:account-circle"></iron-icon>
<div>$i18n{browseAsGuestButton}</div>
</cr-button>
<cr-checkbox checked="{{askOnStartup_}}" <cr-checkbox checked="{{askOnStartup_}}"
on-change="onAskOnStartupChangedByUser_"> on-change="onAskOnStartupChangedByUser_">
$i18n{askOnStartupCheckboxText} $i18n{askOnStartupCheckboxText}
......
...@@ -92,4 +92,9 @@ Polymer({ ...@@ -92,4 +92,9 @@ Polymer({
onAddProfileClick_() { onAddProfileClick_() {
navigateTo(Routes.NEW_PROFILE); navigateTo(Routes.NEW_PROFILE);
}, },
/** @private */
onLaunchGuestProfileClick_() {
this.manageProfilesBrowserProxy_.launchGuestProfile();
},
}); });
...@@ -42,6 +42,10 @@ void ProfilePickerHandler::RegisterMessages() { ...@@ -42,6 +42,10 @@ void ProfilePickerHandler::RegisterMessages() {
"launchSelectedProfile", "launchSelectedProfile",
base::BindRepeating(&ProfilePickerHandler::HandleLaunchSelectedProfile, base::BindRepeating(&ProfilePickerHandler::HandleLaunchSelectedProfile,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"launchGuestProfile",
base::BindRepeating(&ProfilePickerHandler::HandleLaunchGuestProfile,
base::Unretained(this)));
web_ui()->RegisterMessageCallback( web_ui()->RegisterMessageCallback(
"askOnStartupChanged", "askOnStartupChanged",
base::BindRepeating(&ProfilePickerHandler::HandleAskOnStartupChanged, base::BindRepeating(&ProfilePickerHandler::HandleAskOnStartupChanged,
...@@ -107,6 +111,15 @@ void ProfilePickerHandler::HandleLaunchSelectedProfile( ...@@ -107,6 +111,15 @@ void ProfilePickerHandler::HandleLaunchSelectedProfile(
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
void ProfilePickerHandler::HandleLaunchGuestProfile(
const base::ListValue* args) {
// TODO(crbug.com/1063856): Add check |IsGuestModeEnabled| once policy
// checking has been added to the UI.
profiles::SwitchToGuestProfile(
base::Bind(&ProfilePickerHandler::OnSwitchToProfileComplete,
weak_factory_.GetWeakPtr()));
}
void ProfilePickerHandler::HandleAskOnStartupChanged( void ProfilePickerHandler::HandleAskOnStartupChanged(
const base::ListValue* args) { const base::ListValue* args) {
bool show_on_startup; bool show_on_startup;
......
...@@ -26,6 +26,7 @@ class ProfilePickerHandler : public content::WebUIMessageHandler, ...@@ -26,6 +26,7 @@ class ProfilePickerHandler : public content::WebUIMessageHandler,
private: private:
void HandleMainViewInitialize(const base::ListValue* args); void HandleMainViewInitialize(const base::ListValue* args);
void HandleLaunchSelectedProfile(const base::ListValue* args); void HandleLaunchSelectedProfile(const base::ListValue* args);
void HandleLaunchGuestProfile(const base::ListValue* args);
void HandleAskOnStartupChanged(const base::ListValue* args); void HandleAskOnStartupChanged(const base::ListValue* args);
void HandleGetNewProfileSuggestedThemeInfo(const base::ListValue* args); void HandleGetNewProfileSuggestedThemeInfo(const base::ListValue* args);
void HandleLoadSignInProfileCreationFlow(const base::ListValue* args); void HandleLoadSignInProfileCreationFlow(const base::ListValue* args);
......
...@@ -25,6 +25,7 @@ void AddStrings(content::WebUIDataSource* html_source) { ...@@ -25,6 +25,7 @@ void AddStrings(content::WebUIDataSource* html_source) {
{"mainViewTitle", IDS_PROFILE_PICKER_MAIN_VIEW_TITLE}, {"mainViewTitle", IDS_PROFILE_PICKER_MAIN_VIEW_TITLE},
{"mainViewSubtitle", IDS_PROFILE_PICKER_MAIN_VIEW_SUBTITLE}, {"mainViewSubtitle", IDS_PROFILE_PICKER_MAIN_VIEW_SUBTITLE},
{"askOnStartupCheckboxText", IDS_PROFILE_PICKER_ASK_ON_STARTUP}, {"askOnStartupCheckboxText", IDS_PROFILE_PICKER_ASK_ON_STARTUP},
{"browseAsGuestButton", IDS_PROFILE_PICKER_BROWSE_AS_GUEST_BUTTON},
{"backButtonLabel", IDS_PROFILE_PICKER_BACK_BUTTON_LABEL}, {"backButtonLabel", IDS_PROFILE_PICKER_BACK_BUTTON_LABEL},
{"profileTypeChoiceTitle", {"profileTypeChoiceTitle",
IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_PROFILE_TYPE_CHOICE_TITLE}, IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_PROFILE_TYPE_CHOICE_TITLE},
......
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