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

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

Issue 2094523002: Add migration from old to new NTP Promo pref structure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: edits Created 4 years, 5 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
« no previous file with comments | « no previous file | ios/chrome/browser/notification_promo.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 IOS_CHROME_BROWSER_NOTIFICATION_PROMO_H_ 5 #ifndef IOS_CHROME_BROWSER_NOTIFICATION_PROMO_H_
6 #define IOS_CHROME_BROWSER_NOTIFICATION_PROMO_H_ 6 #define IOS_CHROME_BROWSER_NOTIFICATION_PROMO_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 // Register preferences. 81 // Register preferences.
82 static void RegisterPrefs(PrefRegistrySimple* registry); 82 static void RegisterPrefs(PrefRegistrySimple* registry);
83 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 83 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
84 static void MigrateUserPrefs(PrefService* user_prefs); 84 static void MigrateUserPrefs(PrefService* user_prefs);
85 85
86 private: 86 private:
87 // For testing. 87 // For testing.
88 friend class NotificationPromoTest; 88 friend class NotificationPromoTest;
89 89
90 // Flush data members to prefs for storage. 90 // Flush data from instance variables to prefs for storage.
91 void WritePrefs(); 91 void WritePrefs();
92 92
93 // Flush given parameters to prefs for storage.
94 void WritePrefs(int promo_id, double first_view_time, int views, bool closed);
95
93 // Tests views_ against max_views_. 96 // Tests views_ against max_views_.
94 // When max_views_ is 0, we don't cap the number of views. 97 // When max_views_ is 0, we don't cap the number of views.
95 bool ExceedsMaxViews() const; 98 bool ExceedsMaxViews() const;
96 99
97 // Tests |first_view_time_| + |max_seconds_| and -now(). 100 // Tests |first_view_time_| + |max_seconds_| and -now().
98 // When either is 0, we don't cap the number of seconds. 101 // When either is 0, we don't cap the number of seconds.
99 bool ExceedsMaxSeconds() const; 102 bool ExceedsMaxSeconds() const;
100 103
101 // Returns whether the parameter associated with |param_name| is inside the 104 // Returns whether the parameter associated with |param_name| is inside the
102 // payload. 105 // payload.
103 bool IsPayloadParam(const std::string& param_name) const; 106 bool IsPayloadParam(const std::string& param_name) const;
104 107
108 // Transition data saved in old prefs structure to new structure that supports
109 // storing multiple promos.
110 // TODO(crbug.com/623726) Remove this method when migration is no longer
111 // needed as most users have been upgraded to the new pref structure.
112 void MigrateOldPrefs();
113
105 PrefService* local_state_; 114 PrefService* local_state_;
106 115
107 PromoType promo_type_; 116 PromoType promo_type_;
108 std::string promo_text_; 117 std::string promo_text_;
109 118
110 std::unique_ptr<const base::DictionaryValue> promo_payload_; 119 std::unique_ptr<const base::DictionaryValue> promo_payload_;
111 120
112 double start_; 121 double start_;
113 double end_; 122 double end_;
114 int promo_id_; 123 int promo_id_;
(...skipping 10 matching lines...) Expand all
125 134
126 int views_; 135 int views_;
127 bool closed_; 136 bool closed_;
128 137
129 DISALLOW_COPY_AND_ASSIGN(NotificationPromo); 138 DISALLOW_COPY_AND_ASSIGN(NotificationPromo);
130 }; 139 };
131 140
132 } // namespace ios 141 } // namespace ios
133 142
134 #endif // IOS_CHROME_BROWSER_NOTIFICATION_PROMO_H_ 143 #endif // IOS_CHROME_BROWSER_NOTIFICATION_PROMO_H_
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/notification_promo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698