OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | 38 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); |
39 localized_strings->SetString("checkingForUpdatesMsg", | 39 localized_strings->SetString("checkingForUpdatesMsg", |
40 l10n_util::GetStringFUTF16(IDS_CHECKING_FOR_UPDATE_MSG, | 40 l10n_util::GetStringFUTF16(IDS_CHECKING_FOR_UPDATE_MSG, |
41 short_product_name)); | 41 short_product_name)); |
42 localized_strings->SetString("updateScreenTitle", | 42 localized_strings->SetString("updateScreenTitle", |
43 l10n_util::GetStringUTF16(IDS_UPDATE_SCREEN_TITLE)); | 43 l10n_util::GetStringUTF16(IDS_UPDATE_SCREEN_TITLE)); |
44 localized_strings->SetString("checkingForUpdates", | 44 localized_strings->SetString("checkingForUpdates", |
45 l10n_util::GetStringUTF16(IDS_CHECKING_FOR_UPDATES)); | 45 l10n_util::GetStringUTF16(IDS_CHECKING_FOR_UPDATES)); |
46 localized_strings->SetString("installingUpdateDesc", | 46 localized_strings->SetString("installingUpdateDesc", |
47 l10n_util::GetStringFUTF16(IDS_UPDATE_MSG, short_product_name)); | 47 l10n_util::GetStringFUTF16(IDS_UPDATE_MSG, short_product_name)); |
| 48 localized_strings->SetString("downloading", |
| 49 l10n_util::GetStringUTF16(IDS_DOWNLOADING)); |
48 localized_strings->SetString("downloadingTimeLeftLong", | 50 localized_strings->SetString("downloadingTimeLeftLong", |
49 l10n_util::GetStringUTF16(IDS_DOWNLOADING_TIME_LEFT_LONG)); | 51 l10n_util::GetStringUTF16(IDS_DOWNLOADING_TIME_LEFT_LONG)); |
50 localized_strings->SetString("downloadingTimeLeftStatusOneHour", | 52 localized_strings->SetString("downloadingTimeLeftStatusOneHour", |
51 l10n_util::GetStringUTF16(IDS_DOWNLOADING_TIME_LEFT_STATUS_ONE_HOUR)); | 53 l10n_util::GetStringUTF16(IDS_DOWNLOADING_TIME_LEFT_STATUS_ONE_HOUR)); |
52 localized_strings->SetString("downloadingTimeLeftStatusMinutes", | 54 localized_strings->SetString("downloadingTimeLeftStatusMinutes", |
53 l10n_util::GetStringUTF16(IDS_DOWNLOADING_TIME_LEFT_STATUS_MINUTES)); | 55 l10n_util::GetStringUTF16(IDS_DOWNLOADING_TIME_LEFT_STATUS_MINUTES)); |
54 localized_strings->SetString("downloadingTimeLeftSmall", | 56 localized_strings->SetString("downloadingTimeLeftSmall", |
55 l10n_util::GetStringUTF16(IDS_DOWNLOADING_TIME_LEFT_SMALL)); | 57 l10n_util::GetStringUTF16(IDS_DOWNLOADING_TIME_LEFT_SMALL)); |
56 #if !defined(OFFICIAL_BUILD) | 58 #if !defined(OFFICIAL_BUILD) |
57 localized_strings->SetString("cancelUpdateHint", | 59 localized_strings->SetString("cancelUpdateHint", |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 StringValue message(l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED)); | 95 StringValue message(l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED)); |
94 web_ui()->CallJavascriptFunction("cr.ui.Oobe.setUpdateMessage", message); | 96 web_ui()->CallJavascriptFunction("cr.ui.Oobe.setUpdateMessage", message); |
95 } | 97 } |
96 | 98 |
97 void UpdateScreenHandler::SetProgress(int progress) { | 99 void UpdateScreenHandler::SetProgress(int progress) { |
98 base::FundamentalValue progress_value(progress); | 100 base::FundamentalValue progress_value(progress); |
99 web_ui()->CallJavascriptFunction("cr.ui.Oobe.setUpdateProgress", | 101 web_ui()->CallJavascriptFunction("cr.ui.Oobe.setUpdateProgress", |
100 progress_value); | 102 progress_value); |
101 } | 103 } |
102 | 104 |
103 void UpdateScreenHandler::ShowEstimatedTimeLeft(bool enable) { | 105 void UpdateScreenHandler::ShowEstimatedTimeLeft(bool visible) { |
104 base::FundamentalValue enable_value(enable); | 106 base::FundamentalValue visible_value(visible); |
105 web_ui()->CallJavascriptFunction( | 107 web_ui()->CallJavascriptFunction( |
106 "cr.ui.Oobe.showUpdateEstimatedTimeLeft", enable_value); | 108 "cr.ui.Oobe.showEstimatedTimeLeft", visible_value); |
107 } | 109 } |
108 | 110 |
109 void UpdateScreenHandler::SetEstimatedTimeLeft(const base::TimeDelta& time) { | 111 void UpdateScreenHandler::SetEstimatedTimeLeft(const base::TimeDelta& time) { |
110 base::FundamentalValue seconds_value(time.InSecondsF()); | 112 base::FundamentalValue seconds_value(time.InSecondsF()); |
111 web_ui()->CallJavascriptFunction( | 113 web_ui()->CallJavascriptFunction( |
112 "cr.ui.Oobe.setUpdateEstimatedTimeLeft", seconds_value); | 114 "cr.ui.Oobe.setEstimatedTimeLeft", seconds_value); |
113 } | 115 } |
114 | 116 |
115 void UpdateScreenHandler::ShowCurtain(bool enable) { | 117 void UpdateScreenHandler::ShowProgressMessage(bool visible) { |
116 base::FundamentalValue enable_value(enable); | 118 base::FundamentalValue visible_value(visible); |
117 web_ui()->CallJavascriptFunction( | 119 web_ui()->CallJavascriptFunction( |
118 "cr.ui.Oobe.showUpdateCurtain", enable_value); | 120 "cr.ui.Oobe.showProgressMessage", visible_value); |
119 } | 121 } |
120 | 122 |
121 void UpdateScreenHandler::ShowPreparingUpdatesInfo(bool visible) { | 123 void UpdateScreenHandler::SetProgressMessage(ProgressMessage message) { |
122 scoped_ptr<StringValue> info_message; | 124 scoped_ptr<StringValue> progress_message; |
123 if (visible) { | 125 switch (message) { |
124 info_message.reset(Value::CreateStringValue( | 126 case PROGRESS_MESSAGE_UPDATE_AVAILABLE: |
125 l10n_util::GetStringUTF16(IDS_UPDATE_AVAILABLE))); | 127 progress_message.reset(Value::CreateStringValue( |
126 } else { | 128 l10n_util::GetStringUTF16(IDS_UPDATE_AVAILABLE))); |
127 info_message.reset(Value::CreateStringValue( | 129 break; |
128 l10n_util::GetStringFUTF16(IDS_INSTALLING_UPDATE, | 130 case PROGRESS_MESSAGE_INSTALLING_UPDATE: |
129 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)))); | 131 progress_message.reset(Value::CreateStringValue( |
| 132 l10n_util::GetStringFUTF16(IDS_INSTALLING_UPDATE, |
| 133 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)))); |
| 134 break; |
| 135 case PROGRESS_MESSAGE_VERIFYING: |
| 136 progress_message.reset(Value::CreateStringValue( |
| 137 l10n_util::GetStringUTF16(IDS_UPDATE_VERIFYING))); |
| 138 break; |
| 139 case PROGRESS_MESSAGE_FINALIZING: |
| 140 progress_message.reset(Value::CreateStringValue( |
| 141 l10n_util::GetStringUTF16(IDS_UPDATE_FINALIZING))); |
| 142 break; |
| 143 default: |
| 144 NOTREACHED(); |
| 145 }; |
| 146 if (progress_message.get()) { |
| 147 web_ui()->CallJavascriptFunction( |
| 148 "cr.ui.Oobe.setProgressMessage", *progress_message); |
130 } | 149 } |
131 web_ui()->CallJavascriptFunction("cr.ui.Oobe.setUpdateMessage", | 150 } |
132 *info_message); | 151 |
| 152 void UpdateScreenHandler::ShowCurtain(bool visible) { |
| 153 base::FundamentalValue visible_value(visible); |
| 154 web_ui()->CallJavascriptFunction( |
| 155 "cr.ui.Oobe.showUpdateCurtain", visible_value); |
133 } | 156 } |
134 | 157 |
135 void UpdateScreenHandler::RegisterMessages() { | 158 void UpdateScreenHandler::RegisterMessages() { |
136 #if !defined(OFFICIAL_BUILD) | 159 #if !defined(OFFICIAL_BUILD) |
137 web_ui()->RegisterMessageCallback("cancelUpdate", | 160 web_ui()->RegisterMessageCallback("cancelUpdate", |
138 base::Bind(&UpdateScreenHandler::HandleUpdateCancel, | 161 base::Bind(&UpdateScreenHandler::HandleUpdateCancel, |
139 base::Unretained(this))); | 162 base::Unretained(this))); |
140 #endif | 163 #endif |
141 } | 164 } |
142 | 165 |
143 #if !defined(OFFICIAL_BUILD) | 166 #if !defined(OFFICIAL_BUILD) |
144 void UpdateScreenHandler::HandleUpdateCancel(const base::ListValue* args) { | 167 void UpdateScreenHandler::HandleUpdateCancel(const base::ListValue* args) { |
145 DCHECK(args && args->empty()); | 168 DCHECK(args && args->empty()); |
146 screen_->CancelUpdate(); | 169 screen_->CancelUpdate(); |
147 } | 170 } |
148 #endif | 171 #endif |
149 | 172 |
150 } // namespace chromeos | 173 } // namespace chromeos |
OLD | NEW |