| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/history/top_sites_extension_api.h" | 5 #include "chrome/browser/history/top_sites_extension_api.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/history/top_sites.h" | 9 #include "chrome/browser/history/top_sites.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 return false; | 22 return false; |
| 23 | 23 |
| 24 ts->GetMostVisitedURLs( | 24 ts->GetMostVisitedURLs( |
| 25 &topsites_consumer_, | 25 &topsites_consumer_, |
| 26 base::Bind(&GetTopSitesFunction::OnMostVisitedURLsAvailable, this)); | 26 base::Bind(&GetTopSitesFunction::OnMostVisitedURLsAvailable, this)); |
| 27 return true; | 27 return true; |
| 28 } | 28 } |
| 29 | 29 |
| 30 void GetTopSitesFunction::OnMostVisitedURLsAvailable( | 30 void GetTopSitesFunction::OnMostVisitedURLsAvailable( |
| 31 const history::MostVisitedURLList& data) { | 31 const history::MostVisitedURLList& data) { |
| 32 // Code is a direct rip from most_visited_handler.cc TODO(estade): unfork. | |
| 33 scoped_ptr<base::ListValue> pages_value(new ListValue); | 32 scoped_ptr<base::ListValue> pages_value(new ListValue); |
| 34 for (size_t i = 0; i < data.size(); i++) { | 33 for (size_t i = 0; i < data.size(); i++) { |
| 35 const history::MostVisitedURL& url = data[i]; | 34 const history::MostVisitedURL& url = data[i]; |
| 36 DictionaryValue* page_value = new DictionaryValue(); | 35 DictionaryValue* page_value = new DictionaryValue(); |
| 37 if (url.url.is_empty()) { | 36 if (!url.url.is_empty()) { |
| 38 page_value->SetBoolean("filler", true); | 37 page_value->SetString("url", url.url.spec()); |
| 38 if (url.title.empty()) |
| 39 page_value->SetString("title", url.url.spec()); |
| 40 else |
| 41 page_value->SetString("title", url.title); |
| 39 pages_value->Append(page_value); | 42 pages_value->Append(page_value); |
| 40 continue; | |
| 41 } | 43 } |
| 42 | |
| 43 NewTabUI::SetURLTitleAndDirection(page_value, | |
| 44 url.title, | |
| 45 url.url); | |
| 46 | |
| 47 pages_value->Append(page_value); | |
| 48 } | 44 } |
| 49 // End copied code. ---------------------------------------------------------- | |
| 50 | 45 |
| 51 result_.reset(pages_value.release()); | 46 result_.reset(pages_value.release()); |
| 52 SendResponse(true); | 47 SendResponse(true); |
| 53 } | 48 } |
| OLD | NEW |