Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: components/omnibox/browser/omnibox_field_trial.cc

Issue 2716273004: Invert description and URL for experimental zero suggest suggestions. (Closed)
Patch Set: Make title/url swap an independent feature Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // This is a best-effort conversion; we trust the hand-crafted parameters 516 // This is a best-effort conversion; we trust the hand-crafted parameters
517 // downloaded from the server to be perfect. There's no need for handle 517 // downloaded from the server to be perfect. There's no need for handle
518 // errors smartly. 518 // errors smartly.
519 int value; 519 int value;
520 base::StringToInt(value_str, &value); 520 base::StringToInt(value_str, &value);
521 return value; 521 return value;
522 } 522 }
523 523
524 OmniboxFieldTrial::EmphasizeTitlesCondition 524 OmniboxFieldTrial::EmphasizeTitlesCondition
525 OmniboxFieldTrial::GetEmphasizeTitlesConditionForInput( 525 OmniboxFieldTrial::GetEmphasizeTitlesConditionForInput(
526 metrics::OmniboxInputType::Type input_type) { 526 const AutocompleteInput& input) {
527 // Look up the parameter named kEmphasizeTitlesRule + ":" + input_type, 527 // Look up the parameter named kEmphasizeTitlesRule + ":" + input_type,
Mark P 2017/02/28 22:24:28 nit: This comment no longer applies to the code.
gcomanici 2017/03/01 02:56:28 I added a comment for the condition I added, and k
528 // find its value, and return that value as an enum. If the parameter 528 // find its value, and return that value as an enum. If the parameter
529 // isn't redefined, fall back to the generic rule kEmphasizeTitlesRule + ":*" 529 // isn't redefined, fall back to the generic rule kEmphasizeTitlesRule + ":*"
530 metrics::OmniboxInputType::Type input_type = input.type();
Mark P 2017/02/28 22:24:28 nit: it's alias isn't significantly shorter or mor
gcomanici 2017/03/01 02:56:28 Done.
531 if (input.from_omnibox_focus() &&
532 OmniboxFieldTrial::InZeroSuggestSwapTitleAndUrlFieldTrial()) {
Mark P 2017/02/28 22:24:28 nit: just test directly to see if the feature is e
gcomanici 2017/03/01 02:56:28 Done.
533 return EMPHASIZE_WHEN_NONEMPTY;
534 }
530 std::string value_str(variations::GetVariationParamValue( 535 std::string value_str(variations::GetVariationParamValue(
531 kBundledExperimentFieldTrialName, 536 kBundledExperimentFieldTrialName,
532 std::string(kEmphasizeTitlesRule) + "_" + 537 std::string(kEmphasizeTitlesRule) + "_" +
533 base::IntToString(static_cast<int>(input_type)))); 538 base::IntToString(static_cast<int>(input_type))));
534 if (value_str.empty()) { 539 if (value_str.empty()) {
535 value_str = variations::GetVariationParamValue( 540 value_str = variations::GetVariationParamValue(
536 kBundledExperimentFieldTrialName, 541 kBundledExperimentFieldTrialName,
537 std::string(kEmphasizeTitlesRule) + "_*"); 542 std::string(kEmphasizeTitlesRule) + "_*");
538 } 543 }
539 if (value_str.empty()) 544 if (value_str.empty())
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 kZeroSuggestRedirectToChromeServerAddressParam); 604 kZeroSuggestRedirectToChromeServerAddressParam);
600 } 605 }
601 606
602 // static 607 // static
603 std::string OmniboxFieldTrial::ZeroSuggestRedirectToChromeAdditionalFields() { 608 std::string OmniboxFieldTrial::ZeroSuggestRedirectToChromeAdditionalFields() {
604 return base::GetFieldTrialParamValueByFeature( 609 return base::GetFieldTrialParamValueByFeature(
605 features::kZeroSuggestRedirectToChrome, 610 features::kZeroSuggestRedirectToChrome,
606 kZeroSuggestRedirectToChromeAdditionalFieldsParam); 611 kZeroSuggestRedirectToChromeAdditionalFieldsParam);
607 } 612 }
608 613
614 // static
615 bool OmniboxFieldTrial::InZeroSuggestSwapTitleAndUrlFieldTrial() {
616 return base::FeatureList::IsEnabled(features::kZeroSuggestSwapTitleAndUrl);
617 }
618
609 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] = 619 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] =
610 "OmniboxBundledExperimentV1"; 620 "OmniboxBundledExperimentV1";
611 const char OmniboxFieldTrial::kDisableProvidersRule[] = "DisableProviders"; 621 const char OmniboxFieldTrial::kDisableProvidersRule[] = "DisableProviders";
612 const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] = 622 const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] =
613 "ShortcutsScoringMaxRelevance"; 623 "ShortcutsScoringMaxRelevance";
614 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory"; 624 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory";
615 const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType"; 625 const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType";
616 const char OmniboxFieldTrial::kHQPBookmarkValueRule[] = 626 const char OmniboxFieldTrial::kHQPBookmarkValueRule[] =
617 "HQPBookmarkValue"; 627 "HQPBookmarkValue";
618 const char OmniboxFieldTrial::kHQPTypedValueRule[] = "HQPTypedValue"; 628 const char OmniboxFieldTrial::kHQPTypedValueRule[] = "HQPTypedValue";
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 if (it != params.end()) 756 if (it != params.end())
747 return it->second; 757 return it->second;
748 // Fall back to the global instant extended context. 758 // Fall back to the global instant extended context.
749 it = params.find(rule + ":" + page_classification_str + ":*"); 759 it = params.find(rule + ":" + page_classification_str + ":*");
750 if (it != params.end()) 760 if (it != params.end())
751 return it->second; 761 return it->second;
752 // Look up rule in the global context. 762 // Look up rule in the global context.
753 it = params.find(rule + ":*:*"); 763 it = params.find(rule + ":*:*");
754 return (it != params.end()) ? it->second : std::string(); 764 return (it != params.end()) ? it->second : std::string();
755 } 765 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698