| 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/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "base/task_runner_util.h" | 18 #include "base/task_runner_util.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "chrome/common/chrome_paths.h" | |
| 22 #include "components/google/core/browser/google_util.h" | 21 #include "components/google/core/browser/google_util.h" |
| 23 #include "components/ntp_tiles/pref_names.h" | 22 #include "components/ntp_tiles/pref_names.h" |
| 24 #include "components/ntp_tiles/switches.h" | 23 #include "components/ntp_tiles/switches.h" |
| 25 #include "components/pref_registry/pref_registry_syncable.h" | 24 #include "components/pref_registry/pref_registry_syncable.h" |
| 26 #include "components/prefs/pref_service.h" | 25 #include "components/prefs/pref_service.h" |
| 27 #include "components/safe_json/json_sanitizer.h" | 26 #include "components/safe_json/json_sanitizer.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" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 sites->push_back(PopularSites::Site(title, GURL(url), GURL(favicon_url), | 157 sites->push_back(PopularSites::Site(title, GURL(url), GURL(favicon_url), |
| 159 GURL(large_icon_url), | 158 GURL(large_icon_url), |
| 160 GURL(thumbnail_url))); | 159 GURL(thumbnail_url))); |
| 161 } | 160 } |
| 162 | 161 |
| 163 return sites; | 162 return sites; |
| 164 } | 163 } |
| 165 | 164 |
| 166 } // namespace | 165 } // namespace |
| 167 | 166 |
| 168 base::FilePath ChromePopularSites::GetDirectory() { | |
| 169 base::FilePath dir; | |
| 170 PathService::Get(chrome::DIR_USER_DATA, &dir); | |
| 171 return dir; // empty if PathService::Get() failed. | |
| 172 } | |
| 173 | |
| 174 PopularSites::Site::Site(const base::string16& title, | 167 PopularSites::Site::Site(const base::string16& title, |
| 175 const GURL& url, | 168 const GURL& url, |
| 176 const GURL& favicon_url, | 169 const GURL& favicon_url, |
| 177 const GURL& large_icon_url, | 170 const GURL& large_icon_url, |
| 178 const GURL& thumbnail_url) | 171 const GURL& thumbnail_url) |
| 179 : title(title), | 172 : title(title), |
| 180 url(url), | 173 url(url), |
| 181 favicon_url(favicon_url), | 174 favicon_url(favicon_url), |
| 182 large_icon_url(large_icon_url), | 175 large_icon_url(large_icon_url), |
| 183 thumbnail_url(thumbnail_url) {} | 176 thumbnail_url(thumbnail_url) {} |
| (...skipping 216 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 |