Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // In extended mode, the TemplateURL must not have been edited by the user, | |
| 1194 // since the instant_url is not editable and may no longer be correct. | |
| 1195 // Also, must support the param to enable InstantExtended on the server. | |
| 1196 if (extended_enabled_ && | |
| 1197 (!template_url->safe_for_autoreplace() || | |
|
samarth
2013/01/16 19:08:06
Not a big deal, but should we use the template url
sreeram
2013/01/16 19:47:24
Agreed. Let's do this even for regular mode.
Jered
2013/01/16 21:27:04
Done.
Jered
2013/01/16 21:27:04
Done.
| |
| 1198 template_url->search_terms_replacement_key().empty())) | |
| 1199 return false; | |
| 1200 | |
| 1193 const TemplateURLRef& instant_url_ref = template_url->instant_url_ref(); | 1201 const TemplateURLRef& instant_url_ref = template_url->instant_url_ref(); |
| 1194 if (!instant_url_ref.IsValid()) | 1202 if (!instant_url_ref.IsValid()) |
| 1195 return false; | 1203 return false; |
| 1196 | 1204 |
| 1197 // Even if the URL template doesn't have search terms, it may have other | 1205 // 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. | 1206 // components (such as {google:baseURL}) that need to be replaced. |
| 1199 *instant_url = instant_url_ref.ReplaceSearchTerms( | 1207 *instant_url = instant_url_ref.ReplaceSearchTerms( |
| 1200 TemplateURLRef::SearchTermsArgs(string16())); | 1208 TemplateURLRef::SearchTermsArgs(string16())); |
| 1201 | 1209 |
| 1202 // Extended mode should always use HTTPS. TODO(sreeram): This section can be | 1210 // Extended mode should always use HTTPS. TODO(sreeram): This section can be |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1225 std::map<std::string, int>::const_iterator iter = | 1233 std::map<std::string, int>::const_iterator iter = |
| 1226 blacklisted_urls_.find(*instant_url); | 1234 blacklisted_urls_.find(*instant_url); |
| 1227 if (iter != blacklisted_urls_.end() && | 1235 if (iter != blacklisted_urls_.end() && |
| 1228 iter->second > kMaxInstantSupportFailures) { | 1236 iter->second > kMaxInstantSupportFailures) { |
| 1229 RecordEventHistogram(INSTANT_CONTROLLER_EVENT_URL_BLOCKED_BY_BLACKLIST); | 1237 RecordEventHistogram(INSTANT_CONTROLLER_EVENT_URL_BLOCKED_BY_BLACKLIST); |
| 1230 return false; | 1238 return false; |
| 1231 } | 1239 } |
| 1232 | 1240 |
| 1233 return true; | 1241 return true; |
| 1234 } | 1242 } |
| OLD | NEW |