| Index: chrome/browser/web_resource/promo_resource_service.cc
|
| diff --git a/chrome/browser/web_resource/promo_resource_service.cc b/chrome/browser/web_resource/promo_resource_service.cc
|
| index ad4c185dae5b128acc71c6dec211bfb9c37d61c9..6bc23f678e566f5e3371460276738c4b4cf871ce 100644
|
| --- a/chrome/browser/web_resource/promo_resource_service.cc
|
| +++ b/chrome/browser/web_resource/promo_resource_service.cc
|
| @@ -11,7 +11,6 @@
|
| #include "base/values.h"
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/prefs/pref_service.h"
|
| -#include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/web_resource/notification_promo.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| #include "chrome/common/chrome_switches.h"
|
| @@ -34,7 +33,7 @@ const int kTestCacheUpdateDelay = 3 * 60 * 1000;
|
| // to versions with different types of promos).
|
| const int kPromoServiceVersion = 7;
|
|
|
| -// The promotion type used for Unpack() and ScheduleNotificationOnInit.
|
| +// The promotion type used for Unpack() and ScheduleNotificationOnInit().
|
| const NotificationPromo::PromoType kValidPromoTypes[] = {
|
| #if defined(OS_ANDROID) || defined(OS_IOS)
|
| NotificationPromo::MOBILE_NTP_SYNC_PROMO,
|
| @@ -63,32 +62,28 @@ int GetCacheUpdateDelay() {
|
|
|
| // static
|
| void PromoResourceService::RegisterPrefs(PrefServiceSimple* local_state) {
|
| - // TODO(achuith): Delete this in M26. http://crbug.com/143773
|
| - // The promo service version number, and last locale.
|
| - const char kNtpPromoVersion[] = "ntp.promo_version";
|
| - const char kNtpPromoLocale[] = "ntp.promo_locale";
|
| - local_state->RegisterIntegerPref(kNtpPromoVersion, 0);
|
| - local_state->RegisterStringPref(kNtpPromoLocale, std::string());
|
| - local_state->ClearPref(kNtpPromoVersion);
|
| - local_state->ClearPref(kNtpPromoLocale);
|
| + local_state->RegisterStringPref(prefs::kNtpPromoResourceCacheUpdate, "0");
|
| + NotificationPromo::RegisterPrefs(local_state);
|
| }
|
|
|
| // static
|
| void PromoResourceService::RegisterUserPrefs(PrefServiceSyncable* prefs) {
|
| + // TODO(dbeam): remove in M28 when all prefs have been cleared.
|
| prefs->RegisterStringPref(prefs::kNtpPromoResourceCacheUpdate,
|
| "0",
|
| PrefServiceSyncable::UNSYNCABLE_PREF);
|
| + prefs->ClearPref(prefs::kNtpPromoResourceCacheUpdate);
|
| NotificationPromo::RegisterUserPrefs(prefs);
|
| }
|
|
|
| -PromoResourceService::PromoResourceService(Profile* profile)
|
| - : WebResourceService(profile->GetPrefs(),
|
| +PromoResourceService::PromoResourceService(PrefServiceSimple* prefs)
|
| + : WebResourceService(prefs,
|
| GetPromoResourceURL(),
|
| true, // append locale to URL
|
| prefs::kNtpPromoResourceCacheUpdate,
|
| kStartResourceFetchDelay,
|
| GetCacheUpdateDelay()),
|
| - profile_(profile),
|
| + prefs_(prefs),
|
| ALLOW_THIS_IN_INITIALIZER_LIST(
|
| weak_ptr_factory_(this)) {
|
| ScheduleNotificationOnInit();
|
| @@ -133,7 +128,7 @@ void PromoResourceService::ScheduleNotificationOnInit() {
|
| // If the promo start is in the future, set a notification task to
|
| // invalidate the NTP cache at the time of the promo start.
|
| for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) {
|
| - NotificationPromo notification_promo(profile_);
|
| + NotificationPromo notification_promo(prefs_);
|
| notification_promo.InitFromPrefs(kValidPromoTypes[i]);
|
| ScheduleNotification(notification_promo);
|
| }
|
| @@ -167,7 +162,7 @@ void PromoResourceService::PromoResourceStateChange() {
|
|
|
| void PromoResourceService::Unpack(const DictionaryValue& parsed_json) {
|
| for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) {
|
| - NotificationPromo notification_promo(profile_);
|
| + NotificationPromo notification_promo(prefs_);
|
| notification_promo.InitFromJson(parsed_json, kValidPromoTypes[i]);
|
| if (notification_promo.new_notification())
|
| ScheduleNotification(notification_promo);
|
|
|