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" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "build/build_config.h" |
17 #include "components/metrics/proto/omnibox_event.pb.h" | 18 #include "components/metrics/proto/omnibox_event.pb.h" |
18 #include "components/omnibox/browser/omnibox_switches.h" | 19 #include "components/omnibox/browser/omnibox_switches.h" |
19 #include "components/search/search.h" | 20 #include "components/search/search.h" |
20 #include "components/variations/active_field_trials.h" | 21 #include "components/variations/active_field_trials.h" |
21 #include "components/variations/metrics_util.h" | 22 #include "components/variations/metrics_util.h" |
22 #include "components/variations/variations_associated_data.h" | 23 #include "components/variations/variations_associated_data.h" |
23 | 24 |
24 using metrics::OmniboxEventProto; | 25 using metrics::OmniboxEventProto; |
25 | 26 |
26 namespace { | 27 namespace { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 kBundledExperimentFieldTrialName, | 135 kBundledExperimentFieldTrialName, |
135 kDisableProvidersRule); | 136 kDisableProvidersRule); |
136 int types = 0; | 137 int types = 0; |
137 if (types_string.empty() || !base::StringToInt(types_string, &types)) { | 138 if (types_string.empty() || !base::StringToInt(types_string, &types)) { |
138 return 0; | 139 return 0; |
139 } | 140 } |
140 return types; | 141 return types; |
141 } | 142 } |
142 | 143 |
143 void OmniboxFieldTrial::GetActiveSuggestFieldTrialHashes( | 144 void OmniboxFieldTrial::GetActiveSuggestFieldTrialHashes( |
144 std::vector<uint32>* field_trial_hashes) { | 145 std::vector<uint32_t>* field_trial_hashes) { |
145 field_trial_hashes->clear(); | 146 field_trial_hashes->clear(); |
146 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i) { | 147 for (int i = 0; i < kMaxAutocompleteDynamicFieldTrials; ++i) { |
147 const std::string& trial_name = DynamicFieldTrialName(i); | 148 const std::string& trial_name = DynamicFieldTrialName(i); |
148 if (base::FieldTrialList::TrialExists(trial_name)) | 149 if (base::FieldTrialList::TrialExists(trial_name)) |
149 field_trial_hashes->push_back(metrics::HashName(trial_name)); | 150 field_trial_hashes->push_back(metrics::HashName(trial_name)); |
150 } | 151 } |
151 if (base::FieldTrialList::TrialExists(kBundledExperimentFieldTrialName)) { | 152 if (base::FieldTrialList::TrialExists(kBundledExperimentFieldTrialName)) { |
152 field_trial_hashes->push_back( | 153 field_trial_hashes->push_back( |
153 metrics::HashName(kBundledExperimentFieldTrialName)); | 154 metrics::HashName(kBundledExperimentFieldTrialName)); |
154 } | 155 } |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 if (it != params.end()) | 614 if (it != params.end()) |
614 return it->second; | 615 return it->second; |
615 // Fall back to the global instant extended context. | 616 // Fall back to the global instant extended context. |
616 it = params.find(rule + ":" + page_classification_str + ":*"); | 617 it = params.find(rule + ":" + page_classification_str + ":*"); |
617 if (it != params.end()) | 618 if (it != params.end()) |
618 return it->second; | 619 return it->second; |
619 // Look up rule in the global context. | 620 // Look up rule in the global context. |
620 it = params.find(rule + ":*:*"); | 621 it = params.find(rule + ":*:*"); |
621 return (it != params.end()) ? it->second : std::string(); | 622 return (it != params.end()) ? it->second : std::string(); |
622 } | 623 } |
OLD | NEW |