| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/popular_sites_internals_message_handler.h" | 5 #include "chrome/browser/ui/webui/popular_sites_internals_message_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 11 #include "base/values.h" | 12 #include "base/values.h" |
| 12 #include "chrome/browser/android/popular_sites.h" | 13 #include "chrome/browser/android/popular_sites.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "components/url_formatter/url_fixer.h" | 15 #include "components/url_formatter/url_fixer.h" |
| 15 #include "content/public/browser/web_ui.h" | 16 #include "content/public/browser/web_ui.h" |
| 16 | 17 |
| 17 PopularSitesInternalsMessageHandler::PopularSitesInternalsMessageHandler() { | 18 PopularSitesInternalsMessageHandler::PopularSitesInternalsMessageHandler() { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 web_ui()->CallJavascriptFunction( | 70 web_ui()->CallJavascriptFunction( |
| 70 "chrome.popular_sites_internals.receiveDownloadResult", result); | 71 "chrome.popular_sites_internals.receiveDownloadResult", result); |
| 71 } | 72 } |
| 72 | 73 |
| 73 void PopularSitesInternalsMessageHandler::SendSites() { | 74 void PopularSitesInternalsMessageHandler::SendSites() { |
| 74 scoped_ptr<base::ListValue> sites_list(new base::ListValue); | 75 scoped_ptr<base::ListValue> sites_list(new base::ListValue); |
| 75 for (const PopularSites::Site& site : popular_sites_->sites()) { | 76 for (const PopularSites::Site& site : popular_sites_->sites()) { |
| 76 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); | 77 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
| 77 entry->SetString("title", site.title); | 78 entry->SetString("title", site.title); |
| 78 entry->SetString("url", site.url.spec()); | 79 entry->SetString("url", site.url.spec()); |
| 79 sites_list->Append(entry.Pass()); | 80 sites_list->Append(std::move(entry)); |
| 80 } | 81 } |
| 81 | 82 |
| 82 base::DictionaryValue result; | 83 base::DictionaryValue result; |
| 83 result.Set("sites", sites_list.Pass()); | 84 result.Set("sites", std::move(sites_list)); |
| 84 web_ui()->CallJavascriptFunction( | 85 web_ui()->CallJavascriptFunction( |
| 85 "chrome.popular_sites_internals.receiveSites", result); | 86 "chrome.popular_sites_internals.receiveSites", result); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable( | 89 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable( |
| 89 bool explicit_request, bool success) { | 90 bool explicit_request, bool success) { |
| 90 if (explicit_request) | 91 if (explicit_request) |
| 91 SendDownloadResult(success); | 92 SendDownloadResult(success); |
| 92 SendSites(); | 93 SendSites(); |
| 93 } | 94 } |
| OLD | NEW |