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

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

Issue 10911196: Support for ntp promo bubble. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: allow BR in parseHtmlSubset Created 8 years, 3 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
« no previous file with comments | « chrome/browser/web_resource/promo_resource_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/web_resource/promo_resource_service.cc
===================================================================
--- chrome/browser/web_resource/promo_resource_service.cc (revision 155564)
+++ chrome/browser/web_resource/promo_resource_service.cc (working copy)
@@ -12,6 +12,7 @@
#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"
#include "chrome/common/pref_names.h"
@@ -22,23 +23,25 @@
namespace {
// Delay on first fetch so we don't interfere with startup.
-static const int kStartResourceFetchDelay = 5000;
+const int kStartResourceFetchDelay = 5000;
// Delay between calls to update the cache (12 hours), and 3 min in debug mode.
-static const int kCacheUpdateDelay = 12 * 60 * 60 * 1000;
-static const int kTestCacheUpdateDelay = 3 * 60 * 1000;
+const int kCacheUpdateDelay = 12 * 60 * 60 * 1000;
+const int kTestCacheUpdateDelay = 3 * 60 * 1000;
// The version of the service (used to expire the cache when upgrading Chrome
// to versions with different types of promos).
-static const int kPromoServiceVersion = 7;
+const int kPromoServiceVersion = 7;
// The promotion type used for Unpack() and ScheduleNotificationOnInit.
-static const NotificationPromo::PromoType kDefaultPromoType =
+const NotificationPromo::PromoType kValidPromoTypes[] = {
#if defined(OS_ANDROID) || defined(OS_IOS)
- NotificationPromo::MOBILE_NTP_SYNC_PROMO;
+ NotificationPromo::MOBILE_NTP_SYNC_PROMO,
#else
- NotificationPromo::NTP_NOTIFICATION_PROMO;
+ NotificationPromo::NTP_NOTIFICATION_PROMO,
+ NotificationPromo::NTP_BUBBLE_PROMO,
#endif
+};
GURL GetPromoResourceURL() {
const std::string promo_server_url = CommandLine::ForCurrentProcess()->
@@ -97,8 +100,11 @@
PromoResourceService::~PromoResourceService() {
}
-void PromoResourceService::ScheduleNotification(double promo_start,
- double promo_end) {
+void PromoResourceService::ScheduleNotification(
+ const NotificationPromo& notification_promo) {
+ const double promo_start = notification_promo.StartTimeForGroup();
+ const double promo_end = notification_promo.EndTime();
+
if (promo_start > 0 && promo_end > 0) {
const int64 ms_until_start =
static_cast<int64>((base::Time::FromDoubleT(
@@ -143,10 +149,11 @@
} else {
// If the promo start is in the future, set a notification task to
// invalidate the NTP cache at the time of the promo start.
- NotificationPromo notification_promo(profile_);
- notification_promo.InitFromPrefs(kDefaultPromoType);
- ScheduleNotification(notification_promo.StartTimeForGroup(),
- notification_promo.EndTime());
+ for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) {
+ NotificationPromo notification_promo(profile_);
+ notification_promo.InitFromPrefs(kValidPromoTypes[i]);
+ ScheduleNotification(notification_promo);
+ }
}
}
@@ -187,11 +194,10 @@
}
void PromoResourceService::Unpack(const DictionaryValue& parsed_json) {
- NotificationPromo notification_promo(profile_);
- notification_promo.InitFromJson(parsed_json, kDefaultPromoType);
-
- if (notification_promo.new_notification()) {
- ScheduleNotification(notification_promo.StartTimeForGroup(),
- notification_promo.EndTime());
+ for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) {
+ NotificationPromo notification_promo(profile_);
+ notification_promo.InitFromJson(parsed_json, kValidPromoTypes[i]);
+ if (notification_promo.new_notification())
+ ScheduleNotification(notification_promo);
}
}
« no previous file with comments | « chrome/browser/web_resource/promo_resource_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698