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

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

Issue 8045012: NotificationPromo (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Rename files to notification_promo.[h|cc] Created 9 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
Index: chrome/browser/web_resource/promo_resource_service.h
===================================================================
--- chrome/browser/web_resource/promo_resource_service.h (revision 102893)
+++ chrome/browser/web_resource/promo_resource_service.h (working copy)
@@ -8,6 +8,7 @@
#include <string>
+#include "chrome/browser/web_resource/notification_promo.h"
#include "chrome/browser/web_resource/web_resource_service.h"
#include "chrome/common/chrome_version_info.h"
@@ -27,8 +28,19 @@
// messages, which have until now been piggybacked onto the old tips server
// structure. (see http://crbug.com/70634 for details.)
class PromoResourceService
- : public WebResourceService {
+ : public WebResourceService,
+ public NotificationPromo::Delegate {
public:
+ // Identifies types of Chrome builds for promo targeting.
+ enum BuildType {
+ NO_BUILD = 0,
+ DEV_BUILD = 1,
+ BETA_BUILD = 1 << 1,
+ STABLE_BUILD = 1 << 2,
+ CANARY_BUILD = 1 << 3,
+ ALL_BUILDS = (1 << 4) - 1,
+ };
+
// Checks for conditions to show promo: start/end times, channel, etc.
static bool CanShowNotificationPromo(Profile* profile);
@@ -38,13 +50,15 @@
explicit PromoResourceService(Profile* profile);
+ static chrome::VersionInfo::Channel GetChannel();
+ static bool IsBuildTargeted(chrome::VersionInfo::Channel, int builds_allowed);
+
// Default server of dynamically loaded NTP HTML elements.
static const char* kDefaultPromoResourceServer;
private:
- FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, IsBuildTargeted);
+ FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, IsBuildTargetedTest);
FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackLogoSignal);
- FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackNotificationSignal);
FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, UnpackWebStoreSignal);
FRIEND_TEST_ALL_PREFIXES(
PromoResourceServiceTest, UnpackPartialWebStoreSignal);
@@ -55,16 +69,6 @@
FRIEND_TEST_ALL_PREFIXES(
PromoResourceServiceTest, UnpackWebStoreSignalHttpLogo);
- // Identifies types of Chrome builds for promo targeting.
- enum BuildType {
- NO_BUILD = 0,
- DEV_BUILD = 1,
- BETA_BUILD = 1 << 1,
- STABLE_BUILD = 1 << 2,
- CANARY_BUILD = 1 << 3,
- ALL_BUILDS = (1 << 4) - 1,
- };
-
virtual ~PromoResourceService();
int GetPromoServiceVersion();
@@ -75,17 +79,14 @@
void Init();
- static bool IsBuildTargeted(chrome::VersionInfo::Channel channel,
- int builds_targeted);
-
// Returns true if |builds_targeted| includes the release channel Chrome
// belongs to. For testing purposes, you can override the current channel
// with set_channel.
- bool IsThisBuildTargeted(int builds_targeted);
+ bool IsBuildTargeted(int builds_targeted);
// Schedule a notification that a web resource is either going to become
// available or be no longer valid.
- void ScheduleNotification(double ms_start_time, double ms_end_time);
+ void ScheduleNotification(double start, double end);
// Schedules the initial notification for when the web resource is going
// to become available or no longer valid. This performs a few additional
@@ -96,18 +97,19 @@
// Overrides the current Chrome release channel for testing purposes.
void set_channel(chrome::VersionInfo::Channel channel) { channel_ = channel; }
- virtual void Unpack(const base::DictionaryValue& parsed_json);
+ // WebResourceService override.
+ virtual void Unpack(const base::DictionaryValue& parsed_json) OVERRIDE;
- // Unpack the web resource as a custom promo signal. Expects a start and end
- // signal, with the promo to be shown in the tooltip of the start signal
- // field. Delivery will be in json in the form of:
+ // Unpack the web resource as a custom notification signal. Expects a start
+ // and end signal, with the promo to be shown in the tooltip of the start
+ // signal field. Delivery will be in json in the form of:
// {
// "topic": {
// "answers": [
// {
// "answer_id": "1067976",
// "name": "promo_start",
- // "question": "1:24:10",
+ // "question": "1:24:10:10",
// "tooltip":
// "Click \u003ca href=http://www.google.com\u003ehere\u003c/a\u003e!",
// "inproduct": "10/8/09 12:00",
@@ -136,9 +138,10 @@
// this promo (see the BuildType enum in web_resource_service.cc), the
// number of hours that each promo group should see it, and the maximum promo
// group that should see it, separated by ":".
- // For example, "7:24:5" would indicate that all groups with ids less than 5,
- // and with dev, beta and stable builds, should see the promo. The groups
- // ramp up so 1 additional group sees the promo every 24 hours.
+ // For example, "7:24:5:10" would indicate that all groups with ids less than
+ // 5, and with dev, beta and stable builds, should see the promo a maximum of
+ // 10 times. The groups ramp up so 1 additional group sees the promo every
+ // 24 hours.
//
void UnpackNotificationSignal(const base::DictionaryValue& parsed_json);
@@ -202,44 +205,9 @@
// answer_id: the promo's id
void UnpackWebStoreSignal(const base::DictionaryValue& parsed_json);
- // Parse the answers array element.
- void ParseNotification(base::DictionaryValue* a_dic,
- std::string* promo_start_string,
- std::string* promo_end_string);
+ // NotificationPromo::Delegate override.
+ virtual void OnNewNotification(double start, double end) OVERRIDE;
- // Set notification promo params from a question string, which is of the form
- // <build_type>:<time_slice>:<max_group>.
- void SetNotificationParams(base::DictionaryValue* a_dic);
-
- // Extract the notification promo text from the tooltip string.
- void SetNotificationLine(base::DictionaryValue* a_dic);
-
- // Check if this notification promo is new based on start/end times,
- // and trigger events accordingly.
- void CheckForNewNotification(const std::string& promo_start_string,
- const std::string& promo_end_string);
-
- // Calculate the notification promo times, taking into account our group, and
- // the group time slice.
- void ParseNewNotificationTimes(const std::string& promo_start_string,
- const std::string& promo_end_string,
- double* promo_start,
- double* promo_end);
-
- // Calculates notification promo start time with group-based time slice
- // offset.
- static double GetNotificationStartTime(PrefService* prefs);
-
- // Create a new notification promo group.
- int ResetNotificationGroup();
-
- // Get saved notification promo times.
- void GetCurrentNotificationTimes(double* old_promo_start,
- double* old_promo_end);
-
- // Actions on receiving a new notification promo.
- void OnNewNotification(double promo_start, double promo_end);
-
// The profile this service belongs to.
Profile* profile_;
« no previous file with comments | « chrome/browser/web_resource/notification_promo.cc ('k') | chrome/browser/web_resource/promo_resource_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698