| 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 base::DictionaryValue* app_dict = | 279 base::DictionaryValue* app_dict = |
| 280 GetAppDict(origin_dict.get(), package_name_or_start_url); | 280 GetAppDict(origin_dict.get(), package_name_or_start_url); |
| 281 if (!app_dict) | 281 if (!app_dict) |
| 282 return; | 282 return; |
| 283 | 283 |
| 284 // Dates are stored in their raw form (i.e. not local dates) to be resilient | 284 // Dates are stored in their raw form (i.e. not local dates) to be resilient |
| 285 // to time zone changes. | 285 // to time zone changes. |
| 286 std::string event_key(kBannerEventKeys[event]); | 286 std::string event_key(kBannerEventKeys[event]); |
| 287 app_dict->SetDouble(event_key, time.ToInternalValue()); | 287 app_dict->SetDouble(event_key, time.ToInternalValue()); |
| 288 | 288 |
| 289 settings->SetWebsiteSettingDefaultScope(origin_url, GURL(), | 289 settings->SetWebsiteSettingDefaultScope( |
| 290 CONTENT_SETTINGS_TYPE_APP_BANNER, | 290 origin_url, GURL(), CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), |
| 291 std::string(), origin_dict.release()); | 291 std::move(origin_dict)); |
| 292 | 292 |
| 293 // App banner content settings are lossy, meaning they will not cause the | 293 // App banner content settings are lossy, meaning they will not cause the |
| 294 // prefs to become dirty. This is fine for most events, as if they are lost it | 294 // prefs to become dirty. This is fine for most events, as if they are lost it |
| 295 // just means the user will have to engage a little bit more. However the | 295 // just means the user will have to engage a little bit more. However the |
| 296 // DID_ADD_TO_HOMESCREEN event should always be recorded to prevent | 296 // DID_ADD_TO_HOMESCREEN event should always be recorded to prevent |
| 297 // spamminess. | 297 // spamminess. |
| 298 if (event == APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN) | 298 if (event == APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN) |
| 299 settings->FlushLossyWebsiteSettings(); | 299 settings->FlushLossyWebsiteSettings(); |
| 300 } | 300 } |
| 301 | 301 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 it = could_show_list->Erase(it, nullptr); | 371 it = could_show_list->Erase(it, nullptr); |
| 372 } | 372 } |
| 373 | 373 |
| 374 // Dates are stored in their raw form (i.e. not local dates) to be resilient | 374 // Dates are stored in their raw form (i.e. not local dates) to be resilient |
| 375 // to time zone changes. | 375 // to time zone changes. |
| 376 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 376 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 377 value->SetDouble(kBannerTimeKey, time.ToInternalValue()); | 377 value->SetDouble(kBannerTimeKey, time.ToInternalValue()); |
| 378 value->SetDouble(kBannerEngagementKey, engagement); | 378 value->SetDouble(kBannerEngagementKey, engagement); |
| 379 could_show_list->Append(std::move(value)); | 379 could_show_list->Append(std::move(value)); |
| 380 | 380 |
| 381 settings->SetWebsiteSettingDefaultScope(origin_url, GURL(), | 381 settings->SetWebsiteSettingDefaultScope( |
| 382 CONTENT_SETTINGS_TYPE_APP_BANNER, | 382 origin_url, GURL(), CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), |
| 383 std::string(), origin_dict.release()); | 383 std::move(origin_dict)); |
| 384 } | 384 } |
| 385 | 385 |
| 386 bool AppBannerSettingsHelper::ShouldShowBanner( | 386 bool AppBannerSettingsHelper::ShouldShowBanner( |
| 387 content::WebContents* web_contents, | 387 content::WebContents* web_contents, |
| 388 const GURL& origin_url, | 388 const GURL& origin_url, |
| 389 const std::string& package_name_or_start_url, | 389 const std::string& package_name_or_start_url, |
| 390 base::Time time) { | 390 base::Time time) { |
| 391 // Ignore all checks if the flag to do so is set. | 391 // Ignore all checks if the flag to do so is set. |
| 392 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 392 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 393 switches::kBypassAppBannerEngagementChecks)) { | 393 switches::kBypassAppBannerEngagementChecks)) { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 // must only be active when there is one singular group under the banner | 611 // must only be active when there is one singular group under the banner |
| 612 // experiment, otherwise the banner and site engagement banner experiments | 612 // experiment, otherwise the banner and site engagement banner experiments |
| 613 // will conflict. | 613 // will conflict. |
| 614 // | 614 // |
| 615 // Making the experiment active when a variations key is present allows us | 615 // Making the experiment active when a variations key is present allows us |
| 616 // to have experiments which enable multiple features under site engagement. | 616 // to have experiments which enable multiple features under site engagement. |
| 617 std::string param = variations::GetVariationParamValue( | 617 std::string param = variations::GetVariationParamValue( |
| 618 SiteEngagementService::kEngagementParams, kBannerSiteEngagementParamsKey); | 618 SiteEngagementService::kEngagementParams, kBannerSiteEngagementParamsKey); |
| 619 return !param.empty(); | 619 return !param.empty(); |
| 620 } | 620 } |
| OLD | NEW |