| OLD | NEW |
| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/weak_ptr.h" |
| 11 #include "base/values.h" | 12 #include "base/values.h" |
| 12 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/component_updater/component_updater_service.h" | 14 #include "chrome/browser/component_updater/component_updater_service.h" |
| 14 #include "chrome/browser/component_updater/crx_update_item.h" | 15 #include "chrome/browser/component_updater/crx_update_item.h" |
| 15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 17 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 19 #include "content/public/browser/web_ui.h" | 20 #include "content/public/browser/web_ui.h" |
| 20 #include "content/public/browser/web_ui_data_source.h" | 21 #include "content/public/browser/web_ui_data_source.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // static | 162 // static |
| 162 base::ListValue* ComponentsUI::LoadComponents() { | 163 base::ListValue* ComponentsUI::LoadComponents() { |
| 163 component_updater::ComponentUpdateService* cus = | 164 component_updater::ComponentUpdateService* cus = |
| 164 g_browser_process->component_updater(); | 165 g_browser_process->component_updater(); |
| 165 std::vector<std::string> component_ids; | 166 std::vector<std::string> component_ids; |
| 166 component_ids = cus->GetComponentIDs(); | 167 component_ids = cus->GetComponentIDs(); |
| 167 | 168 |
| 168 // Construct DictionaryValues to return to UI. | 169 // Construct DictionaryValues to return to UI. |
| 169 base::ListValue* component_list = new base::ListValue(); | 170 base::ListValue* component_list = new base::ListValue(); |
| 170 for (size_t j = 0; j < component_ids.size(); ++j) { | 171 for (size_t j = 0; j < component_ids.size(); ++j) { |
| 171 const component_updater::CrxUpdateItem* item = | 172 const base::WeakPtr<component_updater::CrxUpdateItem> item = |
| 172 cus->GetComponentDetails(component_ids[j]); | 173 cus->GetComponentDetails(component_ids[j]); |
| 173 if (item) { | 174 if (item) { |
| 174 base::DictionaryValue* component_entry = new base::DictionaryValue(); | 175 base::DictionaryValue* component_entry = new base::DictionaryValue(); |
| 175 component_entry->SetString("id", component_ids[j]); | 176 component_entry->SetString("id", component_ids[j]); |
| 176 component_entry->SetString("name", item->component.name); | 177 component_entry->SetString("name", item->component.name); |
| 177 component_entry->SetString("version", | 178 component_entry->SetString("version", |
| 178 item->component.version.GetString()); | 179 item->component.version.GetString()); |
| 179 | 180 |
| 180 component_entry->SetString("status", | 181 component_entry->SetString("status", |
| 181 ServiceStatusToString(item->status)); | 182 ServiceStatusToString(item->status)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 return l10n_util::GetStringUTF16(IDS_COMPONENTS_UNKNOWN); | 244 return l10n_util::GetStringUTF16(IDS_COMPONENTS_UNKNOWN); |
| 244 } | 245 } |
| 245 | 246 |
| 246 void ComponentsUI::OnEvent(Events event, const std::string& id) { | 247 void ComponentsUI::OnEvent(Events event, const std::string& id) { |
| 247 base::DictionaryValue parameters; | 248 base::DictionaryValue parameters; |
| 248 parameters.SetString("event", ComponentEventToString(event)); | 249 parameters.SetString("event", ComponentEventToString(event)); |
| 249 if (!id.empty()) | 250 if (!id.empty()) |
| 250 parameters.SetString("id", id); | 251 parameters.SetString("id", id); |
| 251 web_ui()->CallJavascriptFunction("onComponentEvent", parameters); | 252 web_ui()->CallJavascriptFunction("onComponentEvent", parameters); |
| 252 } | 253 } |
| OLD | NEW |