Commit 322be03c authored by Danila Kuzmin's avatar Danila Kuzmin Committed by Commit Bot

oobe: Migrate EulaScreen to LoginScreenBehavior

Bug: 1106367
Change-Id: Idcb023a623bd230eeba79618162ee47d6c0c5181
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2303717Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Commit-Queue: Danila Kuzmin <dkuzmin@google.com>
Cr-Commit-Position: refs/heads/master@{#795072}
parent b6f48f5b
......@@ -75,14 +75,13 @@ const test::UIPath kAcceptEulaButton = {"oobe-eula-md", "acceptButton"};
const test::UIPath kEulaTPMPassword = {"oobe-eula-md", "eula-password"};
const test::UIPath kUsageStats = {"oobe-eula-md", "usageStats"};
const test::UIPath kAdditionalTermsLink = {"oobe-eula-md", "additionalTerms"};
const test::UIPath kAdditionalTermsDialog = {"oobe-eula-md", "additional-tos"};
const test::UIPath kAdditionalTermsDialog = {"oobe-eula-md", "additionalToS"};
const test::UIPath kAdditionalTermsClose = {"oobe-eula-md",
"close-additional-tos"};
const test::UIPath kInstallationSettingsLink = {"oobe-eula-md",
"installationSettings"};
const test::UIPath kInstallationSettingsDialog = {"oobe-eula-md",
"installationSettingsDialog"};
const test::UIPath kLearnMoreLink = {"oobe-eula-md", "learn-more"};
const test::UIPath kSecuritySettingsLink = {"oobe-eula-md", "securitySettings"};
const test::UIPath kSecuritySettingsDialog = {"oobe-eula-md",
"securitySettingsDialog"};
const test::UIPath kLearnMoreLink = {"oobe-eula-md", "learnMore"};
// Helper class to wait until the WebCotnents finishes loading.
class WebContentsLoadFinishedWaiter : public content::WebContentsObserver {
......@@ -320,8 +319,8 @@ IN_PROC_BROWSER_TEST_F(EulaTest, DisplaysTpmPassword) {
base::HistogramTester histogram_tester;
ShowEulaScreen();
test::OobeJS().TapLinkOnPath(kInstallationSettingsLink);
test::OobeJS().ExpectVisiblePath(kInstallationSettingsDialog);
test::OobeJS().TapLinkOnPath(kSecuritySettingsLink);
test::OobeJS().ExpectVisiblePath(kSecuritySettingsDialog);
test::OobeJS()
.CreateWaiter(
......
......@@ -149,7 +149,17 @@ void EulaScreen::OnUserAction(const std::string& action_id) {
return;
}
RecordUserAction(action_id);
if (action_id == kUserActionAcceptButtonClicked) {
if (action_id == kUserActionShowStatsUsageLearnMore) {
ShowStatsUsageLearnMore();
} else if (action_id == kUserActionShowAdditionalTos) {
ShowAdditionalTosDialog();
} else if (action_id == kUserActionShowSecuritySettings) {
InitiatePasswordFetch();
} else if (action_id == kUserActionSelectStatsUsage) {
SetUsageStatsEnabled(true);
} else if (action_id == kUserActionUnselectStatsUsage) {
SetUsageStatsEnabled(false);
} else if (action_id == kUserActionAcceptButtonClicked) {
exit_callback_.Run(g_usage_statistics_reporting_enabled
? Result::ACCEPTED_WITH_USAGE_STATS_REPORTING
: Result::ACCEPTED_WITHOUT_USAGE_STATS_REPORTING);
......@@ -172,4 +182,14 @@ void EulaScreen::OnPasswordFetched(const std::string& tpm_password) {
view_->OnPasswordFetched(tpm_password_);
}
void EulaScreen::ShowStatsUsageLearnMore() {
if (view_)
view_->ShowStatsUsageLearnMore();
}
void EulaScreen::ShowAdditionalTosDialog() {
if (view_)
view_->ShowAdditionalTosDialog();
}
} // namespace chromeos
......@@ -81,6 +81,8 @@ class EulaScreen : public BaseScreen, public TpmPasswordFetcherDelegate {
// TpmPasswordFetcherDelegate implementation:
void OnPasswordFetched(const std::string& tpm_password) override;
void ShowStatsUsageLearnMore();
void ShowAdditionalTosDialog();
// URL of the OEM EULA page (on disk).
GURL oem_eula_page_;
......
......@@ -36,6 +36,8 @@ class MockEulaView : public EulaView {
MOCK_METHOD(void, MockBind, (EulaScreen * screen));
MOCK_METHOD(void, MockUnbind, ());
MOCK_METHOD(void, OnPasswordFetched, (const std::string& tpm_password));
MOCK_METHOD(void, ShowStatsUsageLearnMore, ());
MOCK_METHOD(void, ShowAdditionalTosDialog, ());
private:
EulaScreen* screen_ = nullptr;
......
......@@ -216,6 +216,8 @@ js_library("oobe_enable_kiosk") {
js_library("oobe_eula") {
deps = [
":web_view_helper",
"components:login_screen_behavior",
"components:oobe_dialog",
"components:oobe_dialog_host_behavior",
"components:oobe_i18n_behavior",
......@@ -284,3 +286,6 @@ js_library("throbber_notice") {
js_library("update_required_card") {
}
js_library("web_view_helper") {
}
......@@ -38,7 +38,6 @@
// <include src="oobe_screen_demo_setup.js">
// <include src="oobe_screen_demo_preferences.js">
// <include src="oobe_screen_enable_debugging.js">
// <include src="oobe_screen_eula.js">
// <include src="multi_tap_detector.js">
// <include src="web_view_helper.js">
......@@ -50,7 +49,6 @@ cr.define('cr.ui.Oobe', function() {
*/
initialize() {
cr.ui.login.DisplayManager.initialize();
login.EulaScreen.register();
login.AutoEnrollmentCheckScreen.register();
login.EnableDebuggingScreen.register();
login.AutolaunchScreen.register();
......
......@@ -17,7 +17,7 @@ a {
height: 300px;
}
#installationSettings,
#securitySettings,
#logging {
font-size: 13px;
min-height: unset;
......@@ -28,7 +28,7 @@ a {
}
#additionalTerms,
#installationSettings,
#securitySettings,
#logging {
margin-top: 16px;
}
......@@ -65,6 +65,6 @@ cr-checkbox {
user-select: text;
}
.installation-settings-spinner {
.security-settings-spinner {
margin-inline-end: 5px;
}
......@@ -40,10 +40,10 @@
class="oobe-local-link">
[[i18nDynamic(locale, 'oobeEulaAditionalTerms')]]
</a>
<a id="installationSettings" href="#"
<a id="securitySettings" href="#"
class="oobe-local-link"
on-tap="onInstallationSettingsClicked_">
[[i18nDynamic(locale, 'eulaSystemInstallationSettings')]]
on-tap="onSecuritySettingsClicked_">
[[i18nDynamic(locale, 'eulaSystemSecuritySettings')]]
</a>
<div id="logging" class="layout horizontal">
<cr-checkbox id="usageStats" class="layout start self-center"
......@@ -53,7 +53,7 @@
<span id="usageStatsLabel">
[[i18nDynamic(locale, 'checkboxLogging')]]
</span>
<a id="learn-more" href="#"
<a id="learnMore" href="#"
on-tap="onUsageStatsHelpLinkClicked_"
class="oobe-local-link">
[[i18nDynamic(locale, 'learnMore')]]
......@@ -75,9 +75,9 @@
</oobe-text-button>
</div>
</oobe-dialog>
<oobe-dialog id="installationSettingsDialog" role="dialog" has-buttons
title-key="eulaSystemInstallationSettings" hidden
aria-label$="[[i18nDynamic(locale, 'eulaSystemInstallationSettings')]]">
<oobe-dialog id="securitySettingsDialog" role="dialog" has-buttons
title-key="eulaSystemSecuritySettings" hidden
aria-label$="[[i18nDynamic(locale, 'eulaSystemSecuritySettings')]]">
<hd-iron-icon slot="oobe-icon"
icon1x="oobe-32:googleg" icon2x="oobe-64:googleg">
</hd-iron-icon>
......@@ -95,7 +95,7 @@
</div>
<div class="layout horizontal"
hidden="[[!isWaitingForPassword_(password)]]">
<div class="installation-settings-spinner throbber"></div>
<div class="security-settings-spinner throbber"></div>
<div>
[[i18nDynamic(locale, 'eulaTpmBusy')]]
</div>
......@@ -111,11 +111,11 @@
<div class="flex"></div>
<oobe-text-button id="settings-close-button" inverse
class="focus-on-show"
text-key="eulaSystemInstallationSettingsOkButton"
on-tap="onInstallationSettingsCloseClicked_"></oobe-text-button>
text-key="eulaSystemSecuritySettingsOkButton"
on-tap="onSecuritySettingsCloseClicked_"></oobe-text-button>
</div>
</oobe-dialog>
<cr-dialog id="additional-tos" ignore-popstate
<cr-dialog id="additionalToS" ignore-popstate
on-close="focusAdditionalTermsLink_"
on-cancel="focusAdditionalTermsLink_">
<div slot="title">
......
<div class="step hidden" id="eula" role="group"
i18n-values="aria-label:eulaScreenAccessibleTitle" hidden>
<oobe-eula-md id="oobe-eula-md"></oobe-eula-md>
</div>
......@@ -13,7 +13,7 @@
<include src="../oobe_screen_demo_setup.html">
<oobe-network id="network-selection" class="step hidden" hidden>
</oobe-network>
<include src="../oobe_screen_eula.html">
<oobe-eula-md id="oobe-eula-md" class="step hidden" hidden></oobe-eula-md>
<oobe-update id="oobe-update" class="step hidden" hidden>
</oobe-update>
<include src="../oobe_screen_auto_enrollment_check.html">
......
......@@ -13,9 +13,10 @@ class WebViewHelper {
* The content is loaded via XHR and is sent to web view via data url so that
* it is properly sandboxed.
*
* @param {!WebView} webView web view element to host the content.
* @param {!Object} webView is a WebView element to host the content.
* @param {string} url URL to load the content from.
* @param {!ContentType} contentType type of the content to load.
* @param {!WebViewHelper.ContentType} contentType type of the content to
* load.
*/
static loadUrlContentToWebView(webView, url, contentType) {
assert(webView.tagName === 'WEBVIEW');
......@@ -59,7 +60,8 @@ class WebViewHelper {
onError();
return;
}
setContents(xhr.response);
let contents = /** @type {string} */ (xhr.response);
setContents(contents);
};
try {
......@@ -79,4 +81,4 @@ WebViewHelper.ContentType = {
HTML: 'text/html',
/** Base64 encoded application/pdf content type. */
PDF: 'application/pdf',
};
\ No newline at end of file
};
......@@ -89,8 +89,7 @@ void EulaScreenHandler::DeclareLocalizedValues(
builder->Add("back", IDS_EULA_BACK_BUTTON);
builder->Add("next", IDS_EULA_NEXT_BUTTON);
builder->Add("acceptAgreement", IDS_EULA_ACCEPT_AND_CONTINUE_BUTTON);
builder->Add("eulaSystemInstallationSettings",
IDS_EULA_SYSTEM_SECURITY_SETTING);
builder->Add("eulaSystemSecuritySettings", IDS_EULA_SYSTEM_SECURITY_SETTING);
builder->Add("eulaTpmDesc", IDS_EULA_SECURE_MODULE_DESCRIPTION);
builder->Add("eulaTpmKeyDesc", IDS_EULA_SECURE_MODULE_KEY_DESCRIPTION);
......@@ -100,7 +99,7 @@ void EulaScreenHandler::DeclareLocalizedValues(
::login::GetSecureModuleUsed(base::BindOnce(
&EulaScreenHandler::UpdateLocalizedValues, weak_factory_.GetWeakPtr()));
builder->Add("eulaSystemInstallationSettingsOkButton", IDS_OK);
builder->Add("eulaSystemSecuritySettingsOkButton", IDS_OK);
builder->Add("termsOfServiceLoading", IDS_TERMS_OF_SERVICE_SCREEN_LOADING);
#if BUILDFLAG(ENABLE_RLZ)
builder->AddF("eulaRlzDesc",
......@@ -124,14 +123,6 @@ void EulaScreenHandler::DeclareLocalizedValues(
IDS_OOBE_EULA_ACCEPT_AND_CONTINUE_BUTTON_TEXT);
}
void EulaScreenHandler::DeclareJSCallbacks() {
AddCallback("eulaOnLearnMore", &EulaScreenHandler::HandleOnLearnMore);
AddCallback("eulaOnInstallationSettingsPopupOpened",
&EulaScreenHandler::HandleOnInstallationSettingsPopupOpened);
AddCallback("EulaScreen.usageStatsEnabled",
&EulaScreenHandler::HandleUsageStatsEnabled);
}
void EulaScreenHandler::GetAdditionalParameters(base::DictionaryValue* dict) {
#if BUILDFLAG(ENABLE_RLZ)
dict->SetString("rlzEnabled", "enabled");
......@@ -154,23 +145,18 @@ void EulaScreenHandler::Initialize() {
void EulaScreenHandler::OnPasswordFetched(const std::string& tpm_password) {
CallJS("login.EulaScreen.setTpmPassword", tpm_password);
CallJS("login.EulaScreen.showSecuritySettingsDialog");
}
void EulaScreenHandler::HandleOnLearnMore() {
void EulaScreenHandler::ShowStatsUsageLearnMore() {
if (!help_app_.get())
help_app_ = new HelpAppLauncher(
LoginDisplayHost::default_host()->GetNativeWindow());
help_app_->ShowHelpTopic(HelpAppLauncher::HELP_STATS_USAGE);
}
void EulaScreenHandler::HandleOnInstallationSettingsPopupOpened() {
if (screen_)
screen_->InitiatePasswordFetch();
}
void EulaScreenHandler::HandleUsageStatsEnabled(bool enabled) {
if (screen_)
screen_->SetUsageStatsEnabled(enabled);
void EulaScreenHandler::ShowAdditionalTosDialog() {
CallJS("login.EulaScreen.showAdditionalTosDialog");
}
void EulaScreenHandler::UpdateLocalizedValues(
......
......@@ -26,7 +26,7 @@ class HelpAppLauncher;
// dtor.
class EulaView {
public:
constexpr static StaticOobeScreenId kScreenId{"eula"};
constexpr static StaticOobeScreenId kScreenId{"oobe-eula-md"};
virtual ~EulaView() {}
......@@ -35,6 +35,8 @@ class EulaView {
virtual void Bind(EulaScreen* screen) = 0;
virtual void Unbind() = 0;
virtual void OnPasswordFetched(const std::string& tpm_password) = 0;
virtual void ShowStatsUsageLearnMore() = 0;
virtual void ShowAdditionalTosDialog() = 0;
};
// WebUI implementation of EulaScreenView. It is used to interact
......@@ -53,20 +55,16 @@ class EulaScreenHandler : public EulaView, public BaseScreenHandler {
void Bind(EulaScreen* screen) override;
void Unbind() override;
void OnPasswordFetched(const std::string& tpm_password) override;
void ShowStatsUsageLearnMore() override;
void ShowAdditionalTosDialog() override;
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
void DeclareJSCallbacks() override;
void GetAdditionalParameters(base::DictionaryValue* dict) override;
void Initialize() override;
private:
// JS messages handlers.
void HandleOnLearnMore();
void HandleOnInstallationSettingsPopupOpened();
void HandleUsageStatsEnabled(bool enabled);
// Determines the online URL to use.
std::string GetEulaOnlineUrl();
std::string GetAdditionalToSUrl();
......@@ -76,12 +74,12 @@ class EulaScreenHandler : public EulaView, public BaseScreenHandler {
EulaScreen* screen_ = nullptr;
CoreOobeView* core_oobe_view_ = nullptr;
// Help application used for help dialogs.
scoped_refptr<HelpAppLauncher> help_app_;
// Keeps whether screen should be shown right after initialization.
bool show_on_init_ = false;
// Help application used for help dialogs.
scoped_refptr<HelpAppLauncher> help_app_;
base::WeakPtrFactory<EulaScreenHandler> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(EulaScreenHandler);
......
......@@ -12,7 +12,6 @@
/** @const */ var SCREEN_WELCOME = 'connect';
/** @const */ var SCREEN_OOBE_NETWORK = 'network-selection';
/** @const */ var SCREEN_OOBE_HID_DETECTION = 'hid-detection';
/** @const */ var SCREEN_OOBE_EULA = 'eula';
/** @const */ var SCREEN_OOBE_ENABLE_DEBUGGING = 'debugging';
/** @const */ var SCREEN_OOBE_UPDATE = 'oobe-update';
/** @const */ var SCREEN_OOBE_RESET = 'reset';
......@@ -94,7 +93,6 @@ cr.define('cr.ui.login', function() {
*/
var RESET_AVAILABLE_SCREEN_GROUP = [
SCREEN_OOBE_NETWORK,
SCREEN_OOBE_EULA,
SCREEN_OOBE_AUTO_ENROLLMENT_CHECK,
SCREEN_GAIA_SIGNIN,
SCREEN_ACCOUNT_PICKER,
......
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