| 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/instant/instant_field_trial.h" | 5 #include "chrome/browser/instant/instant_field_trial.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "chrome/browser/metrics/metrics_service.h" | 9 #include "chrome/browser/metrics/metrics_service.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 return SILENT; | 59 return SILENT; |
| 60 if (switch_value == switches::kInstantFieldTrialControl) | 60 if (switch_value == switches::kInstantFieldTrialControl) |
| 61 return CONTROL; | 61 return CONTROL; |
| 62 return INACTIVE; | 62 return INACTIVE; |
| 63 } | 63 } |
| 64 | 64 |
| 65 const int group = base::FieldTrialList::FindValue("Instant"); | 65 const int group = base::FieldTrialList::FindValue("Instant"); |
| 66 if (group == base::FieldTrial::kNotFinalized || group == g_inactive) | 66 if (group == base::FieldTrial::kNotFinalized || group == g_inactive) |
| 67 return INACTIVE; | 67 return INACTIVE; |
| 68 | 68 |
| 69 // If Instant is already enabled explicitly, then it's not a field trial. |
| 70 const PrefService* prefs = profile ? profile->GetPrefs() : NULL; |
| 71 if (prefs && prefs->GetBoolean(prefs::kInstantEnabled)) |
| 72 return INACTIVE; |
| 73 |
| 69 // CONTROL and SILENT are unconstrained. | 74 // CONTROL and SILENT are unconstrained. |
| 70 if (group == g_control) | 75 if (group == g_control) |
| 71 return CONTROL; | 76 return CONTROL; |
| 72 if (group == g_silent) | 77 if (group == g_silent) |
| 73 return SILENT; | 78 return SILENT; |
| 74 | 79 |
| 75 // HIDDEN, SUGGEST and INSTANT need non-incognito, suggest-enabled profiles. | 80 // HIDDEN, SUGGEST and INSTANT need non-incognito, suggest-enabled profiles. |
| 76 const PrefService* prefs = profile ? profile->GetPrefs() : NULL; | |
| 77 if (!prefs || profile->IsOffTheRecord() || | 81 if (!prefs || profile->IsOffTheRecord() || |
| 78 !prefs->GetBoolean(prefs::kSearchSuggestEnabled)) { | 82 !prefs->GetBoolean(prefs::kSearchSuggestEnabled)) { |
| 79 return INACTIVE; | 83 return INACTIVE; |
| 80 } | 84 } |
| 81 | 85 |
| 82 if (group == g_hidden) | 86 if (group == g_hidden) |
| 83 return HIDDEN; | 87 return HIDDEN; |
| 84 | 88 |
| 85 // SUGGEST and INSTANT require UMA opt-in. | 89 // SUGGEST and INSTANT require UMA opt-in. |
| 86 if (!MetricsServiceHelper::IsMetricsReportingEnabled()) | 90 if (!MetricsServiceHelper::IsMetricsReportingEnabled()) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 153 |
| 150 NOTREACHED(); | 154 NOTREACHED(); |
| 151 return std::string(); | 155 return std::string(); |
| 152 } | 156 } |
| 153 | 157 |
| 154 // static | 158 // static |
| 155 bool InstantFieldTrial::ShouldSetSuggestedText(Profile* profile) { | 159 bool InstantFieldTrial::ShouldSetSuggestedText(Profile* profile) { |
| 156 Group group = GetGroup(profile); | 160 Group group = GetGroup(profile); |
| 157 return group != HIDDEN && group != SILENT; | 161 return group != HIDDEN && group != SILENT; |
| 158 } | 162 } |
| OLD | NEW |