1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h"
9 #include "chrome/browser/chromeos/login/help_app_launcher.h"
10 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h"
11 #include "chrome/browser/chromeos/login/webui_login_display.h"
12 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
13 #include "chrome/common/url_constants.h"
14 #include "grit/browser_resources.h"
15 #include "grit/chromium_strings.h"
16 #include "grit/generated_resources.h"
17 #include "ui/views/widget/widget.h"
21 const char kJsScreenPath
[] = "login.EulaScreen";
27 EulaScreenHandler::EulaScreenHandler(CoreOobeActor
* core_oobe_actor
)
28 : BaseScreenHandler(kJsScreenPath
),
30 core_oobe_actor_(core_oobe_actor
),
31 show_on_init_(false) {
34 EulaScreenHandler::~EulaScreenHandler() {
36 delegate_
->OnActorDestroyed(this);
39 void EulaScreenHandler::PrepareToShow() {
42 void EulaScreenHandler::Show() {
43 if (!page_is_ready()) {
47 ShowScreen(OobeUI::kScreenOobeEula
, NULL
);
50 void EulaScreenHandler::Hide() {
53 void EulaScreenHandler::SetDelegate(Delegate
* delegate
) {
59 void EulaScreenHandler::DeclareLocalizedValues(
60 LocalizedValuesBuilder
* builder
) {
61 builder
->Add("eulaScreenTitle", IDS_EULA_SCREEN_TITLE
);
62 builder
->Add("checkboxLogging", IDS_EULA_CHECKBOX_ENABLE_LOGGING
);
63 builder
->Add("back", IDS_EULA_BACK_BUTTON
);
64 builder
->Add("acceptAgreement", IDS_EULA_ACCEPT_AND_CONTINUE_BUTTON
);
65 builder
->Add("eulaSystemInstallationSettings",
66 IDS_EULA_SYSTEM_SECURITY_SETTING
);
67 builder
->Add("eulaTpmDesc", IDS_EULA_TPM_DESCRIPTION
);
68 builder
->Add("eulaTpmKeyDesc", IDS_EULA_TPM_KEY_DESCRIPTION
);
69 builder
->Add("eulaTpmDescPowerwash", IDS_EULA_TPM_KEY_DESCRIPTION_POWERWASH
);
70 builder
->Add("eulaTpmBusy", IDS_EULA_TPM_BUSY
);
71 builder
->Add("eulaSystemInstallationSettingsOkButton", IDS_OK
);
72 builder
->Add("termsOfServiceLoading", IDS_TERMS_OF_SERVICE_SCREEN_LOADING
);
73 #if defined(ENABLE_RLZ)
74 builder
->AddF("eulaRlzDesc",
75 IDS_EULA_RLZ_DESCRIPTION
,
76 IDS_SHORT_PRODUCT_NAME
,
78 builder
->AddF("eulaRlzEnable",
80 IDS_SHORT_PRODUCT_OS_NAME
);
84 void EulaScreenHandler::GetAdditionalParameters(base::DictionaryValue
* dict
) {
85 #if defined(ENABLE_RLZ)
86 dict
->SetString("rlzEnabled", "enabled");
88 dict
->SetString("rlzEnabled", "disabled");
92 void EulaScreenHandler::Initialize() {
93 if (!page_is_ready() || !delegate_
)
96 core_oobe_actor_
->SetUsageStats(delegate_
->IsUsageStatsEnabled());
98 // This OEM EULA is a file:// URL which we're unable to load in iframe.
99 // Instead if it's defined we use chrome://terms/oem that will load same file.
100 if (!delegate_
->GetOemEulaUrl().is_empty())
101 core_oobe_actor_
->SetOemEulaUrl(chrome::kChromeUITermsOemURL
);
105 show_on_init_
= false;
109 void EulaScreenHandler::RegisterMessages() {
110 AddCallback("eulaOnExit", &EulaScreenHandler::HandleOnExit
);
111 AddCallback("eulaOnLearnMore", &EulaScreenHandler::HandleOnLearnMore
);
112 AddCallback("eulaOnInstallationSettingsPopupOpened",
113 &EulaScreenHandler::HandleOnInstallationSettingsPopupOpened
);
116 void EulaScreenHandler::OnPasswordFetched(const std::string
& tpm_password
) {
117 core_oobe_actor_
->SetTpmPassword(tpm_password
);
120 void EulaScreenHandler::HandleOnExit(bool accepted
, bool usage_stats_enabled
) {
122 delegate_
->OnExit(accepted
, usage_stats_enabled
);
125 void EulaScreenHandler::HandleOnLearnMore() {
126 if (!help_app_
.get())
127 help_app_
= new HelpAppLauncher(GetNativeWindow());
128 help_app_
->ShowHelpTopic(HelpAppLauncher::HELP_STATS_USAGE
);
131 void EulaScreenHandler::HandleOnInstallationSettingsPopupOpened() {
133 delegate_
->InitiatePasswordFetch();
136 } // namespace chromeos