| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // Keys to use when storing BannerEvent structs. | 71 // Keys to use when storing BannerEvent structs. |
| 72 const char kBannerTimeKey[] = "time"; | 72 const char kBannerTimeKey[] = "time"; |
| 73 const char kBannerEngagementKey[] = "engagement"; | 73 const char kBannerEngagementKey[] = "engagement"; |
| 74 | 74 |
| 75 // Keys to use when querying the variations params. | 75 // Keys to use when querying the variations params. |
| 76 const char kBannerParamsKey[] = "AppBannerTriggering"; | 76 const char kBannerParamsKey[] = "AppBannerTriggering"; |
| 77 const char kBannerParamsDirectKey[] = "direct"; | 77 const char kBannerParamsDirectKey[] = "direct"; |
| 78 const char kBannerParamsIndirectKey[] = "indirect"; | 78 const char kBannerParamsIndirectKey[] = "indirect"; |
| 79 const char kBannerParamsTotalKey[] = "total"; | 79 const char kBannerParamsTotalKey[] = "total"; |
| 80 const char kBannerParamsMinutesKey[] = "minutes"; | 80 const char kBannerParamsMinutesKey[] = "minutes"; |
| 81 const char kBannerParamsEngagementTotalKey[] = "site_engagement_total"; |
| 81 const char kBannerSiteEngagementParamsKey[] = "use_site_engagement"; | 82 const char kBannerSiteEngagementParamsKey[] = "use_site_engagement"; |
| 82 | 83 |
| 83 // Engagement weight assigned to direct and indirect navigations. | 84 // Engagement weight assigned to direct and indirect navigations. |
| 84 // By default, a direct navigation is a page visit via ui::PAGE_TRANSITION_TYPED | 85 // By default, a direct navigation is a page visit via ui::PAGE_TRANSITION_TYPED |
| 85 // or ui::PAGE_TRANSITION_GENERATED. | 86 // or ui::PAGE_TRANSITION_GENERATED. |
| 86 double gDirectNavigationEngagement = kDefaultDirectNavigationEngagement; | 87 double gDirectNavigationEngagement = kDefaultDirectNavigationEngagement; |
| 87 double gIndirectNavigationEnagagement = kDefaultIndirectNavigationEngagement; | 88 double gIndirectNavigationEnagagement = kDefaultIndirectNavigationEngagement; |
| 88 | 89 |
| 89 // Number of minutes between visits that will trigger a could show banner event. | 90 // Number of minutes between visits that will trigger a could show banner event. |
| 90 // Defaults to the number of minutes in a day. | 91 // Defaults to the number of minutes in a day. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 return gDirectNavigationEngagement; | 133 return gDirectNavigationEngagement; |
| 133 } else { | 134 } else { |
| 134 return gIndirectNavigationEnagagement; | 135 return gIndirectNavigationEnagagement; |
| 135 } | 136 } |
| 136 } | 137 } |
| 137 | 138 |
| 138 // Queries variations for the maximum site engagement score required to trigger | 139 // Queries variations for the maximum site engagement score required to trigger |
| 139 // the banner showing. | 140 // the banner showing. |
| 140 void UpdateSiteEngagementToTrigger() { | 141 void UpdateSiteEngagementToTrigger() { |
| 141 std::string total_param = variations::GetVariationParamValue( | 142 std::string total_param = variations::GetVariationParamValue( |
| 142 kBannerParamsKey, kBannerParamsTotalKey); | 143 kBannerParamsKey, kBannerParamsEngagementTotalKey); |
| 143 | 144 |
| 144 if (!total_param.empty()) { | 145 if (!total_param.empty()) { |
| 145 double total_engagement = -1; | 146 double total_engagement = -1; |
| 146 | 147 |
| 147 if (base::StringToDouble(total_param, &total_engagement) && | 148 if (base::StringToDouble(total_param, &total_engagement) && |
| 148 total_engagement > 0) { | 149 total_engagement > 0) { |
| 149 AppBannerSettingsHelper::SetTotalEngagementToTrigger(total_engagement); | 150 AppBannerSettingsHelper::SetTotalEngagementToTrigger(total_engagement); |
| 150 } | 151 } |
| 151 } | 152 } |
| 152 } | 153 } |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 return true; | 648 return true; |
| 648 } | 649 } |
| 649 | 650 |
| 650 // Assume any value which is not "0" or "false" indicates that we should use | 651 // Assume any value which is not "0" or "false" indicates that we should use |
| 651 // site engagement. | 652 // site engagement. |
| 652 std::string param = variations::GetVariationParamValue( | 653 std::string param = variations::GetVariationParamValue( |
| 653 kBannerParamsKey, kBannerSiteEngagementParamsKey); | 654 kBannerParamsKey, kBannerSiteEngagementParamsKey); |
| 654 | 655 |
| 655 return (!param.empty() && param != "0" && param != "false"); | 656 return (!param.empty() && param != "0" && param != "false"); |
| 656 } | 657 } |
| OLD | NEW |