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 const bool res = cus->GetComponentDetails(component_ids[j], &item); |
James Hawkins
2014/06/11 17:50:39
What does 'res' mean? Can we get a better variabl
Sorin Jianu
2014/06/11 21:39:41
Done.
| |
173 if (item) { | 173 if (res) { |
174 base::DictionaryValue* component_entry = new base::DictionaryValue(); | 174 base::DictionaryValue* component_entry = new base::DictionaryValue(); |
175 component_entry->SetString("id", component_ids[j]); | 175 component_entry->SetString("id", component_ids[j]); |
176 component_entry->SetString("name", item->component.name); | 176 component_entry->SetString("name", item.component.name); |
177 component_entry->SetString("version", | 177 component_entry->SetString("version", item.component.version.GetString()); |
178 item->component.version.GetString()); | 178 component_entry->SetString("status", ServiceStatusToString(item.status)); |
179 | |
180 component_entry->SetString("status", | |
181 ServiceStatusToString(item->status)); | |
182 | |
183 component_list->Append(component_entry); | 179 component_list->Append(component_entry); |
184 } | 180 } |
185 } | 181 } |
186 | 182 |
187 return component_list; | 183 return component_list; |
188 } | 184 } |
189 | 185 |
190 // static | 186 // static |
191 base::RefCountedMemory* ComponentsUI::GetFaviconResourceBytes( | 187 base::RefCountedMemory* ComponentsUI::GetFaviconResourceBytes( |
192 ui::ScaleFactor scale_factor) { | 188 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); | 239 return l10n_util::GetStringUTF16(IDS_COMPONENTS_UNKNOWN); |
244 } | 240 } |
245 | 241 |
246 void ComponentsUI::OnEvent(Events event, const std::string& id) { | 242 void ComponentsUI::OnEvent(Events event, const std::string& id) { |
247 base::DictionaryValue parameters; | 243 base::DictionaryValue parameters; |
248 parameters.SetString("event", ComponentEventToString(event)); | 244 parameters.SetString("event", ComponentEventToString(event)); |
249 if (!id.empty()) | 245 if (!id.empty()) |
250 parameters.SetString("id", id); | 246 parameters.SetString("id", id); |
251 web_ui()->CallJavascriptFunction("onComponentEvent", parameters); | 247 web_ui()->CallJavascriptFunction("onComponentEvent", parameters); |
252 } | 248 } |
OLD | NEW |