| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_ | 5 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_ |
| 6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_ | 6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // the host/path of the URL, otherwise this returns an empty string. | 231 // the host/path of the URL, otherwise this returns an empty string. |
| 232 const std::string& GetHost(const SearchTermsData& search_terms_data) const; | 232 const std::string& GetHost(const SearchTermsData& search_terms_data) const; |
| 233 const std::string& GetPath(const SearchTermsData& search_terms_data) const; | 233 const std::string& GetPath(const SearchTermsData& search_terms_data) const; |
| 234 | 234 |
| 235 // If this TemplateURLRef is valid and contains one search term | 235 // If this TemplateURLRef is valid and contains one search term |
| 236 // in its query or ref, this returns the key of the search term, | 236 // in its query or ref, this returns the key of the search term, |
| 237 // otherwise this returns an empty string. | 237 // otherwise this returns an empty string. |
| 238 const std::string& GetSearchTermKey( | 238 const std::string& GetSearchTermKey( |
| 239 const SearchTermsData& search_terms_data) const; | 239 const SearchTermsData& search_terms_data) const; |
| 240 | 240 |
| 241 // If this TemplateURLRef is valid and contains one search term | |
| 242 // in its path, this returns the length of the subpath before the search term, | |
| 243 // otherwise this returns std::string::npos. | |
| 244 size_t GetSearchTermPositionInPath( | |
| 245 const SearchTermsData& search_terms_data) const; | |
| 246 | |
| 247 // If this TemplateURLRef is valid and contains one search term, | 241 // If this TemplateURLRef is valid and contains one search term, |
| 248 // this returns the location of the search term, | 242 // this returns the location of the search term, |
| 249 // otherwise this returns url::Parsed::QUERY. | 243 // otherwise this returns url::Parsed::QUERY. |
| 250 url::Parsed::ComponentType GetSearchTermKeyLocation( | 244 url::Parsed::ComponentType GetSearchTermKeyLocation( |
| 251 const SearchTermsData& search_terms_data) const; | 245 const SearchTermsData& search_terms_data) const; |
| 252 | 246 |
| 247 // If this TemplateURLRef is valid and contains one search term, |
| 248 // this returns the fixed prefix before the search term, |
| 249 // otherwise this returns an empty string. |
| 250 const std::string& GetSearchTermValuePrefix( |
| 251 const SearchTermsData& search_terms_data) const; |
| 252 |
| 253 // If this TemplateURLRef is valid and contains one search term, |
| 254 // this returns the fixed suffix after the search term, |
| 255 // otherwise this returns an empty string. |
| 256 const std::string& GetSearchTermValueSuffix( |
| 257 const SearchTermsData& search_terms_data) const; |
| 258 |
| 253 // Converts the specified term in our owner's encoding to a base::string16. | 259 // Converts the specified term in our owner's encoding to a base::string16. |
| 254 base::string16 SearchTermToString16(const std::string& term) const; | 260 base::string16 SearchTermToString16(const base::StringPiece& term) const; |
| 255 | 261 |
| 256 // Returns true if this TemplateURLRef has a replacement term of | 262 // Returns true if this TemplateURLRef has a replacement term of |
| 257 // {google:baseURL} or {google:baseSuggestURL}. | 263 // {google:baseURL} or {google:baseSuggestURL}. |
| 258 bool HasGoogleBaseURLs(const SearchTermsData& search_terms_data) const; | 264 bool HasGoogleBaseURLs(const SearchTermsData& search_terms_data) const; |
| 259 | 265 |
| 260 // Use the pattern referred to by this TemplateURLRef to match the provided | 266 // Use the pattern referred to by this TemplateURLRef to match the provided |
| 261 // |url| and extract |search_terms| from it. Returns true if the pattern | 267 // |url| and extract |search_terms| from it. Returns true if the pattern |
| 262 // matches, even if |search_terms| is empty. In this case | 268 // matches, even if |search_terms| is empty. In this case |
| 263 // |search_term_component|, if not NULL, indicates whether the search terms | 269 // |search_term_component|, if not NULL, indicates whether the search terms |
| 264 // were found in the query or the ref parameters; and |search_terms_position|, | 270 // were found in the query or the ref parameters; and |search_terms_position|, |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // The replaceable parts of url (parsed_url_). These are ordered by index | 441 // The replaceable parts of url (parsed_url_). These are ordered by index |
| 436 // into the string, and may be empty. | 442 // into the string, and may be empty. |
| 437 mutable Replacements replacements_; | 443 mutable Replacements replacements_; |
| 438 | 444 |
| 439 // Host, port, path, key and location of the search term. These are only set | 445 // Host, port, path, key and location of the search term. These are only set |
| 440 // if the url contains one search term. | 446 // if the url contains one search term. |
| 441 mutable std::string host_; | 447 mutable std::string host_; |
| 442 mutable std::string port_; | 448 mutable std::string port_; |
| 443 mutable std::string path_; | 449 mutable std::string path_; |
| 444 mutable std::string search_term_key_; | 450 mutable std::string search_term_key_; |
| 445 mutable size_t search_term_position_in_path_; | |
| 446 mutable url::Parsed::ComponentType search_term_key_location_; | 451 mutable url::Parsed::ComponentType search_term_key_location_; |
| 447 mutable std::string search_term_value_prefix_; | 452 mutable std::string search_term_value_prefix_; |
| 448 mutable std::string search_term_value_suffix_; | 453 mutable std::string search_term_value_suffix_; |
| 449 | 454 |
| 450 mutable PostParams post_params_; | 455 mutable PostParams post_params_; |
| 451 | 456 |
| 452 // Whether the contained URL is a pre-populated URL. | 457 // Whether the contained URL is a pre-populated URL. |
| 453 bool prepopulated_; | 458 bool prepopulated_; |
| 454 }; | 459 }; |
| 455 | 460 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 | 749 |
| 745 // Caches the computed engine type across successive calls to GetEngineType(). | 750 // Caches the computed engine type across successive calls to GetEngineType(). |
| 746 mutable SearchEngineType engine_type_; | 751 mutable SearchEngineType engine_type_; |
| 747 | 752 |
| 748 // TODO(sky): Add date last parsed OSD file. | 753 // TODO(sky): Add date last parsed OSD file. |
| 749 | 754 |
| 750 DISALLOW_COPY_AND_ASSIGN(TemplateURL); | 755 DISALLOW_COPY_AND_ASSIGN(TemplateURL); |
| 751 }; | 756 }; |
| 752 | 757 |
| 753 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_ | 758 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_ |
| OLD | NEW |