Chromium Code Reviews| Index: chrome/browser/web_resource/notification_promo.h |
| =================================================================== |
| --- chrome/browser/web_resource/notification_promo.h (revision 111558) |
| +++ chrome/browser/web_resource/notification_promo.h (working copy) |
| @@ -10,30 +10,40 @@ |
| #include "base/basictypes.h" |
| #include "base/gtest_prod_util.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| namespace base { |
| class DictionaryValue; |
| } |
| +namespace net { |
| + class URLRequestContextGetter; |
| +} |
| + |
| class PrefService; |
| +class Profile; |
| // Helper class for PromoResourceService that parses promo notification info |
| // from json or prefs. |
| -class NotificationPromo { |
| +class NotificationPromo |
| + : public base::RefCountedThreadSafe<NotificationPromo> { |
| public: |
| class Delegate { |
| public: |
| virtual ~Delegate() {} |
| - virtual void OnNewNotification(double start, double end) = 0; |
| + virtual void OnNotificationParsed(double start, double end) = 0; |
| // For testing. |
| virtual bool IsBuildAllowed(int builds_targeted) const { return false; } |
| virtual int CurrentPlatform() const { return PLATFORM_NONE; } |
| }; |
| - explicit NotificationPromo(PrefService* prefs, Delegate* delegate); |
| + // Static factory for creating new notification promos. |
| + static NotificationPromo* Factory(Profile* profile, Delegate* delegate); |
|
achuithb
2011/11/27 07:48:26
I think Create is more common than Factory in the
Cait (Slow)
2011/11/28 19:06:25
Done.
|
|
achuithb
2011/11/27 07:48:26
delete unnecessary newline please.
Cait (Slow)
2011/11/28 19:06:25
Done.
|
| + |
| // Initialize from json/prefs. |
| - void InitFromJson(const base::DictionaryValue& json); |
| + void InitFromJson(const base::DictionaryValue& json, bool do_cookie_check); |
| void InitFromPrefs(); |
| // Can this promo be shown? |
| @@ -51,6 +61,10 @@ |
| static void RegisterUserPrefs(PrefService* prefs); |
| private: |
| + friend class base::RefCountedThreadSafe<NotificationPromo>; |
| + NotificationPromo(Profile* profile, Delegate* delegate); |
| + virtual ~NotificationPromo(); |
| + |
| // For testing. |
| friend class NotificationPromoTestDelegate; |
| FRIEND_TEST_ALL_PREFIXES(PromoResourceServiceTest, GetNextQuestionValueTest); |
| @@ -70,6 +84,13 @@ |
| // different groups. |
| static const int kMaxGroupSize = 99; |
| + // Flags for feature_mask_. |
| + enum FEATURE { |
| + NO_FEATURE = 0, |
| + FEATURE_GPLUS = 1, |
| + }; |
| + |
|
achuithb
2011/11/27 07:48:26
remove unnecessary newline please.
Cait (Slow)
2011/11/28 19:06:25
Done.
|
| + |
| // Parse the answers array element. Set the data members of this instance |
| // and trigger OnNewNotification callback if necessary. |
| void Parse(const base::DictionaryValue* dict); |
| @@ -80,11 +101,21 @@ |
| // Check if this promo notification is new based on start/end times, |
| // and trigger events accordingly. |
| - void CheckForNewNotification(); |
| + void CheckForNewNotification(bool found_cookie); |
| // Actions on receiving a new promo notification. |
| void OnNewNotification(); |
| + // Async method to get cookies from GPlus url. Used to check if user is |
| + // logged in to GPlus. |
| + void GetCookies(net::URLRequestContextGetter* getter); |
| + |
| + // Callback for GetCookies. |
| + void GetCookiesCallback(const std::string& cookies); |
| + |
| + // Parse cookies in search of a SID= value. |
| + bool CheckForGPlusCookie(const std::string& cookies); |
|
achuithb
2011/11/27 07:48:26
Please make this function static.
Cait (Slow)
2011/11/28 19:06:25
Done.
|
| + |
| // Create a new promo notification group. |
| static int NewGroup(); |
| @@ -110,6 +141,7 @@ |
| // For testing. |
| bool operator==(const NotificationPromo& other) const; |
| + Profile* profile_; |
| PrefService* prefs_; |
| Delegate* delegate_; |
| @@ -121,11 +153,13 @@ |
| int max_group_; |
| int max_views_; |
| int platform_; |
| + int feature_mask_; |
| int group_; |
| int views_; |
| std::string text_; |
| bool closed_; |
| + bool gplus_; |
| DISALLOW_COPY_AND_ASSIGN(NotificationPromo); |
| }; |