OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/ntp_snippets/remote/scheduling_remote_suggestions_provider.
h" | 5 #include "components/ntp_snippets/remote/scheduling_remote_suggestions_provider.
h" |
6 | 6 |
7 #include <random> | 7 #include <random> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 } | 502 } |
503 | 503 |
504 std::vector<std::string> tokens = base::SplitString( | 504 std::vector<std::string> tokens = base::SplitString( |
505 param_value, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 505 param_value, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
506 if (tokens.empty()) { | 506 if (tokens.empty()) { |
507 return GetDefaultEnabledTriggerTypes(); | 507 return GetDefaultEnabledTriggerTypes(); |
508 } | 508 } |
509 | 509 |
510 std::set<TriggerType> enabled_types; | 510 std::set<TriggerType> enabled_types; |
511 for (const auto& token : tokens) { | 511 for (const auto& token : tokens) { |
512 auto it = std::find(std::begin(kTriggerTypeNames), | 512 auto** it = std::find(std::begin(kTriggerTypeNames), |
513 std::end(kTriggerTypeNames), token); | 513 std::end(kTriggerTypeNames), token); |
514 if (it == std::end(kTriggerTypeNames)) { | 514 if (it == std::end(kTriggerTypeNames)) { |
515 DLOG(WARNING) << "Failed to parse variation param " | 515 DLOG(WARNING) << "Failed to parse variation param " |
516 << kTriggerTypesParamName << " with string value " | 516 << kTriggerTypesParamName << " with string value " |
517 << param_value | 517 << param_value |
518 << " into a comma-separated list of keywords. " | 518 << " into a comma-separated list of keywords. " |
519 << "Unknown token " << token | 519 << "Unknown token " << token |
520 << " found. Falling back to default value."; | 520 << " found. Falling back to default value."; |
521 return GetDefaultEnabledTriggerTypes(); | 521 return GetDefaultEnabledTriggerTypes(); |
522 } | 522 } |
523 | 523 |
524 // Add the enabled type represented by |token| into the result set. | 524 // Add the enabled type represented by |token| into the result set. |
525 enabled_types.insert( | 525 enabled_types.insert( |
526 static_cast<TriggerType>(it - std::begin(kTriggerTypeNames))); | 526 static_cast<TriggerType>(it - std::begin(kTriggerTypeNames))); |
527 } | 527 } |
528 return enabled_types; | 528 return enabled_types; |
529 } | 529 } |
530 | 530 |
531 std::set<SchedulingRemoteSuggestionsProvider::TriggerType> | 531 std::set<SchedulingRemoteSuggestionsProvider::TriggerType> |
532 SchedulingRemoteSuggestionsProvider::GetDefaultEnabledTriggerTypes() { | 532 SchedulingRemoteSuggestionsProvider::GetDefaultEnabledTriggerTypes() { |
533 return {TriggerType::PERSISTENT_SCHEDULER_WAKE_UP, TriggerType::NTP_OPENED, | 533 return {TriggerType::PERSISTENT_SCHEDULER_WAKE_UP, TriggerType::NTP_OPENED, |
534 TriggerType::BROWSER_FOREGROUNDED}; | 534 TriggerType::BROWSER_FOREGROUNDED}; |
535 } | 535 } |
536 | 536 |
537 } // namespace ntp_snippets | 537 } // namespace ntp_snippets |
OLD | NEW |