| 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 12 matching lines...) Expand all Loading... |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // Delay on first fetch so we don't interfere with startup. | 25 // Delay on first fetch so we don't interfere with startup. |
| 26 const int kStartResourceFetchDelay = 5000; | 26 const int kStartResourceFetchDelay = 5000; |
| 27 | 27 |
| 28 // Delay between calls to fetch the promo json: 6 hours in production, and 3 min | 28 // Delay between calls to fetch the promo json: 6 hours in production, and 3 min |
| 29 // in debug. | 29 // in debug. |
| 30 const int kCacheUpdateDelay = 6 * 60 * 60 * 1000; | 30 const int kCacheUpdateDelay = 6 * 60 * 60 * 1000; |
| 31 const int kTestCacheUpdateDelay = 3 * 60 * 1000; | 31 const int kTestCacheUpdateDelay = 3 * 60 * 1000; |
| 32 | 32 |
| 33 // The version of the service (used to expire the cache when upgrading Chrome | |
| 34 // to versions with different types of promos). | |
| 35 const int kPromoServiceVersion = 7; | |
| 36 | |
| 37 // The promotion type used for Unpack() and ScheduleNotificationOnInit(). | 33 // The promotion type used for Unpack() and ScheduleNotificationOnInit(). |
| 38 const NotificationPromo::PromoType kValidPromoTypes[] = { | 34 const NotificationPromo::PromoType kValidPromoTypes[] = { |
| 39 #if defined(OS_ANDROID) || defined(OS_IOS) | 35 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 40 NotificationPromo::MOBILE_NTP_SYNC_PROMO, | 36 NotificationPromo::MOBILE_NTP_SYNC_PROMO, |
| 41 #else | 37 #else |
| 42 NotificationPromo::NTP_NOTIFICATION_PROMO, | 38 NotificationPromo::NTP_NOTIFICATION_PROMO, |
| 43 NotificationPromo::NTP_BUBBLE_PROMO, | 39 NotificationPromo::NTP_BUBBLE_PROMO, |
| 44 #endif | 40 #endif |
| 45 }; | 41 }; |
| 46 | 42 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 164 } |
| 169 | 165 |
| 170 void PromoResourceService::Unpack(const DictionaryValue& parsed_json) { | 166 void PromoResourceService::Unpack(const DictionaryValue& parsed_json) { |
| 171 for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) { | 167 for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) { |
| 172 NotificationPromo notification_promo; | 168 NotificationPromo notification_promo; |
| 173 notification_promo.InitFromJson(parsed_json, kValidPromoTypes[i]); | 169 notification_promo.InitFromJson(parsed_json, kValidPromoTypes[i]); |
| 174 if (notification_promo.new_notification()) | 170 if (notification_promo.new_notification()) |
| 175 ScheduleNotification(notification_promo); | 171 ScheduleNotification(notification_promo); |
| 176 } | 172 } |
| 177 } | 173 } |
| OLD | NEW |