OLD | NEW |
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 "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 return false; | 27 return false; |
28 | 28 |
29 ts->GetMostVisitedURLs( | 29 ts->GetMostVisitedURLs( |
30 base::Bind(&TopSitesGetFunction::OnMostVisitedURLsAvailable, | 30 base::Bind(&TopSitesGetFunction::OnMostVisitedURLsAvailable, |
31 weak_ptr_factory_.GetWeakPtr()), false); | 31 weak_ptr_factory_.GetWeakPtr()), false); |
32 return true; | 32 return true; |
33 } | 33 } |
34 | 34 |
35 void TopSitesGetFunction::OnMostVisitedURLsAvailable( | 35 void TopSitesGetFunction::OnMostVisitedURLsAvailable( |
36 const history::MostVisitedURLList& data) { | 36 const history::MostVisitedURLList& data) { |
37 scoped_ptr<base::ListValue> pages_value(new base::ListValue); | 37 std::unique_ptr<base::ListValue> pages_value(new base::ListValue); |
38 for (size_t i = 0; i < data.size(); i++) { | 38 for (size_t i = 0; i < data.size(); i++) { |
39 const history::MostVisitedURL& url = data[i]; | 39 const history::MostVisitedURL& url = data[i]; |
40 if (!url.url.is_empty()) { | 40 if (!url.url.is_empty()) { |
41 base::DictionaryValue* page_value = new base::DictionaryValue(); | 41 base::DictionaryValue* page_value = new base::DictionaryValue(); |
42 page_value->SetString("url", url.url.spec()); | 42 page_value->SetString("url", url.url.spec()); |
43 if (url.title.empty()) | 43 if (url.title.empty()) |
44 page_value->SetString("title", url.url.spec()); | 44 page_value->SetString("title", url.url.spec()); |
45 else | 45 else |
46 page_value->SetString("title", url.title); | 46 page_value->SetString("title", url.title); |
47 pages_value->Append(page_value); | 47 pages_value->Append(page_value); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 SetResult(pages_value.release()); | 51 SetResult(pages_value.release()); |
52 SendResponse(true); | 52 SendResponse(true); |
53 } | 53 } |
54 | 54 |
55 } // namespace extensions | 55 } // namespace extensions |
OLD | NEW |