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 "components/omnibox/browser/omnibox_field_trial.h" | 5 #include "components/omnibox/browser/omnibox_field_trial.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
524 if (value_str.empty()) | 524 if (value_str.empty()) |
525 return EMPHASIZE_NEVER; | 525 return EMPHASIZE_NEVER; |
526 // This is a best-effort conversion; we trust the hand-crafted parameters | 526 // This is a best-effort conversion; we trust the hand-crafted parameters |
527 // downloaded from the server to be perfect. There's no need for handle | 527 // downloaded from the server to be perfect. There's no need for handle |
528 // errors smartly. | 528 // errors smartly. |
529 int value; | 529 int value; |
530 base::StringToInt(value_str, &value); | 530 base::StringToInt(value_str, &value); |
531 return static_cast<EmphasizeTitlesCondition>(value); | 531 return static_cast<EmphasizeTitlesCondition>(value); |
532 } | 532 } |
533 | 533 |
534 // static | |
535 bool OmniboxFieldTrial::InPhysicalWebZeroSuggestFieldTrial() { | |
536 return variations::GetVariationParamValue( | |
537 kBundledExperimentFieldTrialName, | |
538 kPhysicalWebZeroSuggestRule) == "true"; | |
539 } | |
540 | |
541 // static | |
542 bool OmniboxFieldTrial::InPhysicalWebAfterTypingFieldTrial() { | |
543 return variations::GetVariationParamValue( | |
544 kBundledExperimentFieldTrialName, | |
545 kPhysicalWebAfterTypingRule) == "true"; | |
546 } | |
547 | |
548 // static | |
549 void OmniboxFieldTrial::GetExperimentalPhysicalWebScoringParams( | |
Mark P
2016/12/21 23:21:41
minor comment: I think I find these three separate
mattreynolds
2016/12/22 00:23:40
I switched the base relevance calls to use GetVari
| |
550 PhysicalWebScoringParams* scoring_params) { | |
551 scoring_params->experimental_scoring_enabled = false; | |
552 | |
553 VariationParams params; | |
554 if (!variations::GetVariationParams(kBundledExperimentFieldTrialName, | |
555 ¶ms)) | |
556 return; | |
557 | |
558 VariationParams::const_iterator it = | |
559 params.find(kPhysicalWebExperimentalScoringParam); | |
560 if (it != params.end()) { | |
561 int enabled = 0; | |
562 if (base::StringToInt(it->second, &enabled)) | |
Mark P
2016/12/21 23:21:41
Enabling is an int parameter?
mattreynolds
2016/12/22 00:23:40
Removed
| |
563 scoring_params->experimental_scoring_enabled = (enabled != 0); | |
564 } | |
565 | |
566 it = params.find(kPhysicalWebZeroSuggestBaseRelevanceParam); | |
567 if (it != params.end()) { | |
568 int base_relevance = 0; | |
569 if (base::StringToInt(it->second, &base_relevance)) | |
570 scoring_params->zero_suggest_base_relevance = base_relevance; | |
571 } | |
572 | |
573 it = params.find(kPhysicalWebAfterTypingBaseRelevanceParam); | |
574 if (it != params.end()) { | |
575 int base_relevance = 0; | |
576 if (base::StringToInt(it->second, &base_relevance)) | |
577 scoring_params->after_typing_base_relevance = base_relevance; | |
578 } | |
579 } | |
580 | |
534 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] = | 581 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] = |
535 "OmniboxBundledExperimentV1"; | 582 "OmniboxBundledExperimentV1"; |
536 const char OmniboxFieldTrial::kDisableProvidersRule[] = "DisableProviders"; | 583 const char OmniboxFieldTrial::kDisableProvidersRule[] = "DisableProviders"; |
537 const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] = | 584 const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] = |
538 "ShortcutsScoringMaxRelevance"; | 585 "ShortcutsScoringMaxRelevance"; |
539 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory"; | 586 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory"; |
540 const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType"; | 587 const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType"; |
541 const char OmniboxFieldTrial::kHQPBookmarkValueRule[] = | 588 const char OmniboxFieldTrial::kHQPBookmarkValueRule[] = |
542 "HQPBookmarkValue"; | 589 "HQPBookmarkValue"; |
543 const char OmniboxFieldTrial::kHQPTypedValueRule[] = "HQPTypedValue"; | 590 const char OmniboxFieldTrial::kHQPTypedValueRule[] = "HQPTypedValue"; |
(...skipping 21 matching lines...) Expand all Loading... | |
565 "HQPAlsoDoHUPLikeScoring"; | 612 "HQPAlsoDoHUPLikeScoring"; |
566 const char OmniboxFieldTrial::kHUPSearchDatabaseRule[] = | 613 const char OmniboxFieldTrial::kHUPSearchDatabaseRule[] = |
567 "HUPSearchDatabase"; | 614 "HUPSearchDatabase"; |
568 const char OmniboxFieldTrial::kKeywordRequiresRegistryRule[] = | 615 const char OmniboxFieldTrial::kKeywordRequiresRegistryRule[] = |
569 "KeywordRequiresRegistry"; | 616 "KeywordRequiresRegistry"; |
570 const char OmniboxFieldTrial::kKeywordRequiresPrefixMatchRule[] = | 617 const char OmniboxFieldTrial::kKeywordRequiresPrefixMatchRule[] = |
571 "KeywordRequiresPrefixMatch"; | 618 "KeywordRequiresPrefixMatch"; |
572 const char OmniboxFieldTrial::kKeywordScoreForSufficientlyCompleteMatchRule[] = | 619 const char OmniboxFieldTrial::kKeywordScoreForSufficientlyCompleteMatchRule[] = |
573 "KeywordScoreForSufficientlyCompleteMatch"; | 620 "KeywordScoreForSufficientlyCompleteMatch"; |
574 const char OmniboxFieldTrial::kEmphasizeTitlesRule[] = "EmphasizeTitles"; | 621 const char OmniboxFieldTrial::kEmphasizeTitlesRule[] = "EmphasizeTitles"; |
622 const char OmniboxFieldTrial::kPhysicalWebZeroSuggestRule[] = | |
623 "PhysicalWebZeroSuggest"; | |
624 const char OmniboxFieldTrial::kPhysicalWebAfterTypingRule[] = | |
625 "PhysicalWebAfterTyping"; | |
575 | 626 |
576 const char OmniboxFieldTrial::kHUPNewScoringEnabledParam[] = | 627 const char OmniboxFieldTrial::kHUPNewScoringEnabledParam[] = |
577 "HUPExperimentalScoringEnabled"; | 628 "HUPExperimentalScoringEnabled"; |
578 const char OmniboxFieldTrial::kHUPNewScoringTypedCountRelevanceCapParam[] = | 629 const char OmniboxFieldTrial::kHUPNewScoringTypedCountRelevanceCapParam[] = |
579 "TypedCountRelevanceCap"; | 630 "TypedCountRelevanceCap"; |
580 const char OmniboxFieldTrial::kHUPNewScoringTypedCountHalfLifeTimeParam[] = | 631 const char OmniboxFieldTrial::kHUPNewScoringTypedCountHalfLifeTimeParam[] = |
581 "TypedCountHalfLifeTime"; | 632 "TypedCountHalfLifeTime"; |
582 const char OmniboxFieldTrial::kHUPNewScoringTypedCountScoreBucketsParam[] = | 633 const char OmniboxFieldTrial::kHUPNewScoringTypedCountScoreBucketsParam[] = |
583 "TypedCountScoreBuckets"; | 634 "TypedCountScoreBuckets"; |
584 const char OmniboxFieldTrial::kHUPNewScoringTypedCountUseDecayFactorParam[] = | 635 const char OmniboxFieldTrial::kHUPNewScoringTypedCountUseDecayFactorParam[] = |
585 "TypedCountUseDecayFactor"; | 636 "TypedCountUseDecayFactor"; |
586 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountRelevanceCapParam[] = | 637 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountRelevanceCapParam[] = |
587 "VisitedCountRelevanceCap"; | 638 "VisitedCountRelevanceCap"; |
588 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountHalfLifeTimeParam[] = | 639 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountHalfLifeTimeParam[] = |
589 "VisitedCountHalfLifeTime"; | 640 "VisitedCountHalfLifeTime"; |
590 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountScoreBucketsParam[] = | 641 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountScoreBucketsParam[] = |
591 "VisitedCountScoreBuckets"; | 642 "VisitedCountScoreBuckets"; |
592 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountUseDecayFactorParam[] = | 643 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountUseDecayFactorParam[] = |
593 "VisitedCountUseDecayFactor"; | 644 "VisitedCountUseDecayFactor"; |
594 | 645 |
595 const char OmniboxFieldTrial::kHQPExperimentalScoringBucketsParam[] = | 646 const char OmniboxFieldTrial::kHQPExperimentalScoringBucketsParam[] = |
596 "HQPExperimentalScoringBuckets"; | 647 "HQPExperimentalScoringBuckets"; |
597 const char | 648 const char |
598 OmniboxFieldTrial::kHQPExperimentalScoringTopicalityThresholdParam[] = | 649 OmniboxFieldTrial::kHQPExperimentalScoringTopicalityThresholdParam[] = |
599 "HQPExperimentalScoringTopicalityThreshold"; | 650 "HQPExperimentalScoringTopicalityThreshold"; |
600 | 651 |
652 const char OmniboxFieldTrial::kPhysicalWebExperimentalScoringParam[] = | |
653 "PhysicalWebExperimentalScoring"; | |
654 const char OmniboxFieldTrial::kPhysicalWebZeroSuggestBaseRelevanceParam[] = | |
655 "PhysicalWebZeroSuggestBaseRelevance"; | |
656 const char OmniboxFieldTrial::kPhysicalWebAfterTypingBaseRelevanceParam[] = | |
657 "PhysicalWebAfterTypingBaseRelevanceParam"; | |
658 | |
601 // static | 659 // static |
602 int OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs = 100; | 660 int OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs = 100; |
603 | 661 |
604 // Background and implementation details: | 662 // Background and implementation details: |
605 // | 663 // |
606 // Each experiment group in any field trial can come with an optional set of | 664 // Each experiment group in any field trial can come with an optional set of |
607 // parameters (key-value pairs). In the bundled omnibox experiment | 665 // parameters (key-value pairs). In the bundled omnibox experiment |
608 // (kBundledExperimentFieldTrialName), each experiment group comes with a | 666 // (kBundledExperimentFieldTrialName), each experiment group comes with a |
609 // list of parameters in the form: | 667 // list of parameters in the form: |
610 // key=<Rule>: | 668 // key=<Rule>: |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
656 if (it != params.end()) | 714 if (it != params.end()) |
657 return it->second; | 715 return it->second; |
658 // Fall back to the global instant extended context. | 716 // Fall back to the global instant extended context. |
659 it = params.find(rule + ":" + page_classification_str + ":*"); | 717 it = params.find(rule + ":" + page_classification_str + ":*"); |
660 if (it != params.end()) | 718 if (it != params.end()) |
661 return it->second; | 719 return it->second; |
662 // Look up rule in the global context. | 720 // Look up rule in the global context. |
663 it = params.find(rule + ":*:*"); | 721 it = params.find(rule + ":*:*"); |
664 return (it != params.end()) ? it->second : std::string(); | 722 return (it != params.end()) ? it->second : std::string(); |
665 } | 723 } |
OLD | NEW |