| 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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 kBundledExperimentFieldTrialName, | 433 kBundledExperimentFieldTrialName, |
| 434 kHQPAlsoDoHUPLikeScoringRule) == "true"; | 434 kHQPAlsoDoHUPLikeScoringRule) == "true"; |
| 435 } | 435 } |
| 436 | 436 |
| 437 bool OmniboxFieldTrial::PreventUWYTDefaultForNonURLInputs() { | 437 bool OmniboxFieldTrial::PreventUWYTDefaultForNonURLInputs() { |
| 438 return variations::GetVariationParamValue( | 438 return variations::GetVariationParamValue( |
| 439 kBundledExperimentFieldTrialName, | 439 kBundledExperimentFieldTrialName, |
| 440 kPreventUWYTDefaultForNonURLInputsRule) == "true"; | 440 kPreventUWYTDefaultForNonURLInputsRule) == "true"; |
| 441 } | 441 } |
| 442 | 442 |
| 443 bool OmniboxFieldTrial::KeywordRequiresRegistry() { |
| 444 const std::string& value = variations::GetVariationParamValue( |
| 445 kBundledExperimentFieldTrialName, |
| 446 kKeywordRequiresRegistryRule); |
| 447 return value.empty() || (value == "true"); |
| 448 } |
| 449 |
| 450 bool OmniboxFieldTrial::KeywordRequiresPrefixBeforeDomain() { |
| 451 const std::string& value = variations::GetVariationParamValue( |
| 452 kBundledExperimentFieldTrialName, |
| 453 kKeywordRequiresPrefixBeforeDomainRule); |
| 454 return value.empty() || (value == "true"); |
| 455 } |
| 456 |
| 457 int OmniboxFieldTrial::KeywordScoreForNearlyCompleteMatch() { |
| 458 std::string value_str = variations::GetVariationParamValue( |
| 459 kBundledExperimentFieldTrialName, |
| 460 kKeywordScoreForNearlyCompleteMatchRule); |
| 461 if (value_str.empty()) |
| 462 return -1; |
| 463 // This is a best-effort conversion; we trust the hand-crafted parameters |
| 464 // downloaded from the server to be perfect. There's no need for handle |
| 465 // errors smartly. |
| 466 int value; |
| 467 return base::StringToInt(value_str, &value); |
| 468 return value; |
| 469 } |
| 470 |
| 471 |
| 443 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] = | 472 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] = |
| 444 "OmniboxBundledExperimentV1"; | 473 "OmniboxBundledExperimentV1"; |
| 445 const char OmniboxFieldTrial::kDisableProvidersRule[] = "DisableProviders"; | 474 const char OmniboxFieldTrial::kDisableProvidersRule[] = "DisableProviders"; |
| 446 const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] = | 475 const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] = |
| 447 "ShortcutsScoringMaxRelevance"; | 476 "ShortcutsScoringMaxRelevance"; |
| 448 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory"; | 477 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory"; |
| 449 const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType"; | 478 const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType"; |
| 450 const char OmniboxFieldTrial::kHQPBookmarkValueRule[] = | 479 const char OmniboxFieldTrial::kHQPBookmarkValueRule[] = |
| 451 "HQPBookmarkValue"; | 480 "HQPBookmarkValue"; |
| 452 const char OmniboxFieldTrial::kHQPAllowMatchInTLDRule[] = "HQPAllowMatchInTLD"; | 481 const char OmniboxFieldTrial::kHQPAllowMatchInTLDRule[] = "HQPAllowMatchInTLD"; |
| 453 const char OmniboxFieldTrial::kHQPAllowMatchInSchemeRule[] = | 482 const char OmniboxFieldTrial::kHQPAllowMatchInSchemeRule[] = |
| 454 "HQPAllowMatchInScheme"; | 483 "HQPAllowMatchInScheme"; |
| 455 const char OmniboxFieldTrial::kZeroSuggestRule[] = "ZeroSuggest"; | 484 const char OmniboxFieldTrial::kZeroSuggestRule[] = "ZeroSuggest"; |
| 456 const char OmniboxFieldTrial::kZeroSuggestVariantRule[] = "ZeroSuggestVariant"; | 485 const char OmniboxFieldTrial::kZeroSuggestVariantRule[] = "ZeroSuggestVariant"; |
| 457 const char OmniboxFieldTrial::kSuggestVariantRule[] = "SuggestVariant"; | 486 const char OmniboxFieldTrial::kSuggestVariantRule[] = "SuggestVariant"; |
| 458 const char OmniboxFieldTrial::kDisableResultsCachingRule[] = | 487 const char OmniboxFieldTrial::kDisableResultsCachingRule[] = |
| 459 "DisableResultsCaching"; | 488 "DisableResultsCaching"; |
| 460 const char | 489 const char |
| 461 OmniboxFieldTrial::kMeasureSuggestPollingDelayFromLastKeystrokeRule[] = | 490 OmniboxFieldTrial::kMeasureSuggestPollingDelayFromLastKeystrokeRule[] = |
| 462 "MeasureSuggestPollingDelayFromLastKeystroke"; | 491 "MeasureSuggestPollingDelayFromLastKeystroke"; |
| 463 const char OmniboxFieldTrial::kSuggestPollingDelayMsRule[] = | 492 const char OmniboxFieldTrial::kSuggestPollingDelayMsRule[] = |
| 464 "SuggestPollingDelayMs"; | 493 "SuggestPollingDelayMs"; |
| 465 const char OmniboxFieldTrial::kHQPFixFrequencyScoringBugsRule[] = | 494 const char OmniboxFieldTrial::kHQPFixFrequencyScoringBugsRule[] = |
| 466 "HQPFixFrequencyScoringBugs"; | 495 "HQPFixFrequencyScoringBugs"; |
| 467 const char OmniboxFieldTrial::kHQPNumTitleWordsRule[] = "HQPNumTitleWords"; | 496 const char OmniboxFieldTrial::kHQPNumTitleWordsRule[] = "HQPNumTitleWords"; |
| 468 const char OmniboxFieldTrial::kHQPAlsoDoHUPLikeScoringRule[] = | 497 const char OmniboxFieldTrial::kHQPAlsoDoHUPLikeScoringRule[] = |
| 469 "HQPAlsoDoHUPLikeScoring"; | 498 "HQPAlsoDoHUPLikeScoring"; |
| 470 const char OmniboxFieldTrial::kPreventUWYTDefaultForNonURLInputsRule[] = | 499 const char OmniboxFieldTrial::kPreventUWYTDefaultForNonURLInputsRule[] = |
| 471 "PreventUWYTDefaultForNonURLInputs"; | 500 "PreventUWYTDefaultForNonURLInputs"; |
| 501 const char OmniboxFieldTrial::kKeywordRequiresRegistryRule[] = |
| 502 "KeywordRequiresRegistry"; |
| 503 const char OmniboxFieldTrial::kKeywordRequiresPrefixBeforeDomainRule[] = |
| 504 "KeywordRequiresPrefixBeforeDomain"; |
| 505 const char OmniboxFieldTrial::kKeywordScoreForNearlyCompleteMatchRule[] = |
| 506 "KeywordScoreForNearlyCompleteMatch"; |
| 472 | 507 |
| 473 const char OmniboxFieldTrial::kHUPNewScoringEnabledParam[] = | 508 const char OmniboxFieldTrial::kHUPNewScoringEnabledParam[] = |
| 474 "HUPExperimentalScoringEnabled"; | 509 "HUPExperimentalScoringEnabled"; |
| 475 const char OmniboxFieldTrial::kHUPNewScoringTypedCountRelevanceCapParam[] = | 510 const char OmniboxFieldTrial::kHUPNewScoringTypedCountRelevanceCapParam[] = |
| 476 "TypedCountRelevanceCap"; | 511 "TypedCountRelevanceCap"; |
| 477 const char OmniboxFieldTrial::kHUPNewScoringTypedCountHalfLifeTimeParam[] = | 512 const char OmniboxFieldTrial::kHUPNewScoringTypedCountHalfLifeTimeParam[] = |
| 478 "TypedCountHalfLifeTime"; | 513 "TypedCountHalfLifeTime"; |
| 479 const char OmniboxFieldTrial::kHUPNewScoringTypedCountScoreBucketsParam[] = | 514 const char OmniboxFieldTrial::kHUPNewScoringTypedCountScoreBucketsParam[] = |
| 480 "TypedCountScoreBuckets"; | 515 "TypedCountScoreBuckets"; |
| 481 const char OmniboxFieldTrial::kHUPNewScoringTypedCountUseDecayFactorParam[] = | 516 const char OmniboxFieldTrial::kHUPNewScoringTypedCountUseDecayFactorParam[] = |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 if (it != params.end()) | 590 if (it != params.end()) |
| 556 return it->second; | 591 return it->second; |
| 557 // Fall back to the global instant extended context. | 592 // Fall back to the global instant extended context. |
| 558 it = params.find(rule + ":" + page_classification_str + ":*"); | 593 it = params.find(rule + ":" + page_classification_str + ":*"); |
| 559 if (it != params.end()) | 594 if (it != params.end()) |
| 560 return it->second; | 595 return it->second; |
| 561 // Look up rule in the global context. | 596 // Look up rule in the global context. |
| 562 it = params.find(rule + ":*:*"); | 597 it = params.find(rule + ":*:*"); |
| 563 return (it != params.end()) ? it->second : std::string(); | 598 return (it != params.end()) ? it->second : std::string(); |
| 564 } | 599 } |
| OLD | NEW |