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

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

Issue 12623029: Upstreaming mechanism to add query refinement to omnibox searches. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed ChromeOS. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search_engines/template_url.h
diff --git a/chrome/browser/search_engines/template_url.h b/chrome/browser/search_engines/template_url.h
index a8f41125e06bc3da19853be2bef68f3f5e40f961..e2a1a597e6085e830501bbfa41a3e92da018e07a 100644
--- a/chrome/browser/search_engines/template_url.h
+++ b/chrome/browser/search_engines/template_url.h
@@ -142,12 +142,18 @@ class TemplateURLRef {
// Use the pattern referred to by this TemplateURLRef to match the provided
// |url| and extract |search_terms| from it. Returns true if the pattern
- // matches, even if |search_terms| is empty. Returns false and an empty
- // |search_terms| if the pattern does not match.
+ // matches, even if |search_terms| is empty. In this case
+ // |search_term_location|, if not NULL, indicates whether the search terms
+ // were found in the query or the ref parameters; and |search_terms_position|,
+ // if not NULL, contains the position of the search terms in the query or the
+ // ref parameters. Returns false and an empty |search_terms| if the pattern
+ // does not match.
bool ExtractSearchTermsFromURL(
const GURL& url,
string16* search_terms,
- const SearchTermsData& search_terms_data) const;
+ const SearchTermsData& search_terms_data,
+ url_parse::Parsed::ComponentType* search_term_location,
Peter Kasting 2013/03/22 20:20:06 Nit: I suggest |search_term_component| here and in
beaudoin 2013/03/22 23:10:43 Done.
beaudoin 2013/03/22 23:10:43 Done.
+ url_parse::Component* search_terms_position) const;
private:
friend class TemplateURL;
@@ -514,6 +520,27 @@ class TemplateURL {
// InstantExtended capable URL.
bool HasSearchTermsReplacementKey(const GURL& url) const;
+ // Given a |url| corresponding to this TemplateURL, identifies the search
+ // terms and replace them with the ones in |search_terms_args|, leaving the
Peter Kasting 2013/03/22 20:20:06 Nit: replace -> replaces
beaudoin 2013/03/22 23:10:43 Done.
+ // other parameters untouched. If the replacement fails, returns false and
+ // leaves |result| untouched.
+ bool ReplaceSearchTermsInURL(
Peter Kasting 2013/03/22 20:20:06 As with autocomplete_input.h, I'd specifically not
beaudoin 2013/03/22 23:10:43 I hope to upstream the call to this too, and make
+ const GURL& url,
+ const TemplateURLRef::SearchTermsArgs& search_terms_args,
+ GURL* result);
+
+ // Encode the search terms from |search_terms_args| so that we know the
Peter Kasting 2013/03/22 20:20:06 Nit: Encode -> Encodes
beaudoin 2013/03/22 23:10:43 Done.
+ // |input_encoding|. Returns the |encoded_terms| and the
+ // |encoded_original_query|. |encoded_terms| may be escaped as path or query
+ // depending on |is_in_query|; |encoded_original_query| is always escaped as
+ // query.
+ void EncodeSearchTerms(
+ const TemplateURLRef::SearchTermsArgs& search_terms_args,
+ bool is_in_query,
+ std::string* input_encoding,
+ string16* encoded_terms,
+ string16* encoded_original_query) const;
+
private:
friend class TemplateURLService;
@@ -529,6 +556,17 @@ class TemplateURL {
// TemplateURLService::GenerateKeyword().
void ResetKeywordIfNecessary(bool force);
+ // Use the alternate URLs and the search URL to match the provided |url|
Peter Kasting 2013/03/22 20:20:06 Nit: Use -> Uses
beaudoin 2013/03/22 23:10:43 Done.
+ // and extract |search_terms| from it as well as the |search_terms_location|
+ // (either REF or QUERY) and |search_terms_location| at which the
+ // |search_terms| are found in |url|. See also ExtractSearchTermsFromURL().
+ bool FindSearchTermsInURL(
+ const GURL& url,
+ const SearchTermsData& search_terms_data,
+ string16* search_terms,
+ url_parse::Parsed::ComponentType* search_terms_location,
+ url_parse::Component* search_terms_position);
+
Profile* profile_;
TemplateURLData data_;
TemplateURLRef url_ref_;

Powered by Google App Engine
This is Rietveld 408576698