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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 const std::string& rule, | 490 const std::string& rule, |
491 OmniboxEventProto::PageClassification page_classification) { | 491 OmniboxEventProto::PageClassification page_classification) { |
492 VariationParams params; | 492 VariationParams params; |
493 if (!variations::GetVariationParams(kBundledExperimentFieldTrialName, | 493 if (!variations::GetVariationParams(kBundledExperimentFieldTrialName, |
494 ¶ms)) { | 494 ¶ms)) { |
495 return std::string(); | 495 return std::string(); |
496 } | 496 } |
497 const std::string page_classification_str = | 497 const std::string page_classification_str = |
498 base::IntToString(static_cast<int>(page_classification)); | 498 base::IntToString(static_cast<int>(page_classification)); |
499 const std::string instant_extended = | 499 const std::string instant_extended = |
500 chrome::IsInstantExtendedAPIEnabled() ? "1" : "0"; | 500 search::IsInstantExtendedAPIEnabled() ? "1" : "0"; |
501 // Look up rule in this exact context. | 501 // Look up rule in this exact context. |
502 VariationParams::const_iterator it = params.find( | 502 VariationParams::const_iterator it = params.find( |
503 rule + ":" + page_classification_str + ":" + instant_extended); | 503 rule + ":" + page_classification_str + ":" + instant_extended); |
504 if (it != params.end()) | 504 if (it != params.end()) |
505 return it->second; | 505 return it->second; |
506 // Fall back to the global page classification context. | 506 // Fall back to the global page classification context. |
507 it = params.find(rule + ":*:" + instant_extended); | 507 it = params.find(rule + ":*:" + instant_extended); |
508 if (it != params.end()) | 508 if (it != params.end()) |
509 return it->second; | 509 return it->second; |
510 // Fall back to the global instant extended context. | 510 // Fall back to the global instant extended context. |
511 it = params.find(rule + ":" + page_classification_str + ":*"); | 511 it = params.find(rule + ":" + page_classification_str + ":*"); |
512 if (it != params.end()) | 512 if (it != params.end()) |
513 return it->second; | 513 return it->second; |
514 // Look up rule in the global context. | 514 // Look up rule in the global context. |
515 it = params.find(rule + ":*:*"); | 515 it = params.find(rule + ":*:*"); |
516 return (it != params.end()) ? it->second : std::string(); | 516 return (it != params.end()) ? it->second : std::string(); |
517 } | 517 } |
OLD | NEW |