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

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

Issue 8520009: Only show G+ promo for users logged into G+ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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/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,
+ bool new_notification) = 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* Create(Profile* profile, Delegate* delegate);
// 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);
@@ -65,6 +79,12 @@
PLATFORM_ALL = (1 << 4) -1,
};
+ // Flags for feature_mask_.
+ enum Feature {
+ NO_FEATURE = 0,
+ FEATURE_GPLUS = 1,
+ };
+
// Users are randomly assigned to one of kMaxGroupSize + 1 buckets, in order
// to be able to roll out promos slowly, or display different promos to
// different groups.
@@ -75,16 +95,26 @@
void Parse(const base::DictionaryValue* dict);
// Set promo notification params from a question string, which is of the form
- // <build_type>:<time_slice>:<max_group>:<max_views>
+ // <build_type>:<time_slice>:<max_group>:<max_views>:<platform>:<feature_mask>
void ParseParams(const base::DictionaryValue* dict);
// 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.
+ static bool CheckForGPlusCookie(const std::string& cookies);
+
// Create a new promo notification group.
static int NewGroup();
@@ -110,6 +140,7 @@
// For testing.
bool operator==(const NotificationPromo& other) const;
+ Profile* profile_;
PrefService* prefs_;
Delegate* delegate_;
@@ -121,11 +152,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);
};
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_page_handler.cc ('k') | chrome/browser/web_resource/notification_promo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698