| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_resource/promo_resource_service.h" | 5 #include "chrome/browser/web_resource/promo_resource_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 void PromoResourceService::RegisterPrefs(PrefRegistrySimple* registry) { | 64 void PromoResourceService::RegisterPrefs(PrefRegistrySimple* registry) { |
| 65 registry->RegisterStringPref(prefs::kNtpPromoResourceCacheUpdate, "0"); | 65 registry->RegisterStringPref(prefs::kNtpPromoResourceCacheUpdate, "0"); |
| 66 NotificationPromo::RegisterPrefs(registry); | 66 NotificationPromo::RegisterPrefs(registry); |
| 67 } | 67 } |
| 68 | 68 |
| 69 // static | 69 // static |
| 70 void PromoResourceService::RegisterProfilePrefs( | 70 void PromoResourceService::RegisterProfilePrefs( |
| 71 user_prefs::PrefRegistrySyncable* registry) { | 71 user_prefs::PrefRegistrySyncable* registry) { |
| 72 // TODO(dbeam): This is registered only for migration; remove in M28 | 72 // TODO(dbeam): This is registered only for migration; remove in M28 |
| 73 // when all prefs have been cleared. http://crbug.com/168887 | 73 // when all prefs have been cleared. http://crbug.com/168887 |
| 74 registry->RegisterStringPref( | 74 registry->RegisterStringPref(prefs::kNtpPromoResourceCacheUpdate, "0"); |
| 75 prefs::kNtpPromoResourceCacheUpdate, | |
| 76 "0", | |
| 77 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 78 NotificationPromo::RegisterProfilePrefs(registry); | 75 NotificationPromo::RegisterProfilePrefs(registry); |
| 79 } | 76 } |
| 80 | 77 |
| 81 // static | 78 // static |
| 82 void PromoResourceService::MigrateUserPrefs(PrefService* user_prefs) { | 79 void PromoResourceService::MigrateUserPrefs(PrefService* user_prefs) { |
| 83 user_prefs->ClearPref(prefs::kNtpPromoResourceCacheUpdate); | 80 user_prefs->ClearPref(prefs::kNtpPromoResourceCacheUpdate); |
| 84 NotificationPromo::MigrateUserPrefs(user_prefs); | 81 NotificationPromo::MigrateUserPrefs(user_prefs); |
| 85 } | 82 } |
| 86 | 83 |
| 87 PromoResourceService::PromoResourceService() | 84 PromoResourceService::PromoResourceService() |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 166 } |
| 170 | 167 |
| 171 void PromoResourceService::Unpack(const base::DictionaryValue& parsed_json) { | 168 void PromoResourceService::Unpack(const base::DictionaryValue& parsed_json) { |
| 172 for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) { | 169 for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) { |
| 173 NotificationPromo notification_promo; | 170 NotificationPromo notification_promo; |
| 174 notification_promo.InitFromJson(parsed_json, kValidPromoTypes[i]); | 171 notification_promo.InitFromJson(parsed_json, kValidPromoTypes[i]); |
| 175 if (notification_promo.new_notification()) | 172 if (notification_promo.new_notification()) |
| 176 ScheduleNotification(notification_promo); | 173 ScheduleNotification(notification_promo); |
| 177 } | 174 } |
| 178 } | 175 } |
| OLD | NEW |