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(kBundledExperimentFieldTrialName, |
| 537 kPhysicalWebZeroSuggestRule) == |
| 538 "true"; |
| 539 } |
| 540 |
| 541 // static |
| 542 bool OmniboxFieldTrial::InPhysicalWebAfterTypingFieldTrial() { |
| 543 return variations::GetVariationParamValue(kBundledExperimentFieldTrialName, |
| 544 kPhysicalWebAfterTypingRule) == |
| 545 "true"; |
| 546 } |
| 547 |
| 548 // static |
| 549 int OmniboxFieldTrial::GetPhysicalWebZeroSuggestBaseRelevance() { |
| 550 std::string param_value(variations::GetVariationParamValue( |
| 551 kBundledExperimentFieldTrialName, |
| 552 kPhysicalWebZeroSuggestBaseRelevanceParam)); |
| 553 int base_relevance; |
| 554 if (!param_value.empty() && base::StringToInt(param_value, &base_relevance)) |
| 555 return base_relevance; |
| 556 // Default relevance score of the first Physical Web URL autocomplete match |
| 557 // when the user has not typed in the omnibox. This score is intended to be |
| 558 // between ClipboardURLProvider and ZeroSuggestProvider. |
| 559 return 700; |
| 560 } |
| 561 |
| 562 // static |
| 563 int OmniboxFieldTrial::GetPhysicalWebAfterTypingBaseRelevance() { |
| 564 std::string param_value(variations::GetVariationParamValue( |
| 565 kBundledExperimentFieldTrialName, |
| 566 kPhysicalWebAfterTypingBaseRelevanceParam)); |
| 567 int base_relevance; |
| 568 if (!param_value.empty() && base::StringToInt(param_value, &base_relevance)) |
| 569 return base_relevance; |
| 570 // Default relevance score of the first Physical Web URL autocomplete match |
| 571 // when the user is typing in the omnibox. |
| 572 return 700; |
| 573 } |
| 574 |
534 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] = | 575 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] = |
535 "OmniboxBundledExperimentV1"; | 576 "OmniboxBundledExperimentV1"; |
536 const char OmniboxFieldTrial::kDisableProvidersRule[] = "DisableProviders"; | 577 const char OmniboxFieldTrial::kDisableProvidersRule[] = "DisableProviders"; |
537 const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] = | 578 const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] = |
538 "ShortcutsScoringMaxRelevance"; | 579 "ShortcutsScoringMaxRelevance"; |
539 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory"; | 580 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory"; |
540 const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType"; | 581 const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType"; |
541 const char OmniboxFieldTrial::kHQPBookmarkValueRule[] = | 582 const char OmniboxFieldTrial::kHQPBookmarkValueRule[] = |
542 "HQPBookmarkValue"; | 583 "HQPBookmarkValue"; |
543 const char OmniboxFieldTrial::kHQPTypedValueRule[] = "HQPTypedValue"; | 584 const char OmniboxFieldTrial::kHQPTypedValueRule[] = "HQPTypedValue"; |
(...skipping 21 matching lines...) Expand all Loading... |
565 "HQPAlsoDoHUPLikeScoring"; | 606 "HQPAlsoDoHUPLikeScoring"; |
566 const char OmniboxFieldTrial::kHUPSearchDatabaseRule[] = | 607 const char OmniboxFieldTrial::kHUPSearchDatabaseRule[] = |
567 "HUPSearchDatabase"; | 608 "HUPSearchDatabase"; |
568 const char OmniboxFieldTrial::kKeywordRequiresRegistryRule[] = | 609 const char OmniboxFieldTrial::kKeywordRequiresRegistryRule[] = |
569 "KeywordRequiresRegistry"; | 610 "KeywordRequiresRegistry"; |
570 const char OmniboxFieldTrial::kKeywordRequiresPrefixMatchRule[] = | 611 const char OmniboxFieldTrial::kKeywordRequiresPrefixMatchRule[] = |
571 "KeywordRequiresPrefixMatch"; | 612 "KeywordRequiresPrefixMatch"; |
572 const char OmniboxFieldTrial::kKeywordScoreForSufficientlyCompleteMatchRule[] = | 613 const char OmniboxFieldTrial::kKeywordScoreForSufficientlyCompleteMatchRule[] = |
573 "KeywordScoreForSufficientlyCompleteMatch"; | 614 "KeywordScoreForSufficientlyCompleteMatch"; |
574 const char OmniboxFieldTrial::kEmphasizeTitlesRule[] = "EmphasizeTitles"; | 615 const char OmniboxFieldTrial::kEmphasizeTitlesRule[] = "EmphasizeTitles"; |
| 616 const char OmniboxFieldTrial::kPhysicalWebZeroSuggestRule[] = |
| 617 "PhysicalWebZeroSuggest"; |
| 618 const char OmniboxFieldTrial::kPhysicalWebAfterTypingRule[] = |
| 619 "PhysicalWebAfterTyping"; |
575 | 620 |
576 const char OmniboxFieldTrial::kHUPNewScoringEnabledParam[] = | 621 const char OmniboxFieldTrial::kHUPNewScoringEnabledParam[] = |
577 "HUPExperimentalScoringEnabled"; | 622 "HUPExperimentalScoringEnabled"; |
578 const char OmniboxFieldTrial::kHUPNewScoringTypedCountRelevanceCapParam[] = | 623 const char OmniboxFieldTrial::kHUPNewScoringTypedCountRelevanceCapParam[] = |
579 "TypedCountRelevanceCap"; | 624 "TypedCountRelevanceCap"; |
580 const char OmniboxFieldTrial::kHUPNewScoringTypedCountHalfLifeTimeParam[] = | 625 const char OmniboxFieldTrial::kHUPNewScoringTypedCountHalfLifeTimeParam[] = |
581 "TypedCountHalfLifeTime"; | 626 "TypedCountHalfLifeTime"; |
582 const char OmniboxFieldTrial::kHUPNewScoringTypedCountScoreBucketsParam[] = | 627 const char OmniboxFieldTrial::kHUPNewScoringTypedCountScoreBucketsParam[] = |
583 "TypedCountScoreBuckets"; | 628 "TypedCountScoreBuckets"; |
584 const char OmniboxFieldTrial::kHUPNewScoringTypedCountUseDecayFactorParam[] = | 629 const char OmniboxFieldTrial::kHUPNewScoringTypedCountUseDecayFactorParam[] = |
585 "TypedCountUseDecayFactor"; | 630 "TypedCountUseDecayFactor"; |
586 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountRelevanceCapParam[] = | 631 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountRelevanceCapParam[] = |
587 "VisitedCountRelevanceCap"; | 632 "VisitedCountRelevanceCap"; |
588 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountHalfLifeTimeParam[] = | 633 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountHalfLifeTimeParam[] = |
589 "VisitedCountHalfLifeTime"; | 634 "VisitedCountHalfLifeTime"; |
590 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountScoreBucketsParam[] = | 635 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountScoreBucketsParam[] = |
591 "VisitedCountScoreBuckets"; | 636 "VisitedCountScoreBuckets"; |
592 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountUseDecayFactorParam[] = | 637 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountUseDecayFactorParam[] = |
593 "VisitedCountUseDecayFactor"; | 638 "VisitedCountUseDecayFactor"; |
594 | 639 |
595 const char OmniboxFieldTrial::kHQPExperimentalScoringBucketsParam[] = | 640 const char OmniboxFieldTrial::kHQPExperimentalScoringBucketsParam[] = |
596 "HQPExperimentalScoringBuckets"; | 641 "HQPExperimentalScoringBuckets"; |
597 const char | 642 const char |
598 OmniboxFieldTrial::kHQPExperimentalScoringTopicalityThresholdParam[] = | 643 OmniboxFieldTrial::kHQPExperimentalScoringTopicalityThresholdParam[] = |
599 "HQPExperimentalScoringTopicalityThreshold"; | 644 "HQPExperimentalScoringTopicalityThreshold"; |
600 | 645 |
| 646 const char OmniboxFieldTrial::kPhysicalWebZeroSuggestBaseRelevanceParam[] = |
| 647 "PhysicalWebZeroSuggestBaseRelevance"; |
| 648 const char OmniboxFieldTrial::kPhysicalWebAfterTypingBaseRelevanceParam[] = |
| 649 "PhysicalWebAfterTypingBaseRelevanceParam"; |
| 650 |
601 // static | 651 // static |
602 int OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs = 100; | 652 int OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs = 100; |
603 | 653 |
604 // Background and implementation details: | 654 // Background and implementation details: |
605 // | 655 // |
606 // Each experiment group in any field trial can come with an optional set of | 656 // Each experiment group in any field trial can come with an optional set of |
607 // parameters (key-value pairs). In the bundled omnibox experiment | 657 // parameters (key-value pairs). In the bundled omnibox experiment |
608 // (kBundledExperimentFieldTrialName), each experiment group comes with a | 658 // (kBundledExperimentFieldTrialName), each experiment group comes with a |
609 // list of parameters in the form: | 659 // list of parameters in the form: |
610 // key=<Rule>: | 660 // key=<Rule>: |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 if (it != params.end()) | 706 if (it != params.end()) |
657 return it->second; | 707 return it->second; |
658 // Fall back to the global instant extended context. | 708 // Fall back to the global instant extended context. |
659 it = params.find(rule + ":" + page_classification_str + ":*"); | 709 it = params.find(rule + ":" + page_classification_str + ":*"); |
660 if (it != params.end()) | 710 if (it != params.end()) |
661 return it->second; | 711 return it->second; |
662 // Look up rule in the global context. | 712 // Look up rule in the global context. |
663 it = params.find(rule + ":*:*"); | 713 it = params.find(rule + ":*:*"); |
664 return (it != params.end()) ? it->second : std::string(); | 714 return (it != params.end()) ? it->second : std::string(); |
665 } | 715 } |
OLD | NEW |