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

Side by Side Diff: chrome/browser/extensions/api/top_sites/top_sites_api.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/api/top_sites/top_sites_api.h" 5 #include "chrome/browser/extensions/api/top_sites/top_sites_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory>
9 #include <utility> 10 #include <utility>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/browser/history/top_sites_factory.h" 14 #include "chrome/browser/history/top_sites_factory.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 16 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
16 #include "components/history/core/browser/top_sites.h" 17 #include "components/history/core/browser/top_sites.h"
17 18
18 namespace extensions { 19 namespace extensions {
(...skipping 14 matching lines...) Expand all
33 weak_ptr_factory_.GetWeakPtr()), false); 34 weak_ptr_factory_.GetWeakPtr()), false);
34 return true; 35 return true;
35 } 36 }
36 37
37 void TopSitesGetFunction::OnMostVisitedURLsAvailable( 38 void TopSitesGetFunction::OnMostVisitedURLsAvailable(
38 const history::MostVisitedURLList& data) { 39 const history::MostVisitedURLList& data) {
39 std::unique_ptr<base::ListValue> pages_value(new base::ListValue); 40 std::unique_ptr<base::ListValue> pages_value(new base::ListValue);
40 for (size_t i = 0; i < data.size(); i++) { 41 for (size_t i = 0; i < data.size(); i++) {
41 const history::MostVisitedURL& url = data[i]; 42 const history::MostVisitedURL& url = data[i];
42 if (!url.url.is_empty()) { 43 if (!url.url.is_empty()) {
43 base::DictionaryValue* page_value = new base::DictionaryValue(); 44 std::unique_ptr<base::DictionaryValue> page_value(
45 new base::DictionaryValue());
44 page_value->SetString("url", url.url.spec()); 46 page_value->SetString("url", url.url.spec());
45 if (url.title.empty()) 47 if (url.title.empty())
46 page_value->SetString("title", url.url.spec()); 48 page_value->SetString("title", url.url.spec());
47 else 49 else
48 page_value->SetString("title", url.title); 50 page_value->SetString("title", url.title);
49 pages_value->Append(page_value); 51 pages_value->Append(std::move(page_value));
50 } 52 }
51 } 53 }
52 54
53 SetResult(std::move(pages_value)); 55 SetResult(std::move(pages_value));
54 SendResponse(true); 56 SendResponse(true);
55 } 57 }
56 58
57 } // namespace extensions 59 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698