| 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/ui/search/search.h" | 5 #include "chrome/browser/ui/search/search.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 "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/chrome_version_info.h" | 13 #include "chrome/common/chrome_version_info.h" |
| 14 | 14 |
| 15 namespace chrome { | 15 namespace chrome { |
| 16 namespace search { | 16 namespace search { |
| 17 | 17 |
| 18 bool IsInstantExtendedAPIEnabled(const Profile* profile) { | 18 bool IsInstantExtendedAPIEnabled(const Profile* profile) { |
| 19 return EmbeddedSearchPageVersion(profile) != 0; | 19 return EmbeddedSearchPageVersion(profile) != 0; |
| 20 } | 20 } |
| 21 | 21 |
| 22 uint64 EmbeddedSearchPageVersion(const Profile* profile) { | 22 uint64 EmbeddedSearchPageVersion(const Profile* profile) { |
| 23 // Incognito windows do not currently use the embedded search API. | |
| 24 if (profile->IsOffTheRecord()) | |
| 25 return 0; | |
| 26 | |
| 27 // Check Finch field trials. | 23 // Check Finch field trials. |
| 28 base::FieldTrial* trial = base::FieldTrialList::Find("InstantExtended"); | 24 base::FieldTrial* trial = base::FieldTrialList::Find("InstantExtended"); |
| 29 if (trial && StartsWithASCII(trial->group_name(), "Group", true)) { | 25 if (trial && StartsWithASCII(trial->group_name(), "Group", true)) { |
| 30 uint64 group_number; | 26 uint64 group_number; |
| 31 if (base::StringToUint64(trial->group_name().substr(5), &group_number)) { | 27 if (base::StringToUint64(trial->group_name().substr(5), &group_number)) { |
| 32 return group_number; | 28 return group_number; |
| 33 } | 29 } |
| 34 } | 30 } |
| 35 | 31 |
| 36 if (CommandLine::ForCurrentProcess()->HasSwitch( | 32 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 53 switches::kEnableInstantExtendedAPI); | 49 switches::kEnableInstantExtendedAPI); |
| 54 } | 50 } |
| 55 | 51 |
| 56 void EnableQueryExtractionForTesting() { | 52 void EnableQueryExtractionForTesting() { |
| 57 CommandLine::ForCurrentProcess()->AppendSwitch( | 53 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 58 switches::kEnableInstantExtendedAPI); | 54 switches::kEnableInstantExtendedAPI); |
| 59 } | 55 } |
| 60 | 56 |
| 61 } // namespace search | 57 } // namespace search |
| 62 } // namespace chrome | 58 } // namespace chrome |
| OLD | NEW |