| 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::GetMessageLoopProxyForThread( |
| 65 content::BrowserThread::UI), |
| 66 content::BrowserThread::GetBlockingPool(), profile->GetPrefs(), |
| 67 TemplateURLServiceFactory::GetForProfile(profile), |
| 65 g_browser_process->variations_service(), profile->GetRequestContext(), | 68 g_browser_process->variations_service(), profile->GetRequestContext(), |
| 66 ChromePopularSites::GetDirectory(), std::string(), std::string(), | 69 ChromePopularSites::GetDirectory(), std::string(), std::string(), false, |
| 67 false, | |
| 68 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, | 70 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, |
| 69 base::Unretained(this), false))); | 71 base::Unretained(this), false))); |
| 70 } | 72 } |
| 71 | 73 |
| 72 void PopularSitesInternalsMessageHandler::HandleUpdate( | 74 void PopularSitesInternalsMessageHandler::HandleUpdate( |
| 73 const base::ListValue* args) { | 75 const base::ListValue* args) { |
| 74 DCHECK_EQ(3u, args->GetSize()); | 76 DCHECK_EQ(3u, args->GetSize()); |
| 75 Profile* profile = Profile::FromWebUI(web_ui()); | 77 Profile* profile = Profile::FromWebUI(web_ui()); |
| 76 auto callback = | 78 auto callback = |
| 77 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, | 79 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 90 args->GetString(2, &version); | 92 args->GetString(2, &version); |
| 91 if (version.empty()) | 93 if (version.empty()) |
| 92 prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideVersion); | 94 prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideVersion); |
| 93 else | 95 else |
| 94 prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideVersion, version); | 96 prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideVersion, version); |
| 95 | 97 |
| 96 std::string url; | 98 std::string url; |
| 97 args->GetString(0, &url); | 99 args->GetString(0, &url); |
| 98 if (!url.empty()) { | 100 if (!url.empty()) { |
| 99 popular_sites_.reset(new PopularSites( | 101 popular_sites_.reset(new PopularSites( |
| 100 prefs, profile->GetRequestContext(), ChromePopularSites::GetDirectory(), | 102 content::BrowserThread::GetMessageLoopProxyForThread( |
| 103 content::BrowserThread::UI), |
| 104 content::BrowserThread::GetBlockingPool(), prefs, |
| 105 profile->GetRequestContext(), ChromePopularSites::GetDirectory(), |
| 101 url_formatter::FixupURL(url, std::string()), callback)); | 106 url_formatter::FixupURL(url, std::string()), callback)); |
| 102 return; | 107 return; |
| 103 } | 108 } |
| 104 | 109 |
| 105 popular_sites_.reset(new PopularSites( | 110 popular_sites_.reset(new PopularSites( |
| 106 prefs, TemplateURLServiceFactory::GetForProfile(profile), | 111 content::BrowserThread::GetMessageLoopProxyForThread( |
| 112 content::BrowserThread::UI), |
| 113 content::BrowserThread::GetBlockingPool(), prefs, |
| 114 TemplateURLServiceFactory::GetForProfile(profile), |
| 107 g_browser_process->variations_service(), profile->GetRequestContext(), | 115 g_browser_process->variations_service(), profile->GetRequestContext(), |
| 108 ChromePopularSites::GetDirectory(), std::string(), std::string(), true, | 116 ChromePopularSites::GetDirectory(), std::string(), std::string(), true, |
| 109 callback)); | 117 callback)); |
| 110 } | 118 } |
| 111 | 119 |
| 112 void PopularSitesInternalsMessageHandler::HandleViewJson( | 120 void PopularSitesInternalsMessageHandler::HandleViewJson( |
| 113 const base::ListValue* args) { | 121 const base::ListValue* args) { |
| 114 DCHECK_EQ(0u, args->GetSize()); | 122 DCHECK_EQ(0u, args->GetSize()); |
| 115 | 123 |
| 116 const base::FilePath& path = popular_sites_->local_path(); | 124 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", | 170 web_ui()->CallJavascriptFunction("chrome.popular_sites_internals.receiveJson", |
| 163 base::StringValue(json)); | 171 base::StringValue(json)); |
| 164 } | 172 } |
| 165 | 173 |
| 166 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable( | 174 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable( |
| 167 bool explicit_request, bool success) { | 175 bool explicit_request, bool success) { |
| 168 if (explicit_request) | 176 if (explicit_request) |
| 169 SendDownloadResult(success); | 177 SendDownloadResult(success); |
| 170 SendSites(); | 178 SendSites(); |
| 171 } | 179 } |
| OLD | NEW |