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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 327 |
328 base::ListValue* could_show_list = nullptr; | 328 base::ListValue* could_show_list = nullptr; |
329 if (!app_dict->GetList(event_key, &could_show_list)) { | 329 if (!app_dict->GetList(event_key, &could_show_list)) { |
330 could_show_list = new base::ListValue(); | 330 could_show_list = new base::ListValue(); |
331 app_dict->Set(event_key, base::WrapUnique(could_show_list)); | 331 app_dict->Set(event_key, base::WrapUnique(could_show_list)); |
332 } | 332 } |
333 | 333 |
334 // Trim any items that are older than we should care about. For comparisons | 334 // Trim any items that are older than we should care about. For comparisons |
335 // the times are converted to local dates. | 335 // the times are converted to local dates. |
336 base::Time date = BucketTimeToResolution(time, gMinimumMinutesBetweenVisits); | 336 base::Time date = BucketTimeToResolution(time, gMinimumMinutesBetweenVisits); |
337 base::ValueVector::iterator it = could_show_list->begin(); | 337 for (auto it = could_show_list->begin(); it != could_show_list->end();) { |
338 while (it != could_show_list->end()) { | |
339 if ((*it)->IsType(base::Value::TYPE_DICTIONARY)) { | 338 if ((*it)->IsType(base::Value::TYPE_DICTIONARY)) { |
340 base::DictionaryValue* internal_value; | 339 base::DictionaryValue* internal_value; |
341 double internal_date; | 340 double internal_date; |
342 (*it)->GetAsDictionary(&internal_value); | 341 (*it)->GetAsDictionary(&internal_value); |
343 | 342 |
344 if (internal_value->GetDouble(kBannerTimeKey, &internal_date)) { | 343 if (internal_value->GetDouble(kBannerTimeKey, &internal_date)) { |
345 base::Time other_date = | 344 base::Time other_date = |
346 BucketTimeToResolution(base::Time::FromInternalValue(internal_date), | 345 BucketTimeToResolution(base::Time::FromInternalValue(internal_date), |
347 gMinimumMinutesBetweenVisits); | 346 gMinimumMinutesBetweenVisits); |
348 if (other_date == date) { | 347 if (other_date == date) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 base::DictionaryValue* app_dict = | 468 base::DictionaryValue* app_dict = |
470 GetAppDict(origin_dict.get(), package_name_or_start_url); | 469 GetAppDict(origin_dict.get(), package_name_or_start_url); |
471 if (!app_dict) | 470 if (!app_dict) |
472 return result; | 471 return result; |
473 | 472 |
474 std::string event_key(kBannerEventKeys[APP_BANNER_EVENT_COULD_SHOW]); | 473 std::string event_key(kBannerEventKeys[APP_BANNER_EVENT_COULD_SHOW]); |
475 base::ListValue* could_show_list = nullptr; | 474 base::ListValue* could_show_list = nullptr; |
476 if (!app_dict->GetList(event_key, &could_show_list)) | 475 if (!app_dict->GetList(event_key, &could_show_list)) |
477 return result; | 476 return result; |
478 | 477 |
479 for (auto value : *could_show_list) { | 478 for (const auto& value : *could_show_list) { |
480 if (value->IsType(base::Value::TYPE_DICTIONARY)) { | 479 if (value->IsType(base::Value::TYPE_DICTIONARY)) { |
481 base::DictionaryValue* internal_value; | 480 base::DictionaryValue* internal_value; |
482 double internal_date = 0; | 481 double internal_date = 0; |
483 value->GetAsDictionary(&internal_value); | 482 value->GetAsDictionary(&internal_value); |
484 double engagement = 0; | 483 double engagement = 0; |
485 | 484 |
486 if (internal_value->GetDouble(kBannerTimeKey, &internal_date) && | 485 if (internal_value->GetDouble(kBannerTimeKey, &internal_date) && |
487 internal_value->GetDouble(kBannerEngagementKey, &engagement)) { | 486 internal_value->GetDouble(kBannerEngagementKey, &engagement)) { |
488 base::Time date = base::Time::FromInternalValue(internal_date); | 487 base::Time date = base::Time::FromInternalValue(internal_date); |
489 result.push_back({date, engagement}); | 488 result.push_back({date, engagement}); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 // 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 |
613 // experiment, otherwise the banner and site engagement banner experiments | 612 // experiment, otherwise the banner and site engagement banner experiments |
614 // will conflict. | 613 // will conflict. |
615 // | 614 // |
616 // 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 |
617 // to have experiments which enable multiple features under site engagement. | 616 // to have experiments which enable multiple features under site engagement. |
618 std::string param = variations::GetVariationParamValue( | 617 std::string param = variations::GetVariationParamValue( |
619 SiteEngagementService::kEngagementParams, kBannerSiteEngagementParamsKey); | 618 SiteEngagementService::kEngagementParams, kBannerSiteEngagementParamsKey); |
620 return !param.empty(); | 619 return !param.empty(); |
621 } | 620 } |
OLD | NEW |