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

Unified Diff: components/search_engines/template_url.h

Issue 1978553002: Refactor extracting search terms from Template URL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@support-prefix-path-matching-when-extracting-terms-from-template-url
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | components/search_engines/template_url.cc » ('j') | components/search_engines/template_url.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/search_engines/template_url.h
diff --git a/components/search_engines/template_url.h b/components/search_engines/template_url.h
index 2acb146851887d0f8246dbf56c4b60071374d097..5519069a4a65538a0336187764318f17f7d12ade 100644
--- a/components/search_engines/template_url.h
+++ b/components/search_engines/template_url.h
@@ -261,18 +261,24 @@ class TemplateURLRef {
const std::string& GetSearchTermKey(
const SearchTermsData& search_terms_data) const;
- // If this TemplateURLRef is valid and contains one search term
- // in its path, this returns the length of the subpath before the search term,
- // otherwise this returns std::string::npos.
- size_t GetSearchTermPositionInPath(
- const SearchTermsData& search_terms_data) const;
-
// If this TemplateURLRef is valid and contains one search term,
// this returns the location of the search term,
// otherwise this returns url::Parsed::QUERY.
url::Parsed::ComponentType GetSearchTermKeyLocation(
const SearchTermsData& search_terms_data) const;
+ // If this TemplateURLRef is valid and contains one search term,
+ // this returns the fixed prefix of the value of the search term,
+ // otherwise this returns an empty string.
+ const std::string& GetSearchTermValuePrefix(
+ const SearchTermsData& search_terms_data) const;
+
+ // If this TemplateURLRef is valid and contains one search term,
+ // this returns the fixed suffix of the value of the search term,
+ // otherwise this returns an empty string.
+ const std::string& GetSearchTermValueSuffix(
+ const SearchTermsData& search_terms_data) const;
+
// Converts the specified term in our owner's encoding to a base::string16.
base::string16 SearchTermToString16(const std::string& term) const;
@@ -369,6 +375,12 @@ class TemplateURLRef {
typedef std::vector<struct Replacement> Replacements;
typedef std::vector<PostParam> PostParams;
+ // Checks that |path| matches to this TemplateURLRef's path and
+ // extracts the position of the search terms inside |path|.
+ // This is a helper function for extracting search terms from URL.
+ bool ExtractSearchTermsFromPath(const std::string& path,
+ url::Component* search_terms_position) const;
+
// TemplateURLRef internally caches values to make replacement quick. This
// method invalidates any cached values.
void InvalidateCachedValues() const;
@@ -465,7 +477,6 @@ class TemplateURLRef {
mutable std::string port_;
mutable std::string path_;
mutable std::string search_term_key_;
- mutable size_t search_term_position_in_path_;
mutable url::Parsed::ComponentType search_term_key_location_;
mutable std::string search_term_value_prefix_;
mutable std::string search_term_value_suffix_;
« no previous file with comments | « no previous file | components/search_engines/template_url.cc » ('j') | components/search_engines/template_url.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698