Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: chrome/browser/ui/webui/popular_sites_internals_message_handler.cc

Issue 1957313003: Remove PopularSites' dependencies on //chrome/.... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/android/ntp/popular_sites.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(), 64 profile->GetPrefs(), TemplateURLServiceFactory::GetForProfile(profile),
65 TemplateURLServiceFactory::GetForProfile(profile), 65 g_browser_process->variations_service(), profile->GetRequestContext(),
66 g_browser_process->variations_service(), 66 ChromePopularSites::GetDirectory(), std::string(), std::string(),
67 profile->GetRequestContext(), 67 false,
68 std::string(), std::string(), false,
69 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, 68 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable,
70 base::Unretained(this), false))); 69 base::Unretained(this), false)));
71 } 70 }
72 71
73 void PopularSitesInternalsMessageHandler::HandleUpdate( 72 void PopularSitesInternalsMessageHandler::HandleUpdate(
74 const base::ListValue* args) { 73 const base::ListValue* args) {
75 DCHECK_EQ(3u, args->GetSize()); 74 DCHECK_EQ(3u, args->GetSize());
76 Profile* profile = Profile::FromWebUI(web_ui()); 75 Profile* profile = Profile::FromWebUI(web_ui());
77 auto callback = 76 auto callback =
78 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable, 77 base::Bind(&PopularSitesInternalsMessageHandler::OnPopularSitesAvailable,
(...skipping 12 matching lines...) Expand all
91 args->GetString(2, &version); 90 args->GetString(2, &version);
92 if (version.empty()) 91 if (version.empty())
93 prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideVersion); 92 prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideVersion);
94 else 93 else
95 prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideVersion, version); 94 prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideVersion, version);
96 95
97 std::string url; 96 std::string url;
98 args->GetString(0, &url); 97 args->GetString(0, &url);
99 if (!url.empty()) { 98 if (!url.empty()) {
100 popular_sites_.reset(new PopularSites( 99 popular_sites_.reset(new PopularSites(
101 profile->GetPrefs(), 100 prefs, TemplateURLServiceFactory::GetForProfile(profile),
102 TemplateURLServiceFactory::GetForProfile(profile), 101 profile->GetRequestContext(), ChromePopularSites::GetDirectory(),
103 profile->GetRequestContext(),
104 url_formatter::FixupURL(url, std::string()), callback)); 102 url_formatter::FixupURL(url, std::string()), callback));
105 return; 103 return;
106 } 104 }
107 105
108 popular_sites_.reset(new PopularSites( 106 popular_sites_.reset(new PopularSites(
109 profile->GetPrefs(), 107 prefs, TemplateURLServiceFactory::GetForProfile(profile),
110 TemplateURLServiceFactory::GetForProfile(profile), 108 g_browser_process->variations_service(), profile->GetRequestContext(),
111 g_browser_process->variations_service(), 109 ChromePopularSites::GetDirectory(), std::string(), std::string(), true,
112 profile->GetRequestContext(), 110 callback));
113 std::string(), std::string(), true, callback));
114 } 111 }
115 112
116 void PopularSitesInternalsMessageHandler::HandleViewJson( 113 void PopularSitesInternalsMessageHandler::HandleViewJson(
117 const base::ListValue* args) { 114 const base::ListValue* args) {
118 DCHECK_EQ(0u, args->GetSize()); 115 DCHECK_EQ(0u, args->GetSize());
119 116
120 const base::FilePath& path = popular_sites_->local_path(); 117 const base::FilePath& path = popular_sites_->local_path();
121 base::PostTaskAndReplyWithResult( 118 base::PostTaskAndReplyWithResult(
122 content::BrowserThread::GetBlockingPool() 119 content::BrowserThread::GetBlockingPool()
123 ->GetTaskRunnerWithShutdownBehavior( 120 ->GetTaskRunnerWithShutdownBehavior(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 web_ui()->CallJavascriptFunction("chrome.popular_sites_internals.receiveJson", 163 web_ui()->CallJavascriptFunction("chrome.popular_sites_internals.receiveJson",
167 base::StringValue(json)); 164 base::StringValue(json));
168 } 165 }
169 166
170 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable( 167 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable(
171 bool explicit_request, bool success) { 168 bool explicit_request, bool success) {
172 if (explicit_request) 169 if (explicit_request)
173 SendDownloadResult(success); 170 SendDownloadResult(success);
174 SendSites(); 171 SendSites();
175 } 172 }
OLDNEW
« no previous file with comments | « chrome/browser/android/ntp/popular_sites.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698