OLD | NEW |
1 // Copyright (c) 2011 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" |
11 #include "content/public/browser/web_ui.h" | 11 #include "content/public/browser/web_ui.h" |
(...skipping 19 matching lines...) Expand all Loading... |
31 if (screen_) | 31 if (screen_) |
32 screen_->OnActorDestroyed(this); | 32 screen_->OnActorDestroyed(this); |
33 } | 33 } |
34 | 34 |
35 void UpdateScreenHandler::GetLocalizedStrings( | 35 void UpdateScreenHandler::GetLocalizedStrings( |
36 DictionaryValue *localized_strings) { | 36 DictionaryValue *localized_strings) { |
37 localized_strings->SetString("updateScreenTitle", | 37 localized_strings->SetString("updateScreenTitle", |
38 l10n_util::GetStringUTF16(IDS_UPDATE_SCREEN_TITLE)); | 38 l10n_util::GetStringUTF16(IDS_UPDATE_SCREEN_TITLE)); |
39 localized_strings->SetString("checkingForUpdates", | 39 localized_strings->SetString("checkingForUpdates", |
40 l10n_util::GetStringUTF16(IDS_CHECKING_FOR_UPDATES)); | 40 l10n_util::GetStringUTF16(IDS_CHECKING_FOR_UPDATES)); |
| 41 localized_strings->SetString("updateStatsEstimating", |
| 42 l10n_util::GetStringUTF16(IDS_UPDATE_STATS_ESTIMATING)); |
| 43 localized_strings->SetString("updateEstimatedTimeLeft", |
| 44 l10n_util::GetStringUTF16(IDS_UPDATE_DOWNLOADING_ESTIMATED_TIME_LEFT)); |
| 45 localized_strings->SetString("updateDownloadingRate", |
| 46 l10n_util::GetStringUTF16(IDS_UPDATE_DOWNLOADING_RATE)); |
41 localized_strings->SetString("installingUpdateDesc", | 47 localized_strings->SetString("installingUpdateDesc", |
42 l10n_util::GetStringUTF16(IDS_INSTALLING_UPDATE_DESC)); | 48 l10n_util::GetStringUTF16(IDS_INSTALLING_UPDATE_DESC)); |
43 #if !defined(OFFICIAL_BUILD) | 49 #if !defined(OFFICIAL_BUILD) |
44 localized_strings->SetString("cancelUpdateHint", | 50 localized_strings->SetString("cancelUpdateHint", |
45 l10n_util::GetStringUTF16(IDS_UPDATE_CANCEL)); | 51 l10n_util::GetStringUTF16(IDS_UPDATE_CANCEL)); |
46 localized_strings->SetString("cancelledUpdateMessage", | 52 localized_strings->SetString("cancelledUpdateMessage", |
47 l10n_util::GetStringUTF16(IDS_UPDATE_CANCELLED)); | 53 l10n_util::GetStringUTF16(IDS_UPDATE_CANCELLED)); |
48 #endif | 54 #endif |
49 } | 55 } |
50 | 56 |
(...skipping 29 matching lines...) Expand all Loading... |
80 StringValue message(l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED)); | 86 StringValue message(l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED)); |
81 web_ui()->CallJavascriptFunction("cr.ui.Oobe.setUpdateMessage", message); | 87 web_ui()->CallJavascriptFunction("cr.ui.Oobe.setUpdateMessage", message); |
82 } | 88 } |
83 | 89 |
84 void UpdateScreenHandler::SetProgress(int progress) { | 90 void UpdateScreenHandler::SetProgress(int progress) { |
85 base::FundamentalValue progress_value(progress); | 91 base::FundamentalValue progress_value(progress); |
86 web_ui()->CallJavascriptFunction("cr.ui.Oobe.setUpdateProgress", | 92 web_ui()->CallJavascriptFunction("cr.ui.Oobe.setUpdateProgress", |
87 progress_value); | 93 progress_value); |
88 } | 94 } |
89 | 95 |
| 96 void UpdateScreenHandler::SetEstimatedTimeLeft(const base::TimeDelta& time) { |
| 97 int64 duration = time.InSeconds(); |
| 98 |
| 99 int seconds = duration % 60; |
| 100 duration /= 60; |
| 101 int minutes = duration % 60; |
| 102 duration /= 60; |
| 103 int hours = duration % 24; |
| 104 duration /= 24; |
| 105 int days = duration; |
| 106 |
| 107 web_ui()->CallJavascriptFunction("cr.ui.Oobe.setUpdateEstimatedTimeLeft", |
| 108 base::FundamentalValue(days), |
| 109 base::FundamentalValue(hours), |
| 110 base::FundamentalValue(minutes), |
| 111 base::FundamentalValue(seconds)); |
| 112 } |
| 113 |
| 114 void UpdateScreenHandler::SetDownloadingRate(double rate) { |
| 115 base::FundamentalValue rate_value(rate); |
| 116 web_ui()->CallJavascriptFunction("cr.ui.Oobe.setUpdateDownloadingRate", |
| 117 rate_value); |
| 118 } |
| 119 |
90 void UpdateScreenHandler::ShowCurtain(bool enable) { | 120 void UpdateScreenHandler::ShowCurtain(bool enable) { |
91 base::FundamentalValue enable_value(enable); | 121 base::FundamentalValue enable_value(enable); |
92 web_ui()->CallJavascriptFunction( | 122 web_ui()->CallJavascriptFunction( |
93 "cr.ui.Oobe.showUpdateCurtain", enable_value); | 123 "cr.ui.Oobe.showUpdateCurtain", enable_value); |
94 } | 124 } |
95 | 125 |
| 126 void UpdateScreenHandler::ShowUpdateDownloadingStats(bool enable) { |
| 127 base::FundamentalValue enable_value(enable); |
| 128 web_ui()->CallJavascriptFunction( |
| 129 "cr.ui.Oobe.showUpdateDownloadingStats", enable_value); |
| 130 } |
| 131 |
96 void UpdateScreenHandler::ShowPreparingUpdatesInfo(bool visible) { | 132 void UpdateScreenHandler::ShowPreparingUpdatesInfo(bool visible) { |
97 scoped_ptr<StringValue> info_message; | 133 scoped_ptr<StringValue> info_message; |
98 if (visible) { | 134 if (visible) { |
99 info_message.reset(Value::CreateStringValue( | 135 info_message.reset(Value::CreateStringValue( |
100 l10n_util::GetStringUTF16(IDS_UPDATE_AVAILABLE))); | 136 l10n_util::GetStringUTF16(IDS_UPDATE_AVAILABLE))); |
101 } else { | 137 } else { |
102 info_message.reset(Value::CreateStringValue( | 138 info_message.reset(Value::CreateStringValue( |
103 l10n_util::GetStringFUTF16(IDS_INSTALLING_UPDATE, | 139 l10n_util::GetStringFUTF16(IDS_INSTALLING_UPDATE, |
104 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)))); | 140 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)))); |
105 } | 141 } |
(...skipping 10 matching lines...) Expand all Loading... |
116 } | 152 } |
117 | 153 |
118 #if !defined(OFFICIAL_BUILD) | 154 #if !defined(OFFICIAL_BUILD) |
119 void UpdateScreenHandler::HandleUpdateCancel(const base::ListValue* args) { | 155 void UpdateScreenHandler::HandleUpdateCancel(const base::ListValue* args) { |
120 DCHECK(args && args->empty()); | 156 DCHECK(args && args->empty()); |
121 screen_->CancelUpdate(); | 157 screen_->CancelUpdate(); |
122 } | 158 } |
123 #endif | 159 #endif |
124 | 160 |
125 } // namespace chromeos | 161 } // namespace chromeos |
OLD | NEW |