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

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

Issue 182313014: Omnibox: Launch URL Demotion in the Fakebox by Default (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/omnibox/omnibox_field_trial.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/omnibox/omnibox_field_trial.h" 5 #include "chrome/browser/omnibox/omnibox_field_trial.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <string> 8 #include <string>
9 9
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 bool OmniboxFieldTrial::SearchHistoryDisable( 315 bool OmniboxFieldTrial::SearchHistoryDisable(
316 AutocompleteInput::PageClassification current_page_classification) { 316 AutocompleteInput::PageClassification current_page_classification) {
317 return OmniboxFieldTrial::GetValueForRuleInContext( 317 return OmniboxFieldTrial::GetValueForRuleInContext(
318 kSearchHistoryRule, current_page_classification) == "Disable"; 318 kSearchHistoryRule, current_page_classification) == "Disable";
319 } 319 }
320 320
321 void OmniboxFieldTrial::GetDemotionsByType( 321 void OmniboxFieldTrial::GetDemotionsByType(
322 AutocompleteInput::PageClassification current_page_classification, 322 AutocompleteInput::PageClassification current_page_classification,
323 DemotionMultipliers* demotions_by_type) { 323 DemotionMultipliers* demotions_by_type) {
324 demotions_by_type->clear(); 324 demotions_by_type->clear();
325 const std::string demotion_rule = 325 std::string demotion_rule = OmniboxFieldTrial::GetValueForRuleInContext(
326 OmniboxFieldTrial::GetValueForRuleInContext( 326 kDemoteByTypeRule, current_page_classification);
327 kDemoteByTypeRule, 327 // If there is no demotion rule for this context, then use the default
328 current_page_classification); 328 // value for that context. At the moment the default value is non-empty
329 // only for the fakebox-focus context.
330 if (demotion_rule.empty() &&
331 (current_page_classification ==
332 AutocompleteInput::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS))
333 demotion_rule = "1:61,2:61,3:61,4:61,12:61";
334
329 // The value of the DemoteByType rule is a comma-separated list of 335 // The value of the DemoteByType rule is a comma-separated list of
330 // {ResultType + ":" + Number} where ResultType is an AutocompleteMatchType:: 336 // {ResultType + ":" + Number} where ResultType is an AutocompleteMatchType::
331 // Type enum represented as an integer and Number is an integer number 337 // Type enum represented as an integer and Number is an integer number
332 // between 0 and 100 inclusive. Relevance scores of matches of that result 338 // between 0 and 100 inclusive. Relevance scores of matches of that result
333 // type are multiplied by Number / 100. 100 means no change. 339 // type are multiplied by Number / 100. 100 means no change.
334 base::StringPairs kv_pairs; 340 base::StringPairs kv_pairs;
335 if (base::SplitStringIntoKeyValuePairs(demotion_rule, ':', ',', &kv_pairs)) { 341 if (base::SplitStringIntoKeyValuePairs(demotion_rule, ':', ',', &kv_pairs)) {
336 for (base::StringPairs::const_iterator it = kv_pairs.begin(); 342 for (base::StringPairs::const_iterator it = kv_pairs.begin();
337 it != kv_pairs.end(); ++it) { 343 it != kv_pairs.end(); ++it) {
338 // This is a best-effort conversion; we trust the hand-crafted parameters 344 // This is a best-effort conversion; we trust the hand-crafted parameters
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 if (it != params.end()) 535 if (it != params.end())
530 return it->second; 536 return it->second;
531 // Fall back to the global instant extended context. 537 // Fall back to the global instant extended context.
532 it = params.find(rule + ":" + page_classification_str + ":*"); 538 it = params.find(rule + ":" + page_classification_str + ":*");
533 if (it != params.end()) 539 if (it != params.end())
534 return it->second; 540 return it->second;
535 // Look up rule in the global context. 541 // Look up rule in the global context.
536 it = params.find(rule + ":*:*"); 542 it = params.find(rule + ":*:*");
537 return (it != params.end()) ? it->second : std::string(); 543 return (it != params.end()) ? it->second : std::string();
538 } 544 }
OLDNEW
« no previous file with comments | « chrome/browser/omnibox/omnibox_field_trial.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698