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

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

Issue 2058233002: Rewrite simple uses of base::ListValue::Append() taking a raw pointer var. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: less comments more ownership Created 4 years, 6 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 <string> 11 #include <string>
12 #include <utility>
11 #include <vector> 13 #include <vector>
12 14
13 #include "base/macros.h" 15 #include "base/macros.h"
14 #include "base/values.h" 16 #include "base/values.h"
15 #include "build/build_config.h" 17 #include "build/build_config.h"
16 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_window.h" 20 #include "chrome/browser/ui/browser_window.h"
19 #include "chrome/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 component_updater::ComponentUpdateService* cus = 167 component_updater::ComponentUpdateService* cus =
166 g_browser_process->component_updater(); 168 g_browser_process->component_updater();
167 std::vector<std::string> component_ids; 169 std::vector<std::string> component_ids;
168 component_ids = cus->GetComponentIDs(); 170 component_ids = cus->GetComponentIDs();
169 171
170 // Construct DictionaryValues to return to UI. 172 // Construct DictionaryValues to return to UI.
171 base::ListValue* component_list = new base::ListValue(); 173 base::ListValue* component_list = new base::ListValue();
172 for (size_t j = 0; j < component_ids.size(); ++j) { 174 for (size_t j = 0; j < component_ids.size(); ++j) {
173 update_client::CrxUpdateItem item; 175 update_client::CrxUpdateItem item;
174 if (cus->GetComponentDetails(component_ids[j], &item)) { 176 if (cus->GetComponentDetails(component_ids[j], &item)) {
175 base::DictionaryValue* component_entry = new base::DictionaryValue(); 177 std::unique_ptr<base::DictionaryValue> component_entry(
178 new base::DictionaryValue());
176 component_entry->SetString("id", component_ids[j]); 179 component_entry->SetString("id", component_ids[j]);
177 component_entry->SetString("name", item.component.name); 180 component_entry->SetString("name", item.component.name);
178 component_entry->SetString("version", item.component.version.GetString()); 181 component_entry->SetString("version", item.component.version.GetString());
179 component_entry->SetString("status", ServiceStatusToString(item.state)); 182 component_entry->SetString("status", ServiceStatusToString(item.state));
180 component_list->Append(component_entry); 183 component_list->Append(std::move(component_entry));
181 } 184 }
182 } 185 }
183 186
184 return component_list; 187 return component_list;
185 } 188 }
186 189
187 // static 190 // static
188 base::RefCountedMemory* ComponentsUI::GetFaviconResourceBytes( 191 base::RefCountedMemory* ComponentsUI::GetFaviconResourceBytes(
189 ui::ScaleFactor scale_factor) { 192 ui::ScaleFactor scale_factor) {
190 return ResourceBundle::GetSharedInstance(). 193 return ResourceBundle::GetSharedInstance().
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 if (event == Events::COMPONENT_UPDATED) { 254 if (event == Events::COMPONENT_UPDATED) {
252 auto cus = g_browser_process->component_updater(); 255 auto cus = g_browser_process->component_updater();
253 update_client::CrxUpdateItem item; 256 update_client::CrxUpdateItem item;
254 if (cus->GetComponentDetails(id, &item)) 257 if (cus->GetComponentDetails(id, &item))
255 parameters.SetString("version", item.component.version.GetString()); 258 parameters.SetString("version", item.component.version.GetString());
256 } 259 }
257 parameters.SetString("id", id); 260 parameters.SetString("id", id);
258 } 261 }
259 web_ui()->CallJavascriptFunctionUnsafe("onComponentEvent", parameters); 262 web_ui()->CallJavascriptFunctionUnsafe("onComponentEvent", parameters);
260 } 263 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/certificate_viewer_webui.cc ('k') | chrome/browser/ui/webui/cookies_tree_model_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698