| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 54 } |
| 55 | 55 |
| 56 void PopularSitesInternalsMessageHandler::HandleRegisterForEvents( | 56 void PopularSitesInternalsMessageHandler::HandleRegisterForEvents( |
| 57 const base::ListValue* args) { | 57 const base::ListValue* args) { |
| 58 DCHECK(args->empty()); | 58 DCHECK(args->empty()); |
| 59 | 59 |
| 60 SendOverrides(); | 60 SendOverrides(); |
| 61 | 61 |
| 62 Profile* profile = Profile::FromWebUI(web_ui()); | 62 Profile* profile = Profile::FromWebUI(web_ui()); |
| 63 popular_sites_.reset(new PopularSites( | 63 popular_sites_.reset(new PopularSites( |
| 64 profile->GetPrefs(), TemplateURLServiceFactory::GetForProfile(profile), | 64 content::BrowserThread::GetBlockingPool(), profile->GetPrefs(), |
| 65 TemplateURLServiceFactory::GetForProfile(profile), |
| 65 g_browser_process->variations_service(), profile->GetRequestContext(), | 66 g_browser_process->variations_service(), profile->GetRequestContext(), |
| 66 ChromePopularSites::GetDirectory(), std::string(), std::string(), | 67 ChromePopularSites::GetDirectory(), std::string(), std::string(), false, |
| 67 false, | |
| 68 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, | 68 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, |
| 69 base::Unretained(this), false))); | 69 base::Unretained(this), false))); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void PopularSitesInternalsMessageHandler::HandleUpdate( | 72 void PopularSitesInternalsMessageHandler::HandleUpdate( |
| 73 const base::ListValue* args) { | 73 const base::ListValue* args) { |
| 74 DCHECK_EQ(3u, args->GetSize()); | 74 DCHECK_EQ(3u, args->GetSize()); |
| 75 Profile* profile = Profile::FromWebUI(web_ui()); | 75 Profile* profile = Profile::FromWebUI(web_ui()); |
| 76 auto callback = | 76 auto callback = |
| 77 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, | 77 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 90 args->GetString(2, &version); | 90 args->GetString(2, &version); |
| 91 if (version.empty()) | 91 if (version.empty()) |
| 92 prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideVersion); | 92 prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideVersion); |
| 93 else | 93 else |
| 94 prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideVersion, version); | 94 prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideVersion, version); |
| 95 | 95 |
| 96 std::string url; | 96 std::string url; |
| 97 args->GetString(0, &url); | 97 args->GetString(0, &url); |
| 98 if (!url.empty()) { | 98 if (!url.empty()) { |
| 99 popular_sites_.reset(new PopularSites( | 99 popular_sites_.reset(new PopularSites( |
| 100 prefs, profile->GetRequestContext(), ChromePopularSites::GetDirectory(), | 100 content::BrowserThread::GetBlockingPool(), prefs, |
| 101 profile->GetRequestContext(), ChromePopularSites::GetDirectory(), |
| 101 url_formatter::FixupURL(url, std::string()), callback)); | 102 url_formatter::FixupURL(url, std::string()), callback)); |
| 102 return; | 103 return; |
| 103 } | 104 } |
| 104 | 105 |
| 105 popular_sites_.reset(new PopularSites( | 106 popular_sites_.reset(new PopularSites( |
| 106 prefs, TemplateURLServiceFactory::GetForProfile(profile), | 107 content::BrowserThread::GetBlockingPool(), prefs, |
| 108 TemplateURLServiceFactory::GetForProfile(profile), |
| 107 g_browser_process->variations_service(), profile->GetRequestContext(), | 109 g_browser_process->variations_service(), profile->GetRequestContext(), |
| 108 ChromePopularSites::GetDirectory(), std::string(), std::string(), true, | 110 ChromePopularSites::GetDirectory(), std::string(), std::string(), true, |
| 109 callback)); | 111 callback)); |
| 110 } | 112 } |
| 111 | 113 |
| 112 void PopularSitesInternalsMessageHandler::HandleViewJson( | 114 void PopularSitesInternalsMessageHandler::HandleViewJson( |
| 113 const base::ListValue* args) { | 115 const base::ListValue* args) { |
| 114 DCHECK_EQ(0u, args->GetSize()); | 116 DCHECK_EQ(0u, args->GetSize()); |
| 115 | 117 |
| 116 const base::FilePath& path = popular_sites_->local_path(); | 118 const base::FilePath& path = popular_sites_->local_path(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 web_ui()->CallJavascriptFunction("chrome.popular_sites_internals.receiveJson", | 164 web_ui()->CallJavascriptFunction("chrome.popular_sites_internals.receiveJson", |
| 163 base::StringValue(json)); | 165 base::StringValue(json)); |
| 164 } | 166 } |
| 165 | 167 |
| 166 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable( | 168 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable( |
| 167 bool explicit_request, bool success) { | 169 bool explicit_request, bool success) { |
| 168 if (explicit_request) | 170 if (explicit_request) |
| 169 SendDownloadResult(success); | 171 SendDownloadResult(success); |
| 170 SendSites(); | 172 SendSites(); |
| 171 } | 173 } |
| OLD | NEW |