Chromium Code Reviews| 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" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 #include "components/ntp_tiles/pref_names.h" | 24 #include "components/ntp_tiles/pref_names.h" |
| 25 #include "components/ntp_tiles/switches.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_service.h" | 29 #include "components/search_engines/template_url_service.h" |
| 30 #include "components/variations/service/variations_service.h" | 30 #include "components/variations/service/variations_service.h" |
| 31 #include "components/variations/variations_associated_data.h" | 31 #include "components/variations/variations_associated_data.h" |
| 32 #include "net/base/load_flags.h" | 32 #include "net/base/load_flags.h" |
| 33 #include "net/http/http_status_code.h" | 33 #include "net/http/http_status_code.h" |
| 34 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 34 | 35 |
| 35 #if defined(OS_ANDROID) || defined(OS_IOS) | 36 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 36 #include "base/json/json_reader.h" | 37 #include "base/json/json_reader.h" |
| 37 #include "components/grit/components_resources.h" | 38 #include "components/grit/components_resources.h" |
| 38 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" |
| 39 #endif | 40 #endif |
| 40 | 41 |
| 41 #if defined(OS_IOS) | 42 #if defined(OS_IOS) |
| 42 #include "components/ntp_tiles/country_code_ios.h" | 43 #include "components/ntp_tiles/country_code_ios.h" |
| 43 #endif | 44 #endif |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 user_prefs->RegisterStringPref(ntp_tiles::prefs::kPopularSitesOverrideVersion, | 300 user_prefs->RegisterStringPref(ntp_tiles::prefs::kPopularSitesOverrideVersion, |
| 300 std::string()); | 301 std::string()); |
| 301 | 302 |
| 302 user_prefs->RegisterInt64Pref(kPopularSitesLastDownloadPref, 0); | 303 user_prefs->RegisterInt64Pref(kPopularSitesLastDownloadPref, 0); |
| 303 user_prefs->RegisterStringPref(kPopularSitesURLPref, std::string()); | 304 user_prefs->RegisterStringPref(kPopularSitesURLPref, std::string()); |
| 304 user_prefs->RegisterListPref(kPopularSitesJsonPref, | 305 user_prefs->RegisterListPref(kPopularSitesJsonPref, |
| 305 DefaultPopularSites().release()); | 306 DefaultPopularSites().release()); |
| 306 } | 307 } |
| 307 | 308 |
| 308 void PopularSitesImpl::FetchPopularSites() { | 309 void PopularSitesImpl::FetchPopularSites() { |
| 309 fetcher_ = URLFetcher::Create(pending_url_, URLFetcher::GET, this); | 310 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 311 net::DefineNetworkTrafficAnnotation("...", R"( | |
|
Marc Treib
2017/02/22 09:49:37
popular_sites or popular_sites_fetch?
sfiera
2017/02/22 10:06:12
Should we prefix "popular sites" with "new tab pag
Ramin Halavati
2017/02/22 10:35:08
The first identifier is mostly a unique (meaningfu
| |
| 312 semantics { | |
| 313 sender: "..." | |
|
Marc Treib
2017/02/22 09:49:37
popular sites
Ramin Halavati
2017/02/22 10:35:08
Done.
| |
| 314 description: "..." | |
|
Marc Treib
2017/02/22 09:49:37
Google Chrome may display a list of regionally-pop
sfiera
2017/02/22 10:06:12
Do we not disable it for enterprise users, as we d
Marc Treib
2017/02/22 12:16:37
No, I don't think so.
Shouldn't be too hard to set
| |
| 315 trigger: "..." | |
|
Marc Treib
2017/02/22 09:49:37
Triggered automatically once per day, unless no po
Ramin Halavati
2017/02/22 10:35:08
Done.
| |
| 316 data: "..." | |
|
Marc Treib
2017/02/22 09:49:37
A two-letter country code based on the user's loca
Ramin Halavati
2017/02/22 10:35:08
Done.
| |
| 317 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
|
Marc Treib
2017/02/22 09:49:37
GOOGLE_OWNED_SERVICE
Ramin Halavati
2017/02/22 10:35:08
Done.
| |
| 318 } | |
| 319 policy { | |
| 320 cookies_allowed: false/true | |
|
Marc Treib
2017/02/22 09:49:36
false
Ramin Halavati
2017/02/22 10:35:09
Done.
| |
| 321 cookies_store: "..." | |
|
Marc Treib
2017/02/22 09:49:37
n/a
Ramin Halavati
2017/02/22 10:35:09
Done.
| |
| 322 setting: "..." | |
|
Marc Treib
2017/02/22 09:49:36
NA
Ramin Halavati
2017/02/22 10:35:09
Done.
| |
| 323 policy { | |
| 324 [POLICY_NAME] { | |
| 325 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
| 326 value: ... | |
| 327 } | |
| 328 } | |
| 329 policy_exception_justification: "..." | |
|
Marc Treib
2017/02/22 09:49:37
Not sure - since we don't send any PII, I think a
Ramin Halavati
2017/02/22 10:35:08
But as you are sending user's country, it might ca
| |
| 330 })"); | |
| 331 fetcher_ = URLFetcher::Create(pending_url_, URLFetcher::GET, this, | |
| 332 traffic_annotation); | |
| 310 data_use_measurement::DataUseUserData::AttachToFetcher( | 333 data_use_measurement::DataUseUserData::AttachToFetcher( |
|
sfiera
2017/02/22 10:06:12
Will this new feature eventually supersede data_us
Ramin Halavati
2017/02/22 10:35:09
I don't think so.
battre@:
Any comments?
Marc Treib
2017/02/22 12:16:37
I wondered the same thing: We now have two things
| |
| 311 fetcher_.get(), data_use_measurement::DataUseUserData::NTP_TILES); | 334 fetcher_.get(), data_use_measurement::DataUseUserData::NTP_TILES); |
| 312 fetcher_->SetRequestContext(download_context_); | 335 fetcher_->SetRequestContext(download_context_); |
| 313 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 336 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 314 net::LOAD_DO_NOT_SAVE_COOKIES); | 337 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 315 fetcher_->SetAutomaticallyRetryOnNetworkChanges(1); | 338 fetcher_->SetAutomaticallyRetryOnNetworkChanges(1); |
| 316 fetcher_->Start(); | 339 fetcher_->Start(); |
| 317 } | 340 } |
| 318 | 341 |
| 319 void PopularSitesImpl::OnURLFetchComplete(const net::URLFetcher* source) { | 342 void PopularSitesImpl::OnURLFetchComplete(const net::URLFetcher* source) { |
| 320 DCHECK_EQ(fetcher_.get(), source); | 343 DCHECK_EQ(fetcher_.get(), source); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 pending_url_ = GetPopularSitesURL(kPopularSitesDefaultCountryCode, | 387 pending_url_ = GetPopularSitesURL(kPopularSitesDefaultCountryCode, |
| 365 kPopularSitesDefaultVersion); | 388 kPopularSitesDefaultVersion); |
| 366 FetchPopularSites(); | 389 FetchPopularSites(); |
| 367 } else { | 390 } else { |
| 368 DLOG(WARNING) << "Download fallback site list failed"; | 391 DLOG(WARNING) << "Download fallback site list failed"; |
| 369 callback_.Run(false); | 392 callback_.Run(false); |
| 370 } | 393 } |
| 371 } | 394 } |
| 372 | 395 |
| 373 } // namespace ntp_tiles | 396 } // namespace ntp_tiles |
| OLD | NEW |