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

Side by Side Diff: components/ntp_tiles/popular_sites.cc

Issue 1983063002: Move classes to //components/ntp_tiles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « components/ntp_tiles/popular_sites.h ('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/android/ntp/popular_sites.h" 5 #include "components/ntp_tiles/popular_sites.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/files/important_file_writer.h" 13 #include "base/files/important_file_writer.h"
14 #include "base/json/json_reader.h" 14 #include "base/json/json_reader.h"
15 #include "base/json/json_writer.h" 15 #include "base/json/json_writer.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/task_runner_util.h" 19 #include "base/task_runner_util.h"
20 #include "base/time/time.h" 20 #include "base/time/time.h"
21 #include "base/values.h" 21 #include "base/values.h"
22 #include "chrome/common/chrome_paths.h"
23 #include "components/google/core/browser/google_util.h" 22 #include "components/google/core/browser/google_util.h"
24 #include "components/ntp_tiles/pref_names.h" 23 #include "components/ntp_tiles/pref_names.h"
25 #include "components/ntp_tiles/switches.h" 24 #include "components/ntp_tiles/switches.h"
26 #include "components/pref_registry/pref_registry_syncable.h" 25 #include "components/pref_registry/pref_registry_syncable.h"
27 #include "components/prefs/pref_service.h" 26 #include "components/prefs/pref_service.h"
28 #include "components/search_engines/search_engine_type.h" 27 #include "components/search_engines/search_engine_type.h"
29 #include "components/search_engines/template_url_prepopulate_data.h" 28 #include "components/search_engines/template_url_prepopulate_data.h"
30 #include "components/search_engines/template_url_service.h" 29 #include "components/search_engines/template_url_service.h"
31 #include "components/variations/service/variations_service.h" 30 #include "components/variations/service/variations_service.h"
32 #include "net/base/load_flags.h" 31 #include "net/base/load_flags.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 &error_line, &error_column); 168 &error_line, &error_column);
170 if (value) { 169 if (value) {
171 success_callback.Run(std::move(value)); 170 success_callback.Run(std::move(value));
172 } else { 171 } else {
173 error_callback.Run(base::StringPrintf("%s (%d:%d)", error_msg.c_str(), 172 error_callback.Run(base::StringPrintf("%s (%d:%d)", error_msg.c_str(),
174 error_line, error_column)); 173 error_line, error_column));
175 } 174 }
176 } 175 }
177 }; 176 };
178 177
179 using UntrustedJsonParser = JsonUnsafeParser; 178 using UntrustedJsonParser = JsonUnsafeParser;
blundell 2016/06/08 13:59:32 This seems unfortunately hacky :(. Why not just pa
sfiera 2016/06/09 14:42:40 What do you find hacky about it? Our problem is th
180 #else 179 #else
181 using UntrustedJsonParser = safe_json::SafeJsonParser; 180 using UntrustedJsonParser = safe_json::SafeJsonParser;
182 #endif 181 #endif
183 182
184 } // namespace 183 } // namespace
185 184
186 base::FilePath ChromePopularSites::GetDirectory() {
187 base::FilePath dir;
188 PathService::Get(chrome::DIR_USER_DATA, &dir);
189 return dir; // empty if PathService::Get() failed.
190 }
191
192 PopularSites::Site::Site(const base::string16& title, 185 PopularSites::Site::Site(const base::string16& title,
193 const GURL& url, 186 const GURL& url,
194 const GURL& favicon_url, 187 const GURL& favicon_url,
195 const GURL& large_icon_url, 188 const GURL& large_icon_url,
196 const GURL& thumbnail_url) 189 const GURL& thumbnail_url)
197 : title(title), 190 : title(title),
198 url(url), 191 url(url),
199 favicon_url(favicon_url), 192 favicon_url(favicon_url),
200 large_icon_url(large_icon_url), 193 large_icon_url(large_icon_url),
201 thumbnail_url(thumbnail_url) {} 194 thumbnail_url(thumbnail_url) {}
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 DLOG(WARNING) << "Download country site list failed"; 438 DLOG(WARNING) << "Download country site list failed";
446 is_fallback_ = true; 439 is_fallback_ = true;
447 pending_country_ = kPopularSitesDefaultCountryCode; 440 pending_country_ = kPopularSitesDefaultCountryCode;
448 pending_version_ = kPopularSitesDefaultVersion; 441 pending_version_ = kPopularSitesDefaultVersion;
449 FetchPopularSites(GetPopularSitesURL()); 442 FetchPopularSites(GetPopularSitesURL());
450 } else { 443 } else {
451 DLOG(WARNING) << "Download fallback site list failed"; 444 DLOG(WARNING) << "Download fallback site list failed";
452 callback_.Run(false); 445 callback_.Run(false);
453 } 446 }
454 } 447 }
OLDNEW
« no previous file with comments | « components/ntp_tiles/popular_sites.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698