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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 const base::ListValue* args) { | 59 const base::ListValue* args) { |
60 DCHECK(args->empty()); | 60 DCHECK(args->empty()); |
61 | 61 |
62 SendOverrides(); | 62 SendOverrides(); |
63 | 63 |
64 Profile* profile = Profile::FromWebUI(web_ui()); | 64 Profile* profile = Profile::FromWebUI(web_ui()); |
65 popular_sites_.reset(new PopularSites( | 65 popular_sites_.reset(new PopularSites( |
66 content::BrowserThread::GetBlockingPool(), profile->GetPrefs(), | 66 content::BrowserThread::GetBlockingPool(), profile->GetPrefs(), |
67 TemplateURLServiceFactory::GetForProfile(profile), | 67 TemplateURLServiceFactory::GetForProfile(profile), |
68 g_browser_process->variations_service(), profile->GetRequestContext(), | 68 g_browser_process->variations_service(), profile->GetRequestContext(), |
69 ChromePopularSites::GetDirectory(), false, | 69 ChromePopularSites::GetDirectory())); |
| 70 popular_sites_->StartFetch( |
| 71 false, |
70 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, | 72 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, |
71 base::Unretained(this), false))); | 73 base::Unretained(this), false)); |
72 } | 74 } |
73 | 75 |
74 void PopularSitesInternalsMessageHandler::HandleUpdate( | 76 void PopularSitesInternalsMessageHandler::HandleUpdate( |
75 const base::ListValue* args) { | 77 const base::ListValue* args) { |
76 DCHECK_EQ(3u, args->GetSize()); | 78 DCHECK_EQ(3u, args->GetSize()); |
77 Profile* profile = Profile::FromWebUI(web_ui()); | 79 Profile* profile = Profile::FromWebUI(web_ui()); |
78 auto callback = | 80 auto callback = |
79 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, | 81 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, |
80 base::Unretained(this), true); | 82 base::Unretained(this), true); |
81 | 83 |
(...skipping 18 matching lines...) Expand all Loading... |
100 args->GetString(2, &version); | 102 args->GetString(2, &version); |
101 if (version.empty()) | 103 if (version.empty()) |
102 prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideVersion); | 104 prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideVersion); |
103 else | 105 else |
104 prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideVersion, version); | 106 prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideVersion, version); |
105 | 107 |
106 popular_sites_.reset(new PopularSites( | 108 popular_sites_.reset(new PopularSites( |
107 content::BrowserThread::GetBlockingPool(), prefs, | 109 content::BrowserThread::GetBlockingPool(), prefs, |
108 TemplateURLServiceFactory::GetForProfile(profile), | 110 TemplateURLServiceFactory::GetForProfile(profile), |
109 g_browser_process->variations_service(), profile->GetRequestContext(), | 111 g_browser_process->variations_service(), profile->GetRequestContext(), |
110 ChromePopularSites::GetDirectory(), true, callback)); | 112 ChromePopularSites::GetDirectory())); |
| 113 popular_sites_->StartFetch(true, callback); |
111 } | 114 } |
112 | 115 |
113 void PopularSitesInternalsMessageHandler::HandleViewJson( | 116 void PopularSitesInternalsMessageHandler::HandleViewJson( |
114 const base::ListValue* args) { | 117 const base::ListValue* args) { |
115 DCHECK_EQ(0u, args->GetSize()); | 118 DCHECK_EQ(0u, args->GetSize()); |
116 | 119 |
117 const base::FilePath& path = popular_sites_->local_path(); | 120 const base::FilePath& path = popular_sites_->local_path(); |
118 base::PostTaskAndReplyWithResult( | 121 base::PostTaskAndReplyWithResult( |
119 content::BrowserThread::GetBlockingPool() | 122 content::BrowserThread::GetBlockingPool() |
120 ->GetTaskRunnerWithShutdownBehavior( | 123 ->GetTaskRunnerWithShutdownBehavior( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 web_ui()->CallJavascriptFunctionUnsafe( | 167 web_ui()->CallJavascriptFunctionUnsafe( |
165 "chrome.popular_sites_internals.receiveJson", base::StringValue(json)); | 168 "chrome.popular_sites_internals.receiveJson", base::StringValue(json)); |
166 } | 169 } |
167 | 170 |
168 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable( | 171 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable( |
169 bool explicit_request, bool success) { | 172 bool explicit_request, bool success) { |
170 if (explicit_request) | 173 if (explicit_request) |
171 SendDownloadResult(success); | 174 SendDownloadResult(success); |
172 SendSites(); | 175 SendSites(); |
173 } | 176 } |
OLD | NEW |