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

Unified Diff: chrome/browser/search_engines/template_url.cc

Issue 11576044: Remove call to IsInstantExtendedAPIGoogleSearchUrl from ToolbarModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search_engines/template_url.cc
diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc
index b94d8fe95a350ec51f4f37a7fbbe99998c10ee56..69c5787bbf5bf0ef65d5de63af600c6920b367f9 100644
--- a/chrome/browser/search_engines/template_url.cc
+++ b/chrome/browser/search_engines/template_url.cc
@@ -470,8 +470,10 @@ bool TemplateURLRef::HasGoogleBaseURLs() const {
return false;
}
-bool TemplateURLRef::ExtractSearchTermsFromURL(const GURL& url,
- string16* search_terms) const {
+bool TemplateURLRef::ExtractSearchTermsFromURL(
+ const GURL& url,
+ string16* search_terms,
+ bool needs_instant_extended) const {
DCHECK(search_terms);
search_terms->clear();
@@ -501,10 +503,13 @@ bool TemplateURLRef::ExtractSearchTermsFromURL(const GURL& url,
url_parse::Component query, key, value;
query.len = static_cast<int>(params.size());
+ bool search_terms_found = false, replacement_key_found = false;
while (url_parse::ExtractQueryKeyValue(params.c_str(), &query, &key,
&value)) {
if (key.is_nonempty()) {
- if (params.substr(key.begin, key.len) == search_term_key_) {
+ base::StringPiece key_string(params.begin() + key.begin,
Peter Kasting 2012/12/18 02:09:22 Does using a StringPiece here actually buy much?
beaudoin 2012/12/20 04:40:56 Thought it may have been worth not copying charact
Peter Kasting 2012/12/20 19:40:16 I don't really care too much, the string version j
beaudoin 2013/01/08 16:55:39 Done.
+ params.begin() + key.begin + key.len);
+ if (key_string == search_term_key_) {
// Extract the search term.
*search_terms = net::UnescapeAndDecodeUTF8URLComponent(
params.substr(value.begin, value.len),
@@ -512,10 +517,22 @@ bool TemplateURLRef::ExtractSearchTermsFromURL(const GURL& url,
net::UnescapeRule::URL_SPECIAL_CHARS |
net::UnescapeRule::REPLACE_PLUS_WITH_SPACE,
NULL);
+ search_terms_found = true;
+ }
+ if (key_string == owner_->search_terms_replacement_key()) {
+ int int_value = 0;
+ if (value.is_nonempty())
+ base::StringToInt(params.substr(value.begin, value.len), &int_value);
+ if (int_value != 0)
+ replacement_key_found = true;
+ }
+ if (search_terms_found &&
+ (replacement_key_found || !needs_instant_extended)) {
return true;
}
}
}
+ search_terms->clear();
return false;
}
@@ -827,14 +844,15 @@ const std::string& TemplateURL::GetURL(size_t index) const {
}
bool TemplateURL::ExtractSearchTermsFromURL(
- const GURL& url, string16* search_terms) {
+ const GURL& url, string16* search_terms, bool needs_instant_extended) {
Peter Kasting 2012/12/18 02:09:22 Nit: One arg per line (and 1st arg can move up a l
beaudoin 2012/12/20 04:40:56 Done.
DCHECK(search_terms);
search_terms->clear();
// Then try to match with every pattern.
for (size_t i = 0; i < URLCount(); ++i) {
TemplateURLRef ref(this, i);
- if (ref.ExtractSearchTermsFromURL(url, search_terms)) {
+ if (ref.ExtractSearchTermsFromURL(url, search_terms,
+ needs_instant_extended)) {
// If ExtractSearchTermsFromURL() returns true and |search_terms| is empty
// it means the pattern matched but no search terms were present. In this
// case we fail immediately without looking for matches in subsequent
« no previous file with comments | « chrome/browser/search_engines/template_url.h ('k') | chrome/browser/search_engines/template_url_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698