| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 return undemotable_types; | 298 return undemotable_types; |
| 299 } | 299 } |
| 300 | 300 |
| 301 bool OmniboxFieldTrial::ReorderForLegalDefaultMatch( | 301 bool OmniboxFieldTrial::ReorderForLegalDefaultMatch( |
| 302 AutocompleteInput::PageClassification current_page_classification) { | 302 AutocompleteInput::PageClassification current_page_classification) { |
| 303 return OmniboxFieldTrial::GetValueForRuleInContext( | 303 return OmniboxFieldTrial::GetValueForRuleInContext( |
| 304 kReorderForLegalDefaultMatchRule, current_page_classification) == | 304 kReorderForLegalDefaultMatchRule, current_page_classification) == |
| 305 kReorderForLegalDefaultMatchRuleEnabled; | 305 kReorderForLegalDefaultMatchRuleEnabled; |
| 306 } | 306 } |
| 307 | 307 |
| 308 int OmniboxFieldTrial::HQPBookmarkValue() { |
| 309 std::string bookmark_value_str = chrome_variations:: |
| 310 GetVariationParamValue(kBundledExperimentFieldTrialName, |
| 311 kHQPBookmarkValueRule); |
| 312 if (bookmark_value_str.empty()) |
| 313 return 1; |
| 314 // This is a best-effort conversion; we trust the hand-crafted parameters |
| 315 // downloaded from the server to be perfect. There's no need for handle |
| 316 // errors smartly. |
| 317 int bookmark_value; |
| 318 base::StringToInt(bookmark_value_str, &bookmark_value); |
| 319 return bookmark_value; |
| 320 } |
| 321 |
| 308 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] = | 322 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] = |
| 309 "OmniboxBundledExperimentV1"; | 323 "OmniboxBundledExperimentV1"; |
| 310 const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] = | 324 const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] = |
| 311 "ShortcutsScoringMaxRelevance"; | 325 "ShortcutsScoringMaxRelevance"; |
| 312 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory"; | 326 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory"; |
| 313 const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType"; | 327 const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType"; |
| 314 const char OmniboxFieldTrial::kUndemotableTopTypeRule[] = "UndemotableTopTypes"; | 328 const char OmniboxFieldTrial::kUndemotableTopTypeRule[] = "UndemotableTopTypes"; |
| 315 const char OmniboxFieldTrial::kReorderForLegalDefaultMatchRule[] = | 329 const char OmniboxFieldTrial::kReorderForLegalDefaultMatchRule[] = |
| 316 "ReorderForLegalDefaultMatch"; | 330 "ReorderForLegalDefaultMatch"; |
| 331 const char OmniboxFieldTrial::kHQPBookmarkValueRule[] = |
| 332 "HQPBookmarkValue"; |
| 317 const char OmniboxFieldTrial::kReorderForLegalDefaultMatchRuleEnabled[] = | 333 const char OmniboxFieldTrial::kReorderForLegalDefaultMatchRuleEnabled[] = |
| 318 "ReorderForLegalDefaultMatch"; | 334 "ReorderForLegalDefaultMatch"; |
| 319 | 335 |
| 320 // Background and implementation details: | 336 // Background and implementation details: |
| 321 // | 337 // |
| 322 // Each experiment group in any field trial can come with an optional set of | 338 // Each experiment group in any field trial can come with an optional set of |
| 323 // parameters (key-value pairs). In the bundled omnibox experiment | 339 // parameters (key-value pairs). In the bundled omnibox experiment |
| 324 // (kBundledExperimentFieldTrialName), each experiment group comes with a | 340 // (kBundledExperimentFieldTrialName), each experiment group comes with a |
| 325 // list of parameters in the form: | 341 // list of parameters in the form: |
| 326 // key=<Rule>: | 342 // key=<Rule>: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 if (it != params.end()) | 388 if (it != params.end()) |
| 373 return it->second; | 389 return it->second; |
| 374 // Fall back to the global instant extended context. | 390 // Fall back to the global instant extended context. |
| 375 it = params.find(rule + ":" + page_classification_str + ":*"); | 391 it = params.find(rule + ":" + page_classification_str + ":*"); |
| 376 if (it != params.end()) | 392 if (it != params.end()) |
| 377 return it->second; | 393 return it->second; |
| 378 // Look up rule in the global context. | 394 // Look up rule in the global context. |
| 379 it = params.find(rule + ":*:*"); | 395 it = params.find(rule + ":*:*"); |
| 380 return (it != params.end()) ? it->second : std::string(); | 396 return (it != params.end()) ? it->second : std::string(); |
| 381 } | 397 } |
| OLD | NEW |