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

Side by Side Diff: chrome/browser/web_resource/notification_promo.h

Issue 10860025: Remove promotion-type-specific JSON handling from NotificationPromo (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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 unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_WEB_RESOURCE_NOTIFICATION_PROMO_H_ 5 #ifndef CHROME_BROWSER_WEB_RESOURCE_NOTIFICATION_PROMO_H_
6 #define CHROME_BROWSER_WEB_RESOURCE_NOTIFICATION_PROMO_H_ 6 #define CHROME_BROWSER_WEB_RESOURCE_NOTIFICATION_PROMO_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // Helpers for NewTabPageHandler. 52 // Helpers for NewTabPageHandler.
53 // Mark the promo as closed when the user dismisses it. 53 // Mark the promo as closed when the user dismisses it.
54 static void HandleClosed(Profile* profile, PromoType promo_type); 54 static void HandleClosed(Profile* profile, PromoType promo_type);
55 // Mark the promo has having been viewed. This returns true if views 55 // Mark the promo has having been viewed. This returns true if views
56 // exceeds the maximum allowed. 56 // exceeds the maximum allowed.
57 static bool HandleViewed(Profile* profile, PromoType promo_type); 57 static bool HandleViewed(Profile* profile, PromoType promo_type);
58 58
59 bool new_notification() const { return new_notification_; } 59 bool new_notification() const { return new_notification_; }
60 60
61 const std::string& promo_text() const { return promo_text_; } 61 const std::string& promo_text() const { return promo_text_; }
62 #if defined(OS_ANDROID) || defined(OS_IOS) 62 PromoType promo_type() const { return promo_type_; }
63 const std::string& promo_text_long() const { return promo_text_long_; } 63 const base::DictionaryValue* promo_payload() const {
64 const std::string& promo_action_type() const { return promo_action_type_; } 64 return promo_payload_.get();
65 const base::ListValue* promo_action_args() const {
66 return promo_action_args_.get();
67 } 65 }
68 #endif // defined(OS_ANDROID) || defined(OS_IOS)
69 66
70 // Register preferences. 67 // Register preferences.
71 static void RegisterUserPrefs(PrefService* prefs); 68 static void RegisterUserPrefs(PrefService* prefs);
72 69
73 private: 70 private:
74 // For testing. 71 // For testing.
75 friend class NotificationPromoTest; 72 friend class NotificationPromoTest;
73 friend class NotificationPromoMobileNtpTest;
76 74
77 // Check if this promo notification is new based on start/end times, 75 // Check if this promo notification is new based on start/end times,
78 // and trigger events accordingly. 76 // and trigger events accordingly.
79 void CheckForNewNotification(); 77 void CheckForNewNotification();
80 78
81 // Actions on receiving a new promo notification. 79 // Actions on receiving a new promo notification.
82 void OnNewNotification(); 80 void OnNewNotification();
83 81
84 // Flush data members to prefs for storage. 82 // Flush data members to prefs for storage.
85 void WritePrefs(); 83 void WritePrefs();
86 84
87 // Tests group_ against max_group_. 85 // Tests group_ against max_group_.
88 // When max_group_ is 0, all groups pass. 86 // When max_group_ is 0, all groups pass.
89 bool ExceedsMaxGroup() const; 87 bool ExceedsMaxGroup() const;
90 88
91 // Tests views_ against max_views_. 89 // Tests views_ against max_views_.
92 // When max_views_ is 0, we don't cap the number of views. 90 // When max_views_ is 0, we don't cap the number of views.
93 bool ExceedsMaxViews() const; 91 bool ExceedsMaxViews() const;
94 92
95 // True if this promo is not targeted to G+ users, or if this is a G+ user. 93 // True if this promo is not targeted to G+ users, or if this is a G+ user.
96 bool IsGPlusRequired() const; 94 bool IsGPlusRequired() const;
97 95
98 Profile* profile_; 96 Profile* profile_;
99 PrefService* prefs_; 97 PrefService* prefs_;
100 98
101 PromoType promo_type_; 99 PromoType promo_type_;
102 std::string promo_text_; 100 std::string promo_text_;
103 #if defined(OS_ANDROID) || defined(OS_IOS) 101 scoped_ptr<const base::DictionaryValue> promo_payload_;
achuithb 2012/08/17 22:55:12 Let's add a comment here saying that this is curre
aruslan 2012/08/20 15:36:53 Done.
104 std::string promo_text_long_;
105 std::string promo_action_type_;
106 scoped_ptr<base::ListValue> promo_action_args_;
107 #endif // defined(OS_ANDROID) || defined(OS_IOS)
108 102
109 double start_; 103 double start_;
110 double end_; 104 double end_;
111 105
112 int num_groups_; 106 int num_groups_;
113 int initial_segment_; 107 int initial_segment_;
114 int increment_; 108 int increment_;
115 int time_slice_; 109 int time_slice_;
116 int max_group_; 110 int max_group_;
117 111
118 // When max_views_ is 0, we don't cap the number of views. 112 // When max_views_ is 0, we don't cap the number of views.
119 int max_views_; 113 int max_views_;
120 114
121 int group_; 115 int group_;
122 int views_; 116 int views_;
123 bool closed_; 117 bool closed_;
124 118
125 bool gplus_required_; 119 bool gplus_required_;
126 120
127 bool new_notification_; 121 bool new_notification_;
128 122
129 DISALLOW_COPY_AND_ASSIGN(NotificationPromo); 123 DISALLOW_COPY_AND_ASSIGN(NotificationPromo);
130 }; 124 };
131 125
132 #endif // CHROME_BROWSER_WEB_RESOURCE_NOTIFICATION_PROMO_H_ 126 #endif // CHROME_BROWSER_WEB_RESOURCE_NOTIFICATION_PROMO_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/web_resource/notification_promo.cc » ('j') | chrome/browser/web_resource/notification_promo.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698