| 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 #include "chrome/browser/banners/app_banner_settings_helper.h" | 5 #include "chrome/browser/banners/app_banner_settings_helper.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // Keys to use when storing BannerEvent structs. | 65 // Keys to use when storing BannerEvent structs. |
| 66 const char kBannerTimeKey[] = "time"; | 66 const char kBannerTimeKey[] = "time"; |
| 67 const char kBannerEngagementKey[] = "engagement"; | 67 const char kBannerEngagementKey[] = "engagement"; |
| 68 | 68 |
| 69 // Keys to use when querying the variations params. | 69 // Keys to use when querying the variations params. |
| 70 const char kBannerParamsKey[] = "AppBannerTriggering"; | 70 const char kBannerParamsKey[] = "AppBannerTriggering"; |
| 71 const char kBannerParamsDirectKey[] = "direct"; | 71 const char kBannerParamsDirectKey[] = "direct"; |
| 72 const char kBannerParamsIndirectKey[] = "indirect"; | 72 const char kBannerParamsIndirectKey[] = "indirect"; |
| 73 const char kBannerParamsTotalKey[] = "total"; | 73 const char kBannerParamsTotalKey[] = "total"; |
| 74 const char kBannerParamsMinutesKey[] = "minutes"; | 74 const char kBannerParamsMinutesKey[] = "minutes"; |
| 75 const char kBannerParamsEngagementTotalKey[] = "site_engagement_total"; |
| 75 const char kBannerSiteEngagementParamsKey[] = "use_site_engagement"; | 76 const char kBannerSiteEngagementParamsKey[] = "use_site_engagement"; |
| 76 | 77 |
| 77 // Engagement weight assigned to direct and indirect navigations. | 78 // Engagement weight assigned to direct and indirect navigations. |
| 78 // By default, a direct navigation is a page visit via ui::PAGE_TRANSITION_TYPED | 79 // By default, a direct navigation is a page visit via ui::PAGE_TRANSITION_TYPED |
| 79 // or ui::PAGE_TRANSITION_GENERATED. | 80 // or ui::PAGE_TRANSITION_GENERATED. |
| 80 double gDirectNavigationEngagement = kDefaultDirectNavigationEngagement; | 81 double gDirectNavigationEngagement = kDefaultDirectNavigationEngagement; |
| 81 double gIndirectNavigationEnagagement = kDefaultIndirectNavigationEngagement; | 82 double gIndirectNavigationEnagagement = kDefaultIndirectNavigationEngagement; |
| 82 | 83 |
| 83 // Number of minutes between visits that will trigger a could show banner event. | 84 // Number of minutes between visits that will trigger a could show banner event. |
| 84 // Defaults to the number of minutes in a day. | 85 // Defaults to the number of minutes in a day. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return gDirectNavigationEngagement; | 127 return gDirectNavigationEngagement; |
| 127 } else { | 128 } else { |
| 128 return gIndirectNavigationEnagagement; | 129 return gIndirectNavigationEnagagement; |
| 129 } | 130 } |
| 130 } | 131 } |
| 131 | 132 |
| 132 // Queries variations for the maximum site engagement score required to trigger | 133 // Queries variations for the maximum site engagement score required to trigger |
| 133 // the banner showing. | 134 // the banner showing. |
| 134 void UpdateSiteEngagementToTrigger() { | 135 void UpdateSiteEngagementToTrigger() { |
| 135 std::string total_param = variations::GetVariationParamValue( | 136 std::string total_param = variations::GetVariationParamValue( |
| 136 kBannerParamsKey, kBannerParamsTotalKey); | 137 kBannerParamsKey, kBannerParamsEngagementTotalKey); |
| 137 | 138 |
| 138 if (!total_param.empty()) { | 139 if (!total_param.empty()) { |
| 139 double total_engagement = -1; | 140 double total_engagement = -1; |
| 140 | 141 |
| 141 if (base::StringToDouble(total_param, &total_engagement) && | 142 if (base::StringToDouble(total_param, &total_engagement) && |
| 142 total_engagement > 0) { | 143 total_engagement > 0) { |
| 143 AppBannerSettingsHelper::SetTotalEngagementToTrigger(total_engagement); | 144 AppBannerSettingsHelper::SetTotalEngagementToTrigger(total_engagement); |
| 144 } | 145 } |
| 145 } | 146 } |
| 146 } | 147 } |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 return true; | 603 return true; |
| 603 } | 604 } |
| 604 | 605 |
| 605 // Assume any value which is not "0" or "false" indicates that we should use | 606 // Assume any value which is not "0" or "false" indicates that we should use |
| 606 // site engagement. | 607 // site engagement. |
| 607 std::string param = variations::GetVariationParamValue( | 608 std::string param = variations::GetVariationParamValue( |
| 608 kBannerParamsKey, kBannerSiteEngagementParamsKey); | 609 kBannerParamsKey, kBannerSiteEngagementParamsKey); |
| 609 | 610 |
| 610 return (!param.empty() && param != "0" && param != "false"); | 611 return (!param.empty() && param != "0" && param != "false"); |
| 611 } | 612 } |
| OLD | NEW |