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

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

Issue 11884037: InstantExtended: Bail on TemplateURLs with no espv. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Braces. Created 7 years, 11 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
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_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/search_engines/template_url_service.h"
14 #include "chrome/browser/search_engines/template_url_service_factory.h"
13 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/chrome_version_info.h" 16 #include "chrome/common/chrome_version_info.h"
15 17
16 #if !defined(OS_ANDROID) 18 #if !defined(OS_ANDROID)
17 #include "chrome/browser/themes/theme_service.h" 19 #include "chrome/browser/themes/theme_service.h"
18 #include "chrome/browser/themes/theme_service_factory.h" 20 #include "chrome/browser/themes/theme_service_factory.h"
19 #endif 21 #endif
20 22
21 namespace chrome { 23 namespace chrome {
22 namespace search { 24 namespace search {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // Determine what embedded search page version to request from the user's 109 // Determine what embedded search page version to request from the user's
108 // default search provider. If 0, the embedded search UI should not be enabled. 110 // default search provider. If 0, the embedded search UI should not be enabled.
109 // Note that the profile object here isn't const because we need to determine 111 // Note that the profile object here isn't const because we need to determine
110 // whether or not the user has a theme installed as part of this check, and 112 // whether or not the user has a theme installed as part of this check, and
111 // that logic requires a non-const profile for whatever reason. 113 // that logic requires a non-const profile for whatever reason.
112 uint64 EmbeddedSearchPageVersion(Profile* profile) { 114 uint64 EmbeddedSearchPageVersion(Profile* profile) {
113 // Incognito windows do not currently use the embedded search API. 115 // Incognito windows do not currently use the embedded search API.
114 if (!profile || profile->IsOffTheRecord()) 116 if (!profile || profile->IsOffTheRecord())
115 return 0; 117 return 0;
116 118
119 // Some users may have their search provider TemplateURL pinned to an
120 // obsolete value which does not support enabling InstantExtended on the
121 // server side. Bail out of InstantExtended if we detect that.
122 const TemplateURL* template_url =
123 TemplateURLServiceFactory::GetForProfile(profile)->
124 GetDefaultSearchProvider();
125 if (!template_url || !template_url->SupportsInstantExtendedParam())
126 return 0;
127
117 // Check Finch field trials. 128 // Check Finch field trials.
118 FieldTrialFlags flags; 129 FieldTrialFlags flags;
119 uint64 group_number = 0; 130 uint64 group_number = 0;
120 base::FieldTrial* trial = 131 base::FieldTrial* trial =
121 base::FieldTrialList::Find(kInstantExtendedFieldTrialName); 132 base::FieldTrialList::Find(kInstantExtendedFieldTrialName);
122 if (trial) { 133 if (trial) {
123 std::string group_name = trial->group_name(); 134 std::string group_name = trial->group_name();
124 GetFieldTrialInfo(group_name, &flags, &group_number); 135 GetFieldTrialInfo(group_name, &flags, &group_number);
125 } 136 }
126 137
(...skipping 17 matching lines...) Expand all
144 if (!has_theme || enable_for_themes) 155 if (!has_theme || enable_for_themes)
145 return espv; 156 return espv;
146 } 157 }
147 158
148 if (CommandLine::ForCurrentProcess()->HasSwitch( 159 if (CommandLine::ForCurrentProcess()->HasSwitch(
149 switches::kEnableInstantExtendedAPI)) { 160 switches::kEnableInstantExtendedAPI)) {
150 // The user has manually flipped the about:flags switch - give the default 161 // The user has manually flipped the about:flags switch - give the default
151 // UI version. 162 // UI version.
152 return kEmbeddedPageVersionDefault; 163 return kEmbeddedPageVersionDefault;
153 } 164 }
165
154 return 0; 166 return 0;
155 } 167 }
156 168
157 void EnableInstantExtendedAPIForTesting() { 169 void EnableInstantExtendedAPIForTesting() {
158 CommandLine::ForCurrentProcess()->AppendSwitch( 170 CommandLine::ForCurrentProcess()->AppendSwitch(
159 switches::kEnableInstantExtendedAPI); 171 switches::kEnableInstantExtendedAPI);
160 } 172 }
161 173
162 bool IsQueryExtractionEnabled(Profile* profile) { 174 bool IsQueryExtractionEnabled(Profile* profile) {
163 #if defined(OS_IOS) 175 #if defined(OS_IOS)
(...skipping 20 matching lines...) Expand all
184 #else 196 #else
185 // On desktop, query extraction is controlled by the instant-extended-api 197 // On desktop, query extraction is controlled by the instant-extended-api
186 // flag. 198 // flag.
187 CommandLine::ForCurrentProcess()->AppendSwitch( 199 CommandLine::ForCurrentProcess()->AppendSwitch(
188 switches::kEnableInstantExtendedAPI); 200 switches::kEnableInstantExtendedAPI);
189 #endif 201 #endif
190 } 202 }
191 203
192 } // namespace search 204 } // namespace search
193 } // namespace chrome 205 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698