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

Side by Side Diff: chrome/browser/instant/instant_controller.cc

Issue 11884037: InstantExtended: Bail on TemplateURLs with no espv. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix browsertest. 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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_controller.h" 5 #include "chrome/browser/instant/instant_controller.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 1183
1184 CommandLine* command_line = CommandLine::ForCurrentProcess(); 1184 CommandLine* command_line = CommandLine::ForCurrentProcess();
1185 if (command_line->HasSwitch(switches::kInstantURL)) { 1185 if (command_line->HasSwitch(switches::kInstantURL)) {
1186 *instant_url = command_line->GetSwitchValueASCII(switches::kInstantURL); 1186 *instant_url = command_line->GetSwitchValueASCII(switches::kInstantURL);
1187 return template_url != NULL; 1187 return template_url != NULL;
1188 } 1188 }
1189 1189
1190 if (!template_url) 1190 if (!template_url)
1191 return false; 1191 return false;
1192 1192
1193 // If the user has edited the TemplateURL, the instant_url may no longer be
1194 // correct since we won't have migrated it.
1195 if (!template_url->safe_for_autoreplace())
1196 return false;
1197
1198 // Extended mode won't work properly unless the TemplateURL supports the
1199 // param to enable it on the server.
1200 if (extended_enabled_ &&
1201 template_url->search_terms_replacement_key().empty())
1202 return false;
1203
1193 const TemplateURLRef& instant_url_ref = template_url->instant_url_ref(); 1204 const TemplateURLRef& instant_url_ref = template_url->instant_url_ref();
1194 if (!instant_url_ref.IsValid()) 1205 if (!instant_url_ref.IsValid())
1195 return false; 1206 return false;
1196 1207
1197 // Even if the URL template doesn't have search terms, it may have other 1208 // Even if the URL template doesn't have search terms, it may have other
1198 // components (such as {google:baseURL}) that need to be replaced. 1209 // components (such as {google:baseURL}) that need to be replaced.
1199 *instant_url = instant_url_ref.ReplaceSearchTerms( 1210 *instant_url = instant_url_ref.ReplaceSearchTerms(
1200 TemplateURLRef::SearchTermsArgs(string16())); 1211 TemplateURLRef::SearchTermsArgs(string16()));
1201 1212
1202 // Extended mode should always use HTTPS. TODO(sreeram): This section can be 1213 // Extended mode should always use HTTPS. TODO(sreeram): This section can be
(...skipping 22 matching lines...) Expand all
1225 std::map<std::string, int>::const_iterator iter = 1236 std::map<std::string, int>::const_iterator iter =
1226 blacklisted_urls_.find(*instant_url); 1237 blacklisted_urls_.find(*instant_url);
1227 if (iter != blacklisted_urls_.end() && 1238 if (iter != blacklisted_urls_.end() &&
1228 iter->second > kMaxInstantSupportFailures) { 1239 iter->second > kMaxInstantSupportFailures) {
1229 RecordEventHistogram(INSTANT_CONTROLLER_EVENT_URL_BLOCKED_BY_BLACKLIST); 1240 RecordEventHistogram(INSTANT_CONTROLLER_EVENT_URL_BLOCKED_BY_BLACKLIST);
1230 return false; 1241 return false;
1231 } 1242 }
1232 1243
1233 return true; 1244 return true;
1234 } 1245 }
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_browsertest.cc ('k') | chrome/browser/search_engines/template_url.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698