| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ | 5 #ifndef CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ |
| 6 #define CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ | 6 #define CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // The desired effect is to have banners appear once a user has demonstrated | 33 // The desired effect is to have banners appear once a user has demonstrated |
| 34 // an ongoing relationship with the app, and not to pester the user too much. | 34 // an ongoing relationship with the app, and not to pester the user too much. |
| 35 // | 35 // |
| 36 // For most events only the last event is recorded. The exception are the | 36 // For most events only the last event is recorded. The exception are the |
| 37 // could show events. For these a list of the events is maintained. At most | 37 // could show events. For these a list of the events is maintained. At most |
| 38 // one event is stored per day, and events outside the window the heuristic | 38 // one event is stored per day, and events outside the window the heuristic |
| 39 // uses are discarded. Local times are used to enforce these rules, to ensure | 39 // uses are discarded. Local times are used to enforce these rules, to ensure |
| 40 // what we count as a day matches what the user perceives to be days. | 40 // what we count as a day matches what the user perceives to be days. |
| 41 class AppBannerSettingsHelper { | 41 class AppBannerSettingsHelper { |
| 42 public: | 42 public: |
| 43 // An enum for determining the title to use for the add to homescreen / app |
| 44 // banner functionality. |
| 45 // A Java counterpart will be generated for this enum. |
| 46 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.banners |
| 47 enum LanguageOption { |
| 48 LANGUAGE_OPTION_DEFAULT = 0, |
| 49 LANGUAGE_OPTION_MIN = LANGUAGE_OPTION_DEFAULT, |
| 50 LANGUAGE_OPTION_ADD = 1, |
| 51 LANGUAGE_OPTION_INSTALL = 2, |
| 52 LANGUAGE_OPTION_MAX = LANGUAGE_OPTION_INSTALL, |
| 53 }; |
| 54 |
| 43 // TODO(mariakhomenko): Rename events to reflect that they are used in more | 55 // TODO(mariakhomenko): Rename events to reflect that they are used in more |
| 44 // contexts now. | 56 // contexts now. |
| 45 enum AppBannerEvent { | 57 enum AppBannerEvent { |
| 46 APP_BANNER_EVENT_COULD_SHOW, | 58 APP_BANNER_EVENT_COULD_SHOW, |
| 47 APP_BANNER_EVENT_DID_SHOW, | 59 APP_BANNER_EVENT_DID_SHOW, |
| 48 APP_BANNER_EVENT_DID_BLOCK, | 60 APP_BANNER_EVENT_DID_BLOCK, |
| 49 APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, | 61 APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, |
| 50 APP_BANNER_EVENT_NUM_EVENTS, | 62 APP_BANNER_EVENT_NUM_EVENTS, |
| 51 }; | 63 }; |
| 52 | 64 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // trigger to their default values. | 179 // trigger to their default values. |
| 168 static void SetDefaultParameters(); | 180 static void SetDefaultParameters(); |
| 169 | 181 |
| 170 // Bucket a given time to the given resolution in local time. | 182 // Bucket a given time to the given resolution in local time. |
| 171 static base::Time BucketTimeToResolution(base::Time time, | 183 static base::Time BucketTimeToResolution(base::Time time, |
| 172 unsigned int minutes); | 184 unsigned int minutes); |
| 173 | 185 |
| 174 // Updates all values from field trial. | 186 // Updates all values from field trial. |
| 175 static void UpdateFromFieldTrial(); | 187 static void UpdateFromFieldTrial(); |
| 176 | 188 |
| 189 // Queries variations to determine which language option should be used for |
| 190 // app banners and add to homescreen. |
| 191 static LanguageOption GetHomescreenLanguageOption(); |
| 192 |
| 177 // Returns true if the app banner trigger condition should use the site | 193 // Returns true if the app banner trigger condition should use the site |
| 178 // engagement score instead of the navigation-based heuristic. | 194 // engagement score instead of the navigation-based heuristic. |
| 179 static bool ShouldUseSiteEngagementScore(); | 195 static bool ShouldUseSiteEngagementScore(); |
| 180 | 196 |
| 181 private: | 197 private: |
| 182 DISALLOW_IMPLICIT_CONSTRUCTORS(AppBannerSettingsHelper); | 198 DISALLOW_IMPLICIT_CONSTRUCTORS(AppBannerSettingsHelper); |
| 183 }; | 199 }; |
| 184 | 200 |
| 185 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ | 201 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ |
| OLD | NEW |