Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: chrome/browser/ui/search/search.cc

Issue 12319124: Enable query extraction for Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed embeddedPageVersion for mobile and cleaned up the rest Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/android/chrome_startup_flags.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_split.h" 9 #include "base/string_split.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 11 matching lines...) Expand all
22 namespace { 22 namespace {
23 23
24 // Configuration options for Embedded Search. 24 // Configuration options for Embedded Search.
25 // InstantExtended field trials are named in such a way that we can parse out 25 // InstantExtended field trials are named in such a way that we can parse out
26 // the experiment configuration from the trial's group name in order to give 26 // the experiment configuration from the trial's group name in order to give
27 // us maximum flexability in running experiments. 27 // us maximum flexability in running experiments.
28 // Field trial groups should be named things like "Group7 espv:2 instant:1". 28 // Field trial groups should be named things like "Group7 espv:2 instant:1".
29 // The first token is always GroupN for some integer N, followed by a 29 // The first token is always GroupN for some integer N, followed by a
30 // space-delimited list of key:value pairs which correspond to these flags: 30 // space-delimited list of key:value pairs which correspond to these flags:
31 const char kEmbeddedPageVersionFlagName[] = "espv"; 31 const char kEmbeddedPageVersionFlagName[] = "espv";
32
33 #if defined(OS_IOS) || defined(OS_ANDROID)
34 const int kEmbeddedPageVersionDefault = 1;
35 #else
32 const int kEmbeddedPageVersionDefault = 2; 36 const int kEmbeddedPageVersionDefault = 2;
37 #endif
33 38
34 const char kInstantExtendedActivationName[] = "instant"; 39 const char kInstantExtendedActivationName[] = "instant";
35 const chrome::search::InstantExtendedDefault kInstantExtendedActivationDefault = 40 const chrome::search::InstantExtendedDefault kInstantExtendedActivationDefault =
36 chrome::search::INSTANT_DEFAULT_ON; 41 chrome::search::INSTANT_DEFAULT_ON;
37 42
38 // Constants for the field trial name and group prefix. 43 // Constants for the field trial name and group prefix.
39 const char kInstantExtendedFieldTrialName[] = "InstantExtended"; 44 const char kInstantExtendedFieldTrialName[] = "InstantExtended";
40 const char kGroupNumberPrefix[] = "Group"; 45 const char kGroupNumberPrefix[] = "Group";
41 46
42 // If the field trial's group name ends with this string its configuration will 47 // If the field trial's group name ends with this string its configuration will
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 return kInstantExtendedActivationDefault; 142 return kInstantExtendedActivationDefault;
138 } 143 }
139 144
140 bool IsInstantExtendedAPIEnabled(const Profile* profile) { 145 bool IsInstantExtendedAPIEnabled(const Profile* profile) {
141 return EmbeddedSearchPageVersion(profile) != 0; 146 return EmbeddedSearchPageVersion(profile) != 0;
142 } 147 }
143 148
144 // Determine what embedded search page version to request from the user's 149 // Determine what embedded search page version to request from the user's
145 // default search provider. If 0, the embedded search UI should not be enabled. 150 // default search provider. If 0, the embedded search UI should not be enabled.
146 uint64 EmbeddedSearchPageVersion(const Profile* profile) { 151 uint64 EmbeddedSearchPageVersion(const Profile* profile) {
152 #if defined(OS_IOS) || defined(OS_ANDROID)
153 const CommandLine* cl = CommandLine::ForCurrentProcess();
154 if (cl->HasSwitch(switches::kEnableQueryExtraction));
sreeram 2013/03/01 22:36:44 Trailing semicolon oops.
Peter Kasting 2013/03/01 22:42:49 Do we need to use a distinct command-line flag fro
155 return kEmbeddedPageVersionDefault;
156 #else
147 if (!profile || profile->IsOffTheRecord()) 157 if (!profile || profile->IsOffTheRecord())
148 return 0; 158 return 0;
149 159
150 FieldTrialFlags flags; 160 FieldTrialFlags flags;
151 if (GetFieldTrialInfo( 161 if (GetFieldTrialInfo(
152 base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName), 162 base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName),
153 &flags, NULL)) { 163 &flags, NULL)) {
154 return GetUInt64ValueForFlagWithDefault(kEmbeddedPageVersionFlagName, 164 return GetUInt64ValueForFlagWithDefault(kEmbeddedPageVersionFlagName,
155 kEmbeddedPageVersionDefault, 165 kEmbeddedPageVersionDefault,
156 flags); 166 flags);
157 } 167 }
158 168
159 const CommandLine* cl = CommandLine::ForCurrentProcess(); 169 const CommandLine* cl = CommandLine::ForCurrentProcess();
160 if (cl->HasSwitch(switches::kEnableInstantExtendedAPI)) { 170 if (cl->HasSwitch(switches::kEnableInstantExtendedAPI)) {
161 // The user has manually flipped the about:flags switch - give the default 171 // The user has manually flipped the about:flags switch - give the default
162 // UI version. 172 // UI version.
163 return kEmbeddedPageVersionDefault; 173 return kEmbeddedPageVersionDefault;
164 } 174 }
165 175 #endif // defined(OS_IOS) || defined(OS_ANDROID)
sreeram 2013/03/01 22:36:44 Two spaces before "//".
166 return 0; 176 return 0;
167 } 177 }
168 178
169 bool IsQueryExtractionEnabled(const Profile* profile) { 179 bool IsQueryExtractionEnabled(const Profile* profile) {
170 #if defined(OS_IOS)
171 const CommandLine* cl = CommandLine::ForCurrentProcess();
172 return cl->HasSwitch(switches::kEnableQueryExtraction);
173 #else
174 // On desktop, query extraction is controlled by the instant-extended-api 180 // On desktop, query extraction is controlled by the instant-extended-api
175 // flag. 181 // flag. For iOS and Android, the below function returns true if the
182 // enable-query-extraction flag is present.
176 return IsInstantExtendedAPIEnabled(profile); 183 return IsInstantExtendedAPIEnabled(profile);
177 #endif
178 } 184 }
179 185
180 string16 GetSearchTermsFromNavigationEntry( 186 string16 GetSearchTermsFromNavigationEntry(
181 const content::NavigationEntry* entry) { 187 const content::NavigationEntry* entry) {
182 string16 search_terms; 188 string16 search_terms;
183 if (entry) 189 if (entry)
184 entry->GetExtraData(kInstantExtendedSearchTermsKey, &search_terms); 190 entry->GetExtraData(kInstantExtendedSearchTermsKey, &search_terms);
185 return search_terms; 191 return search_terms;
186 } 192 }
187 193
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 IsInstantExtendedAPIEnabled(profile), 261 IsInstantExtendedAPIEnabled(profile),
256 template_url); 262 template_url);
257 } 263 }
258 264
259 void EnableInstantExtendedAPIForTesting() { 265 void EnableInstantExtendedAPIForTesting() {
260 CommandLine* cl = CommandLine::ForCurrentProcess(); 266 CommandLine* cl = CommandLine::ForCurrentProcess();
261 cl->AppendSwitch(switches::kEnableInstantExtendedAPI); 267 cl->AppendSwitch(switches::kEnableInstantExtendedAPI);
262 } 268 }
263 269
264 void EnableQueryExtractionForTesting() { 270 void EnableQueryExtractionForTesting() {
265 #if defined(OS_IOS) 271 #if defined(OS_IOS) || defined(OS_ANDROID)
266 CommandLine* cl = CommandLine::ForCurrentProcess(); 272 CommandLine* cl = CommandLine::ForCurrentProcess();
267 cl->AppendSwitch(switches::kEnableQueryExtraction); 273 cl->AppendSwitch(switches::kEnableQueryExtraction);
268 #else 274 #else
269 EnableInstantExtendedAPIForTesting(); 275 EnableInstantExtendedAPIForTesting();
270 #endif 276 #endif
271 } 277 }
272 278
273 bool ShouldAssignURLToInstantRendererImpl(const GURL& url, 279 bool ShouldAssignURLToInstantRendererImpl(const GURL& url,
274 bool extended_api_enabled, 280 bool extended_api_enabled,
275 TemplateURL* template_url) { 281 TemplateURL* template_url) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // Given a FieldTrialFlags object, returns the boolean value of the provided 371 // Given a FieldTrialFlags object, returns the boolean value of the provided
366 // flag. 372 // flag.
367 bool GetBoolValueForFlagWithDefault(const std::string& flag, 373 bool GetBoolValueForFlagWithDefault(const std::string& flag,
368 bool default_value, 374 bool default_value,
369 const FieldTrialFlags& flags) { 375 const FieldTrialFlags& flags) {
370 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); 376 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags);
371 } 377 }
372 378
373 } // namespace search 379 } // namespace search
374 } // namespace chrome 380 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/android/chrome_startup_flags.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698