Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1220)

Unified Diff: chrome/browser/web_resource/promo_resource_service.cc

Issue 11689004: Move PromoResourceService from Profile to BrowserProcessImpl/local_state(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..fd2d09a6466db5ac9434a1382bb4408d12c30ecb 100644
--- a/chrome/browser/web_resource/promo_resource_service.cc
+++ b/chrome/browser/web_resource/promo_resource_service.cc
@@ -10,8 +10,8 @@
#include "base/threading/thread_restrictions.h"
#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/prefs/pref_service_simple.h"
+#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/web_resource/notification_promo.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
@@ -34,7 +34,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 +63,27 @@ 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()
+ : WebResourceService(g_browser_process->local_state(),
GetPromoResourceURL(),
true, // append locale to URL
prefs::kNtpPromoResourceCacheUpdate,
kStartResourceFetchDelay,
GetCacheUpdateDelay()),
- profile_(profile),
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;
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;
notification_promo.InitFromJson(parsed_json, kValidPromoTypes[i]);
if (notification_promo.new_notification())
ScheduleNotification(notification_promo);

Powered by Google App Engine
This is Rietveld 408576698