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 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // static | 161 // static |
162 base::ListValue* ComponentsUI::LoadComponents() { | 162 base::ListValue* ComponentsUI::LoadComponents() { |
163 component_updater::ComponentUpdateService* cus = | 163 component_updater::ComponentUpdateService* cus = |
164 g_browser_process->component_updater(); | 164 g_browser_process->component_updater(); |
165 std::vector<std::string> component_ids; | 165 std::vector<std::string> component_ids; |
166 component_ids = cus->GetComponentIDs(); | 166 component_ids = cus->GetComponentIDs(); |
167 | 167 |
168 // Construct DictionaryValues to return to UI. | 168 // Construct DictionaryValues to return to UI. |
169 base::ListValue* component_list = new base::ListValue(); | 169 base::ListValue* component_list = new base::ListValue(); |
170 for (size_t j = 0; j < component_ids.size(); ++j) { | 170 for (size_t j = 0; j < component_ids.size(); ++j) { |
171 const component_updater::CrxUpdateItem* item = | 171 component_updater::CrxUpdateItem item; |
172 cus->GetComponentDetails(component_ids[j]); | 172 if (cus->GetComponentDetails(component_ids[j], &item)) { |
173 if (item) { | |
174 base::DictionaryValue* component_entry = new base::DictionaryValue(); | 173 base::DictionaryValue* component_entry = new base::DictionaryValue(); |
175 component_entry->SetString("id", component_ids[j]); | 174 component_entry->SetString("id", component_ids[j]); |
176 component_entry->SetString("name", item->component.name); | 175 component_entry->SetString("name", item.component.name); |
177 component_entry->SetString("version", | 176 component_entry->SetString("version", item.component.version.GetString()); |
178 item->component.version.GetString()); | 177 component_entry->SetString("status", ServiceStatusToString(item.status)); |
179 | |
180 component_entry->SetString("status", | |
181 ServiceStatusToString(item->status)); | |
182 | |
183 component_list->Append(component_entry); | 178 component_list->Append(component_entry); |
184 } | 179 } |
185 } | 180 } |
186 | 181 |
187 return component_list; | 182 return component_list; |
188 } | 183 } |
189 | 184 |
190 // static | 185 // static |
191 base::RefCountedMemory* ComponentsUI::GetFaviconResourceBytes( | 186 base::RefCountedMemory* ComponentsUI::GetFaviconResourceBytes( |
192 ui::ScaleFactor scale_factor) { | 187 ui::ScaleFactor scale_factor) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 return l10n_util::GetStringUTF16(IDS_COMPONENTS_UNKNOWN); | 238 return l10n_util::GetStringUTF16(IDS_COMPONENTS_UNKNOWN); |
244 } | 239 } |
245 | 240 |
246 void ComponentsUI::OnEvent(Events event, const std::string& id) { | 241 void ComponentsUI::OnEvent(Events event, const std::string& id) { |
247 base::DictionaryValue parameters; | 242 base::DictionaryValue parameters; |
248 parameters.SetString("event", ComponentEventToString(event)); | 243 parameters.SetString("event", ComponentEventToString(event)); |
249 if (!id.empty()) | 244 if (!id.empty()) |
250 parameters.SetString("id", id); | 245 parameters.SetString("id", id); |
251 web_ui()->CallJavascriptFunction("onComponentEvent", parameters); | 246 web_ui()->CallJavascriptFunction("onComponentEvent", parameters); |
252 } | 247 } |
OLD | NEW |