OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "grit/chromium_strings.h" | 9 #include "grit/chromium_strings.h" |
10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 // Update screen ID. | 15 // Update screen ID. |
16 const char kUpdateScreen[] = "update"; | 16 const char kUpdateScreen[] = "update"; |
17 | 17 |
18 } // namespace | 18 } // namespace |
19 | 19 |
20 namespace chromeos { | 20 namespace chromeos { |
21 | 21 |
22 UpdateScreenHandler::UpdateScreenHandler() : show_on_init_(false) { | 22 UpdateScreenHandler::UpdateScreenHandler() |
| 23 : screen_(NULL), |
| 24 show_on_init_(false) { |
23 } | 25 } |
24 | 26 |
25 UpdateScreenHandler::~UpdateScreenHandler() { | 27 UpdateScreenHandler::~UpdateScreenHandler() { |
| 28 if (screen_) |
| 29 screen_->OnActorDestroyed(this); |
26 } | 30 } |
27 | 31 |
28 void UpdateScreenHandler::GetLocalizedStrings( | 32 void UpdateScreenHandler::GetLocalizedStrings( |
29 DictionaryValue *localized_strings) { | 33 DictionaryValue *localized_strings) { |
30 localized_strings->SetString("updateScreenTitle", | 34 localized_strings->SetString("updateScreenTitle", |
31 l10n_util::GetStringUTF16(IDS_UPDATE_SCREEN_TITLE)); | 35 l10n_util::GetStringUTF16(IDS_UPDATE_SCREEN_TITLE)); |
32 localized_strings->SetString("checkingForUpdates", | 36 localized_strings->SetString("checkingForUpdates", |
33 l10n_util::GetStringUTF16(IDS_CHECKING_FOR_UPDATES)); | 37 l10n_util::GetStringUTF16(IDS_CHECKING_FOR_UPDATES)); |
34 localized_strings->SetString("installingUpdateDesc", | 38 localized_strings->SetString("installingUpdateDesc", |
35 l10n_util::GetStringUTF16(IDS_INSTALLING_UPDATE_DESC)); | 39 l10n_util::GetStringUTF16(IDS_INSTALLING_UPDATE_DESC)); |
| 40 #if !defined(OFFICIAL_BUILD) |
| 41 localized_strings->SetString("cancelUpdateHint", |
| 42 l10n_util::GetStringUTF16(IDS_UPDATE_CANCEL)); |
| 43 localized_strings->SetString("cancelledUpdateMessage", |
| 44 l10n_util::GetStringUTF16(IDS_UPDATE_CANCELLED)); |
| 45 #endif |
36 } | 46 } |
37 | 47 |
38 void UpdateScreenHandler::Initialize() { | 48 void UpdateScreenHandler::Initialize() { |
39 if (show_on_init_) { | 49 if (show_on_init_) { |
40 Show(); | 50 Show(); |
41 show_on_init_ = false; | 51 show_on_init_ = false; |
42 } | 52 } |
43 } | 53 } |
44 | 54 |
| 55 void UpdateScreenHandler::SetDelegate(UpdateScreenActor::Delegate* screen) { |
| 56 screen_ = screen; |
| 57 } |
| 58 |
45 void UpdateScreenHandler::Show() { | 59 void UpdateScreenHandler::Show() { |
46 if (!page_is_ready()) { | 60 if (!page_is_ready()) { |
47 show_on_init_ = true; | 61 show_on_init_ = true; |
48 return; | 62 return; |
49 } | 63 } |
50 ShowScreen(kUpdateScreen, NULL); | 64 ShowScreen(kUpdateScreen, NULL); |
| 65 #if !defined(OFFICIAL_BUILD) |
| 66 web_ui_->CallJavascriptFunction("oobe.UpdateScreen.enableUpdateCancel"); |
| 67 #endif |
51 } | 68 } |
52 | 69 |
53 void UpdateScreenHandler::Hide() { | 70 void UpdateScreenHandler::Hide() { |
54 } | 71 } |
55 | 72 |
56 void UpdateScreenHandler::PrepareToShow() { | 73 void UpdateScreenHandler::PrepareToShow() { |
57 } | 74 } |
58 | 75 |
59 void UpdateScreenHandler::ShowManualRebootInfo() { | 76 void UpdateScreenHandler::ShowManualRebootInfo() { |
60 StringValue message(l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED)); | 77 StringValue message(l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED)); |
(...skipping 19 matching lines...) Expand all Loading... |
80 } else { | 97 } else { |
81 info_message.reset(Value::CreateStringValue( | 98 info_message.reset(Value::CreateStringValue( |
82 l10n_util::GetStringFUTF16(IDS_INSTALLING_UPDATE, | 99 l10n_util::GetStringFUTF16(IDS_INSTALLING_UPDATE, |
83 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)))); | 100 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)))); |
84 } | 101 } |
85 web_ui_->CallJavascriptFunction("cr.ui.Oobe.setUpdateMessage", | 102 web_ui_->CallJavascriptFunction("cr.ui.Oobe.setUpdateMessage", |
86 *info_message); | 103 *info_message); |
87 } | 104 } |
88 | 105 |
89 void UpdateScreenHandler::RegisterMessages() { | 106 void UpdateScreenHandler::RegisterMessages() { |
| 107 #if !defined(OFFICIAL_BUILD) |
| 108 web_ui_->RegisterMessageCallback( |
| 109 "cancelUpdate", |
| 110 NewCallback(this, &UpdateScreenHandler::HandleUpdateCancel)); |
| 111 #endif |
90 } | 112 } |
91 | 113 |
| 114 #if !defined(OFFICIAL_BUILD) |
| 115 void UpdateScreenHandler::HandleUpdateCancel(const base::ListValue* args) { |
| 116 DCHECK(args && args->empty()); |
| 117 screen_->CancelUpdate(); |
| 118 } |
| 119 #endif |
| 120 |
92 } // namespace chromeos | 121 } // namespace chromeos |
OLD | NEW |