OLD | NEW |
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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 DemotionMultipliers* demotions_by_type) { | 318 DemotionMultipliers* demotions_by_type) { |
319 demotions_by_type->clear(); | 319 demotions_by_type->clear(); |
320 std::string demotion_rule = OmniboxFieldTrial::GetValueForRuleInContext( | 320 std::string demotion_rule = OmniboxFieldTrial::GetValueForRuleInContext( |
321 kDemoteByTypeRule, current_page_classification); | 321 kDemoteByTypeRule, current_page_classification); |
322 // If there is no demotion rule for this context, then use the default | 322 // If there is no demotion rule for this context, then use the default |
323 // value for that context. At the moment the default value is non-empty | 323 // value for that context. At the moment the default value is non-empty |
324 // only for the fakebox-focus context. | 324 // only for the fakebox-focus context. |
325 if (demotion_rule.empty() && | 325 if (demotion_rule.empty() && |
326 (current_page_classification == | 326 (current_page_classification == |
327 OmniboxEventProto::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS)) | 327 OmniboxEventProto::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS)) |
328 demotion_rule = "1:61,2:61,3:61,4:61,12:61"; | 328 demotion_rule = "1:61,2:61,3:61,4:61,16:61"; |
329 | 329 |
330 // The value of the DemoteByType rule is a comma-separated list of | 330 // The value of the DemoteByType rule is a comma-separated list of |
331 // {ResultType + ":" + Number} where ResultType is an AutocompleteMatchType:: | 331 // {ResultType + ":" + Number} where ResultType is an AutocompleteMatchType:: |
332 // Type enum represented as an integer and Number is an integer number | 332 // Type enum represented as an integer and Number is an integer number |
333 // between 0 and 100 inclusive. Relevance scores of matches of that result | 333 // between 0 and 100 inclusive. Relevance scores of matches of that result |
334 // type are multiplied by Number / 100. 100 means no change. | 334 // type are multiplied by Number / 100. 100 means no change. |
335 base::StringPairs kv_pairs; | 335 base::StringPairs kv_pairs; |
336 if (base::SplitStringIntoKeyValuePairs(demotion_rule, ':', ',', &kv_pairs)) { | 336 if (base::SplitStringIntoKeyValuePairs(demotion_rule, ':', ',', &kv_pairs)) { |
337 for (base::StringPairs::const_iterator it = kv_pairs.begin(); | 337 for (base::StringPairs::const_iterator it = kv_pairs.begin(); |
338 it != kv_pairs.end(); ++it) { | 338 it != kv_pairs.end(); ++it) { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 if (it != params.end()) | 527 if (it != params.end()) |
528 return it->second; | 528 return it->second; |
529 // Fall back to the global instant extended context. | 529 // Fall back to the global instant extended context. |
530 it = params.find(rule + ":" + page_classification_str + ":*"); | 530 it = params.find(rule + ":" + page_classification_str + ":*"); |
531 if (it != params.end()) | 531 if (it != params.end()) |
532 return it->second; | 532 return it->second; |
533 // Look up rule in the global context. | 533 // Look up rule in the global context. |
534 it = params.find(rule + ":*:*"); | 534 it = params.find(rule + ":*:*"); |
535 return (it != params.end()) ? it->second : std::string(); | 535 return (it != params.end()) ? it->second : std::string(); |
536 } | 536 } |
OLD | NEW |