| 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 "components/ntp_tiles/popular_sites_impl.h" | 5 #include "components/ntp_tiles/popular_sites_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/feature_list.h" |
| 12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 13 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 17 #include "base/threading/sequenced_worker_pool.h" | 18 #include "base/threading/sequenced_worker_pool.h" |
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 19 #include "base/values.h" | 20 #include "base/values.h" |
| 20 #include "components/data_use_measurement/core/data_use_user_data.h" | 21 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 21 #include "components/google/core/browser/google_util.h" | 22 #include "components/google/core/browser/google_util.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 147 } |
| 147 site->SetInteger("default_icon_resource", resource_id); | 148 site->SetInteger("default_icon_resource", resource_id); |
| 148 } | 149 } |
| 149 #endif | 150 #endif |
| 150 | 151 |
| 151 // Creates the list of popular sites based on a snapshot available for mobile. | 152 // Creates the list of popular sites based on a snapshot available for mobile. |
| 152 std::unique_ptr<base::ListValue> DefaultPopularSites() { | 153 std::unique_ptr<base::ListValue> DefaultPopularSites() { |
| 153 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 154 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 154 return base::MakeUnique<base::ListValue>(); | 155 return base::MakeUnique<base::ListValue>(); |
| 155 #else | 156 #else |
| 157 if (!base::FeatureList::IsEnabled(kPopularSitesBakedInContentFeature)) { |
| 158 return base::MakeUnique<base::ListValue>(); |
| 159 } |
| 156 std::unique_ptr<base::ListValue> sites = | 160 std::unique_ptr<base::ListValue> sites = |
| 157 base::ListValue::From(base::JSONReader::Read( | 161 base::ListValue::From(base::JSONReader::Read( |
| 158 ResourceBundle::GetSharedInstance().GetRawDataResource( | 162 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 159 IDR_DEFAULT_POPULAR_SITES_JSON))); | 163 IDR_DEFAULT_POPULAR_SITES_JSON))); |
| 160 DCHECK(sites); | 164 DCHECK(sites); |
| 161 #if defined(GOOGLE_CHROME_BUILD) | 165 #if defined(GOOGLE_CHROME_BUILD) |
| 162 int index = 0; | 166 int index = 0; |
| 163 for (int icon_resource : | 167 for (int icon_resource : |
| 164 {IDR_DEFAULT_POPULAR_SITES_ICON0, IDR_DEFAULT_POPULAR_SITES_ICON1, | 168 {IDR_DEFAULT_POPULAR_SITES_ICON0, IDR_DEFAULT_POPULAR_SITES_ICON1, |
| 165 IDR_DEFAULT_POPULAR_SITES_ICON2, IDR_DEFAULT_POPULAR_SITES_ICON3, | 169 IDR_DEFAULT_POPULAR_SITES_ICON2, IDR_DEFAULT_POPULAR_SITES_ICON3, |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 pending_url_ = GetPopularSitesURL(kPopularSitesDefaultCountryCode, | 416 pending_url_ = GetPopularSitesURL(kPopularSitesDefaultCountryCode, |
| 413 kPopularSitesDefaultVersion); | 417 kPopularSitesDefaultVersion); |
| 414 FetchPopularSites(); | 418 FetchPopularSites(); |
| 415 } else { | 419 } else { |
| 416 DLOG(WARNING) << "Download fallback site list failed"; | 420 DLOG(WARNING) << "Download fallback site list failed"; |
| 417 callback_.Run(false); | 421 callback_.Run(false); |
| 418 } | 422 } |
| 419 } | 423 } |
| 420 | 424 |
| 421 } // namespace ntp_tiles | 425 } // namespace ntp_tiles |
| OLD | NEW |