| OLD | NEW |
| 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 Loading... |
| 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 void MigrateOldPrefs(); |
| 111 |
| 105 PrefService* local_state_; | 112 PrefService* local_state_; |
| 106 | 113 |
| 107 PromoType promo_type_; | 114 PromoType promo_type_; |
| 108 std::string promo_text_; | 115 std::string promo_text_; |
| 109 | 116 |
| 110 std::unique_ptr<const base::DictionaryValue> promo_payload_; | 117 std::unique_ptr<const base::DictionaryValue> promo_payload_; |
| 111 | 118 |
| 112 double start_; | 119 double start_; |
| 113 double end_; | 120 double end_; |
| 114 int promo_id_; | 121 int promo_id_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 125 | 132 |
| 126 int views_; | 133 int views_; |
| 127 bool closed_; | 134 bool closed_; |
| 128 | 135 |
| 129 DISALLOW_COPY_AND_ASSIGN(NotificationPromo); | 136 DISALLOW_COPY_AND_ASSIGN(NotificationPromo); |
| 130 }; | 137 }; |
| 131 | 138 |
| 132 } // namespace ios | 139 } // namespace ios |
| 133 | 140 |
| 134 #endif // IOS_CHROME_BROWSER_NOTIFICATION_PROMO_H_ | 141 #endif // IOS_CHROME_BROWSER_NOTIFICATION_PROMO_H_ |
| OLD | NEW |