Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/browser/ui/webui/components_ui.cc

Issue 2835803002: Refactor the UpdateEngine and its actions in the component updater. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/components_ui.h" 5 #include "chrome/browser/ui/webui/components_ui.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/ui/browser_window.h" 20 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
22 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
23 #include "chrome/grit/browser_resources.h" 23 #include "chrome/grit/browser_resources.h"
24 #include "chrome/grit/generated_resources.h" 24 #include "chrome/grit/generated_resources.h"
25 #include "chrome/grit/theme_resources.h" 25 #include "chrome/grit/theme_resources.h"
26 #include "components/component_updater/component_updater_service.h" 26 #include "components/update_client/crx_update_item.h"
27 #include "content/public/browser/web_ui.h" 27 #include "content/public/browser/web_ui.h"
28 #include "content/public/browser/web_ui_data_source.h" 28 #include "content/public/browser/web_ui_data_source.h"
29 #include "content/public/browser/web_ui_message_handler.h" 29 #include "content/public/browser/web_ui_message_handler.h"
30 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
31 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
32 32
33 #if defined(OS_CHROMEOS) 33 #if defined(OS_CHROMEOS)
34 #include "chrome/browser/ui/webui/chromeos/ui_account_tweaks.h" 34 #include "chrome/browser/ui/webui/chromeos/ui_account_tweaks.h"
35 #endif 35 #endif
36 36
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 return l10n_util::GetStringUTF16(IDS_COMPONENTS_EVT_STATUS_UPDATED); 208 return l10n_util::GetStringUTF16(IDS_COMPONENTS_EVT_STATUS_UPDATED);
209 case Events::COMPONENT_NOT_UPDATED: 209 case Events::COMPONENT_NOT_UPDATED:
210 return l10n_util::GetStringUTF16(IDS_COMPONENTS_EVT_STATUS_NOTUPDATED); 210 return l10n_util::GetStringUTF16(IDS_COMPONENTS_EVT_STATUS_NOTUPDATED);
211 case Events::COMPONENT_UPDATE_DOWNLOADING: 211 case Events::COMPONENT_UPDATE_DOWNLOADING:
212 return l10n_util::GetStringUTF16(IDS_COMPONENTS_EVT_STATUS_DOWNLOADING); 212 return l10n_util::GetStringUTF16(IDS_COMPONENTS_EVT_STATUS_DOWNLOADING);
213 } 213 }
214 return l10n_util::GetStringUTF16(IDS_COMPONENTS_UNKNOWN); 214 return l10n_util::GetStringUTF16(IDS_COMPONENTS_UNKNOWN);
215 } 215 }
216 216
217 base::string16 ComponentsUI::ServiceStatusToString( 217 base::string16 ComponentsUI::ServiceStatusToString(
218 update_client::CrxUpdateItem::State state) { 218 update_client::ComponentState state) {
219 // TODO(sorin): handle kDownloaded. For now, just handle it as kUpdating. 219 // TODO(sorin): handle kDownloaded. For now, just handle it as kUpdating.
220 switch (state) { 220 switch (state) {
221 case update_client::CrxUpdateItem::State::kNew: 221 case update_client::ComponentState::kNew:
222 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_NEW); 222 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_NEW);
223 case update_client::CrxUpdateItem::State::kChecking: 223 case update_client::ComponentState::kChecking:
224 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_CHECKING); 224 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_CHECKING);
225 case update_client::CrxUpdateItem::State::kCanUpdate: 225 case update_client::ComponentState::kCanUpdate:
226 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_UPDATE); 226 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_UPDATE);
227 case update_client::CrxUpdateItem::State::kDownloadingDiff: 227 case update_client::ComponentState::kDownloadingDiff:
228 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_DNL_DIFF); 228 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_DNL_DIFF);
229 case update_client::CrxUpdateItem::State::kDownloading: 229 case update_client::ComponentState::kDownloading:
230 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_DNL); 230 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_DNL);
231 case update_client::CrxUpdateItem::State::kUpdatingDiff: 231 case update_client::ComponentState::kUpdatingDiff:
232 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_UPDT_DIFF); 232 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_UPDT_DIFF);
233 case update_client::CrxUpdateItem::State::kUpdating: 233 case update_client::ComponentState::kUpdating:
234 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_UPDATING); 234 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_UPDATING);
235 case update_client::CrxUpdateItem::State::kDownloaded: 235 case update_client::ComponentState::kDownloaded:
236 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_DOWNLOADED); 236 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_DOWNLOADED);
237 case update_client::CrxUpdateItem::State::kUpdated: 237 case update_client::ComponentState::kUpdated:
238 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_UPDATED); 238 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_UPDATED);
239 case update_client::CrxUpdateItem::State::kUpToDate: 239 case update_client::ComponentState::kUpToDate:
240 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_UPTODATE); 240 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_UPTODATE);
241 case update_client::CrxUpdateItem::State::kNoUpdate: 241 case update_client::ComponentState::kUpdateError:
242 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_NOUPDATE); 242 return l10n_util::GetStringUTF16(IDS_COMPONENTS_SVC_STATUS_NOUPDATE);
243 case update_client::CrxUpdateItem::State::kUninstalled: // Fall through. 243 case update_client::ComponentState::kUninstalled: // Fall through.
244 case update_client::CrxUpdateItem::State::kLastStatus: 244 case update_client::ComponentState::kLastStatus:
245 return l10n_util::GetStringUTF16(IDS_COMPONENTS_UNKNOWN); 245 return l10n_util::GetStringUTF16(IDS_COMPONENTS_UNKNOWN);
246 } 246 }
247 return l10n_util::GetStringUTF16(IDS_COMPONENTS_UNKNOWN); 247 return l10n_util::GetStringUTF16(IDS_COMPONENTS_UNKNOWN);
248 } 248 }
249 249
250 void ComponentsUI::OnEvent(Events event, const std::string& id) { 250 void ComponentsUI::OnEvent(Events event, const std::string& id) {
251 base::DictionaryValue parameters; 251 base::DictionaryValue parameters;
252 parameters.SetString("event", ComponentEventToString(event)); 252 parameters.SetString("event", ComponentEventToString(event));
253 if (!id.empty()) { 253 if (!id.empty()) {
254 if (event == Events::COMPONENT_UPDATED) { 254 if (event == Events::COMPONENT_UPDATED) {
255 auto* component_updater = g_browser_process->component_updater(); 255 auto* component_updater = g_browser_process->component_updater();
256 update_client::CrxUpdateItem item; 256 update_client::CrxUpdateItem item;
257 if (component_updater->GetComponentDetails(id, &item)) 257 if (component_updater->GetComponentDetails(id, &item))
258 parameters.SetString("version", item.component.version.GetString()); 258 parameters.SetString("version", item.component.version.GetString());
259 } 259 }
260 parameters.SetString("id", id); 260 parameters.SetString("id", id);
261 } 261 }
262 web_ui()->CallJavascriptFunctionUnsafe("onComponentEvent", parameters); 262 web_ui()->CallJavascriptFunctionUnsafe("onComponentEvent", parameters);
263 } 263 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698