| 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/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/safe_json/safe_json_parser.h" | 27 #include "components/safe_json/safe_json_parser.h" |
| 29 #include "components/search_engines/search_engine_type.h" | 28 #include "components/search_engines/search_engine_type.h" |
| 30 #include "components/search_engines/template_url_prepopulate_data.h" | 29 #include "components/search_engines/template_url_prepopulate_data.h" |
| 31 #include "components/search_engines/template_url_service.h" | 30 #include "components/search_engines/template_url_service.h" |
| 32 #include "components/variations/service/variations_service.h" | 31 #include "components/variations/service/variations_service.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 bool WriteJsonToFile(const base::FilePath& local_path, | 130 bool WriteJsonToFile(const base::FilePath& local_path, |
| 132 const base::Value* json) { | 131 const base::Value* json) { |
| 133 std::string json_string; | 132 std::string json_string; |
| 134 return base::JSONWriter::Write(*json, &json_string) && | 133 return base::JSONWriter::Write(*json, &json_string) && |
| 135 base::ImportantFileWriter::WriteFileAtomically(local_path, | 134 base::ImportantFileWriter::WriteFileAtomically(local_path, |
| 136 json_string); | 135 json_string); |
| 137 } | 136 } |
| 138 | 137 |
| 139 } // namespace | 138 } // namespace |
| 140 | 139 |
| 141 base::FilePath ChromePopularSites::GetDirectory() { | |
| 142 base::FilePath dir; | |
| 143 PathService::Get(chrome::DIR_USER_DATA, &dir); | |
| 144 return dir; // empty if PathService::Get() failed. | |
| 145 } | |
| 146 | |
| 147 PopularSites::Site::Site(const base::string16& title, | 140 PopularSites::Site::Site(const base::string16& title, |
| 148 const GURL& url, | 141 const GURL& url, |
| 149 const GURL& favicon_url, | 142 const GURL& favicon_url, |
| 150 const GURL& large_icon_url, | 143 const GURL& large_icon_url, |
| 151 const GURL& thumbnail_url) | 144 const GURL& thumbnail_url) |
| 152 : title(title), | 145 : title(title), |
| 153 url(url), | 146 url(url), |
| 154 favicon_url(favicon_url), | 147 favicon_url(favicon_url), |
| 155 large_icon_url(large_icon_url), | 148 large_icon_url(large_icon_url), |
| 156 thumbnail_url(thumbnail_url) {} | 149 thumbnail_url(thumbnail_url) {} |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 DLOG(WARNING) << "Download country site list failed"; | 393 DLOG(WARNING) << "Download country site list failed"; |
| 401 is_fallback_ = true; | 394 is_fallback_ = true; |
| 402 pending_country_ = kPopularSitesDefaultCountryCode; | 395 pending_country_ = kPopularSitesDefaultCountryCode; |
| 403 pending_version_ = kPopularSitesDefaultVersion; | 396 pending_version_ = kPopularSitesDefaultVersion; |
| 404 FetchPopularSites(GetPopularSitesURL()); | 397 FetchPopularSites(GetPopularSitesURL()); |
| 405 } else { | 398 } else { |
| 406 DLOG(WARNING) << "Download fallback site list failed"; | 399 DLOG(WARNING) << "Download fallback site list failed"; |
| 407 callback_.Run(false); | 400 callback_.Run(false); |
| 408 } | 401 } |
| 409 } | 402 } |
| OLD | NEW |