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/error_screen_handler.h"
7 #include "base/message_loop/message_loop.h"
8 #include "base/time/time.h"
9 #include "chrome/browser/chromeos/login/screens/network_error_model.h"
10 #include "chrome/grit/chromium_strings.h"
11 #include "chrome/grit/generated_resources.h"
12 #include "components/login/localized_values_builder.h"
13 #include "ui/strings/grit/ui_strings.h"
17 const char kJsScreenPath
[] = "login.ErrorMessageScreen";
23 ErrorScreenHandler::ErrorScreenHandler()
24 : BaseScreenHandler(kJsScreenPath
),
27 weak_ptr_factory_(this) {
30 ErrorScreenHandler::~ErrorScreenHandler() {
32 model_
->OnViewDestroyed(this);
35 void ErrorScreenHandler::PrepareToShow() {
38 void ErrorScreenHandler::Show() {
39 if (!page_is_ready()) {
43 BaseScreenHandler::ShowScreen(OobeUI::kScreenErrorMessage
, NULL
);
48 void ErrorScreenHandler::Hide() {
51 void ErrorScreenHandler::Bind(NetworkErrorModel
& model
) {
53 BaseScreenHandler::SetBaseScreen(model_
);
56 void ErrorScreenHandler::Unbind() {
58 BaseScreenHandler::SetBaseScreen(nullptr);
61 void ErrorScreenHandler::ShowScreen(OobeUI::Screen screen
) {
62 std::string screen_name
;
63 if (GetScreenName(screen
, &screen_name
))
64 BaseScreenHandler::ShowScreen(screen_name
.c_str(), NULL
);
67 bool ErrorScreenHandler::GetScreenName(OobeUI::Screen screen
,
68 std::string
* name
) const {
69 OobeUI
* oobe_ui
= static_cast<OobeUI
*>(web_ui()->GetController());
72 *name
= oobe_ui
->GetScreenName(screen
);
76 void ErrorScreenHandler::HandleHideCaptivePortal() {
77 model_
->HideCaptivePortal();
80 void ErrorScreenHandler::RegisterMessages() {
81 AddCallback("hideCaptivePortal",
82 &ErrorScreenHandler::HandleHideCaptivePortal
);
83 BaseScreenHandler::RegisterMessages();
86 void ErrorScreenHandler::DeclareLocalizedValues(
87 ::login::LocalizedValuesBuilder
* builder
) {
88 builder
->Add("loginErrorTitle", IDS_LOGIN_ERROR_TITLE
);
89 builder
->Add("rollbackErrorTitle", IDS_RESET_SCREEN_REVERT_ERROR
);
90 builder
->Add("signinOfflineMessageBody", IDS_LOGIN_OFFLINE_MESSAGE
);
91 builder
->Add("kioskOfflineMessageBody", IDS_KIOSK_OFFLINE_MESSAGE
);
92 builder
->Add("kioskOnlineTitle", IDS_LOGIN_NETWORK_RESTORED_TITLE
);
93 builder
->Add("kioskOnlineMessageBody", IDS_KIOSK_ONLINE_MESSAGE
);
94 builder
->Add("autoEnrollmentOfflineMessageBody",
95 IDS_LOGIN_AUTO_ENROLLMENT_OFFLINE_MESSAGE
);
96 builder
->AddF("rollbackErrorMessageBody",
97 IDS_RESET_SCREEN_REVERT_ERROR_EXPLANATION
,
98 IDS_SHORT_PRODUCT_NAME
);
99 builder
->Add("captivePortalTitle", IDS_LOGIN_MAYBE_CAPTIVE_PORTAL_TITLE
);
100 builder
->Add("captivePortalMessage", IDS_LOGIN_MAYBE_CAPTIVE_PORTAL
);
101 builder
->Add("captivePortalProxyMessage",
102 IDS_LOGIN_MAYBE_CAPTIVE_PORTAL_PROXY
);
103 builder
->Add("captivePortalNetworkSelect",
104 IDS_LOGIN_MAYBE_CAPTIVE_PORTAL_NETWORK_SELECT
);
105 builder
->Add("signinProxyMessageText", IDS_LOGIN_PROXY_ERROR_MESSAGE
);
106 builder
->Add("updateOfflineMessageBody", IDS_UPDATE_OFFLINE_MESSAGE
);
107 builder
->Add("updateProxyMessageText", IDS_UPDATE_PROXY_ERROR_MESSAGE
);
108 builder
->AddF("localStateErrorText0", IDS_LOCAL_STATE_ERROR_TEXT_0
,
109 IDS_SHORT_PRODUCT_NAME
);
110 builder
->Add("localStateErrorText1", IDS_LOCAL_STATE_ERROR_TEXT_1
);
111 builder
->Add("localStateErrorPowerwashButton",
112 IDS_LOCAL_STATE_ERROR_POWERWASH_BUTTON
);
113 builder
->Add("connectingIndicatorText", IDS_LOGIN_CONNECTING_INDICATOR_TEXT
);
114 builder
->Add("guestSigninFixNetwork", IDS_LOGIN_GUEST_SIGNIN_FIX_NETWORK
);
115 builder
->Add("rebootButton", IDS_RELAUNCH_BUTTON
);
116 builder
->Add("diagnoseButton", IDS_DIAGNOSE_BUTTON
);
117 builder
->Add("configureCertsButton", IDS_MANAGE_CERTIFICATES
);
118 builder
->Add("continueButton", IDS_NETWORK_SELECTION_CONTINUE_BUTTON
);
119 builder
->Add("okButton", IDS_APP_OK
);
122 void ErrorScreenHandler::Initialize() {
123 if (!page_is_ready())
127 // TODO(nkostylev): Check that context initial state is properly passed.
129 show_on_init_
= false;
133 } // namespace chromeos