Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / webui / chromeos / login / update_screen_handler.cc
blob811f814a1b263db457baaf7b3d9efdc4c409e740
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/update_screen_handler.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h"
9 #include "chrome/browser/chromeos/login/screens/update_model.h"
10 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
11 #include "chrome/grit/chromium_strings.h"
12 #include "chrome/grit/generated_resources.h"
13 #include "components/login/localized_values_builder.h"
14 #include "ui/base/l10n/l10n_util.h"
16 namespace {
18 const char kJsScreenPath[] = "login.UpdateScreen";
20 } // namespace
22 namespace chromeos {
24 UpdateScreenHandler::UpdateScreenHandler()
25 : BaseScreenHandler(kJsScreenPath), model_(nullptr), show_on_init_(false) {
28 UpdateScreenHandler::~UpdateScreenHandler() {
29 if (model_)
30 model_->OnViewDestroyed(this);
33 void UpdateScreenHandler::DeclareLocalizedValues(
34 ::login::LocalizedValuesBuilder* builder) {
35 builder->Add("checkingForUpdatesMsg", IDS_CHECKING_FOR_UPDATE_MSG);
36 builder->Add("installingUpdateDesc", IDS_UPDATE_MSG);
37 builder->Add("updateScreenTitle", IDS_UPDATE_SCREEN_TITLE);
38 builder->Add("updateScreenAccessibleTitle",
39 IDS_UPDATE_SCREEN_ACCESSIBLE_TITLE);
40 builder->Add("checkingForUpdates", IDS_CHECKING_FOR_UPDATES);
41 builder->Add("downloading", IDS_DOWNLOADING);
42 builder->Add("downloadingTimeLeftLong", IDS_DOWNLOADING_TIME_LEFT_LONG);
43 builder->Add("downloadingTimeLeftStatusOneHour",
44 IDS_DOWNLOADING_TIME_LEFT_STATUS_ONE_HOUR);
45 builder->Add("downloadingTimeLeftStatusMinutes",
46 IDS_DOWNLOADING_TIME_LEFT_STATUS_MINUTES);
47 builder->Add("downloadingTimeLeftSmall", IDS_DOWNLOADING_TIME_LEFT_SMALL);
49 #if !defined(OFFICIAL_BUILD)
50 builder->Add("cancelUpdateHint", IDS_UPDATE_CANCEL);
51 builder->Add("cancelledUpdateMessage", IDS_UPDATE_CANCELLED);
52 #else
53 builder->Add("cancelUpdateHint", IDS_EMPTY_STRING);
54 builder->Add("cancelledUpdateMessage", IDS_EMPTY_STRING);
55 #endif
58 void UpdateScreenHandler::Initialize() {
59 if (show_on_init_) {
60 Show();
61 show_on_init_ = false;
65 void UpdateScreenHandler::PrepareToShow() {
68 void UpdateScreenHandler::Show() {
69 if (!page_is_ready()) {
70 show_on_init_ = true;
71 return;
73 ShowScreen(OobeUI::kScreenOobeUpdate, NULL);
76 void UpdateScreenHandler::Hide() {
79 void UpdateScreenHandler::Bind(UpdateModel& model) {
80 model_ = &model;
81 BaseScreenHandler::SetBaseScreen(model_);
84 void UpdateScreenHandler::Unbind() {
85 model_ = nullptr;
86 BaseScreenHandler::SetBaseScreen(nullptr);
89 } // namespace chromeos