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

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