| 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 const std::string& rule, | 476 const std::string& rule, |
| 477 OmniboxEventProto::PageClassification page_classification) { | 477 OmniboxEventProto::PageClassification page_classification) { |
| 478 VariationParams params; | 478 VariationParams params; |
| 479 if (!variations::GetVariationParams(kBundledExperimentFieldTrialName, | 479 if (!variations::GetVariationParams(kBundledExperimentFieldTrialName, |
| 480 ¶ms)) { | 480 ¶ms)) { |
| 481 return std::string(); | 481 return std::string(); |
| 482 } | 482 } |
| 483 const std::string page_classification_str = | 483 const std::string page_classification_str = |
| 484 base::IntToString(static_cast<int>(page_classification)); | 484 base::IntToString(static_cast<int>(page_classification)); |
| 485 const std::string instant_extended = | 485 const std::string instant_extended = |
| 486 chrome::IsInstantExtendedAPIEnabled() ? "1" : "0"; | 486 search::IsInstantExtendedAPIEnabled() ? "1" : "0"; |
| 487 // Look up rule in this exact context. | 487 // Look up rule in this exact context. |
| 488 VariationParams::const_iterator it = params.find( | 488 VariationParams::const_iterator it = params.find( |
| 489 rule + ":" + page_classification_str + ":" + instant_extended); | 489 rule + ":" + page_classification_str + ":" + instant_extended); |
| 490 if (it != params.end()) | 490 if (it != params.end()) |
| 491 return it->second; | 491 return it->second; |
| 492 // Fall back to the global page classification context. | 492 // Fall back to the global page classification context. |
| 493 it = params.find(rule + ":*:" + instant_extended); | 493 it = params.find(rule + ":*:" + instant_extended); |
| 494 if (it != params.end()) | 494 if (it != params.end()) |
| 495 return it->second; | 495 return it->second; |
| 496 // Fall back to the global instant extended context. | 496 // Fall back to the global instant extended context. |
| 497 it = params.find(rule + ":" + page_classification_str + ":*"); | 497 it = params.find(rule + ":" + page_classification_str + ":*"); |
| 498 if (it != params.end()) | 498 if (it != params.end()) |
| 499 return it->second; | 499 return it->second; |
| 500 // Look up rule in the global context. | 500 // Look up rule in the global context. |
| 501 it = params.find(rule + ":*:*"); | 501 it = params.find(rule + ":*:*"); |
| 502 return (it != params.end()) ? it->second : std::string(); | 502 return (it != params.end()) ? it->second : std::string(); |
| 503 } | 503 } |
| OLD | NEW |