| 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 "chrome/browser/android/ntp/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/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/task_runner_util.h" | 17 #include "base/task_runner_util.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/search_engines/template_url_service_factory.h" | 22 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 23 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 24 #include "chrome/common/chrome_switches.h" | |
| 25 #include "components/google/core/browser/google_util.h" | 24 #include "components/google/core/browser/google_util.h" |
| 25 #include "components/ntp_tiles/switches.h" |
| 26 #include "components/pref_registry/pref_registry_syncable.h" | 26 #include "components/pref_registry/pref_registry_syncable.h" |
| 27 #include "components/prefs/pref_service.h" | 27 #include "components/prefs/pref_service.h" |
| 28 #include "components/search_engines/search_engine_type.h" | 28 #include "components/search_engines/search_engine_type.h" |
| 29 #include "components/search_engines/template_url_prepopulate_data.h" | 29 #include "components/search_engines/template_url_prepopulate_data.h" |
| 30 #include "components/search_engines/template_url_service.h" | 30 #include "components/search_engines/template_url_service.h" |
| 31 #include "components/variations/service/variations_service.h" | 31 #include "components/variations/service/variations_service.h" |
| 32 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| 33 | 33 |
| 34 using content::BrowserThread; | 34 using content::BrowserThread; |
| 35 namespace switches = ntp_tiles::switches; |
| 35 | 36 |
| 36 namespace { | 37 namespace { |
| 37 | 38 |
| 38 const char kPopularSitesURLFormat[] = | 39 const char kPopularSitesURLFormat[] = |
| 39 "https://www.gstatic.com/chrome/ntp/suggested_sites_%s_%s.json"; | 40 "https://www.gstatic.com/chrome/ntp/suggested_sites_%s_%s.json"; |
| 40 const char kPopularSitesDefaultCountryCode[] = "DEFAULT"; | 41 const char kPopularSitesDefaultCountryCode[] = "DEFAULT"; |
| 41 const char kPopularSitesDefaultVersion[] = "5"; | 42 const char kPopularSitesDefaultVersion[] = "5"; |
| 42 const char kPopularSitesLocalFilename[] = "suggested_sites.json"; | 43 const char kPopularSitesLocalFilename[] = "suggested_sites.json"; |
| 43 const int kPopularSitesRedownloadIntervalHours = 24; | 44 const int kPopularSitesRedownloadIntervalHours = 24; |
| 44 | 45 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 base::Bind(&PopularSites::OnJsonParsed, weak_ptr_factory_.GetWeakPtr())); | 304 base::Bind(&PopularSites::OnJsonParsed, weak_ptr_factory_.GetWeakPtr())); |
| 304 } | 305 } |
| 305 | 306 |
| 306 void PopularSites::OnJsonParsed(std::unique_ptr<std::vector<Site>> sites) { | 307 void PopularSites::OnJsonParsed(std::unique_ptr<std::vector<Site>> sites) { |
| 307 if (sites) | 308 if (sites) |
| 308 sites_.swap(*sites); | 309 sites_.swap(*sites); |
| 309 else | 310 else |
| 310 sites_.clear(); | 311 sites_.clear(); |
| 311 callback_.Run(!!sites); | 312 callback_.Run(!!sites); |
| 312 } | 313 } |
| OLD | NEW |