| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ |
| 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ | 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 // This struct encapsulates arguments passed to | 53 // This struct encapsulates arguments passed to |
| 54 // TemplateURLRef::ReplaceSearchTerms methods. By default, only search_terms | 54 // TemplateURLRef::ReplaceSearchTerms methods. By default, only search_terms |
| 55 // is required and is passed in the constructor. | 55 // is required and is passed in the constructor. |
| 56 struct SearchTermsArgs { | 56 struct SearchTermsArgs { |
| 57 explicit SearchTermsArgs(const string16& search_terms); | 57 explicit SearchTermsArgs(const string16& search_terms); |
| 58 ~SearchTermsArgs(); | 58 ~SearchTermsArgs(); |
| 59 | 59 |
| 60 // The search terms (query). | 60 // The search terms (query). |
| 61 const string16 search_terms; | 61 string16 search_terms; |
| 62 |
| 62 // The original (input) query. | 63 // The original (input) query. |
| 63 string16 original_query; | 64 string16 original_query; |
| 65 |
| 64 // The optional assisted query stats, aka AQS, used for logging purposes. | 66 // The optional assisted query stats, aka AQS, used for logging purposes. |
| 65 // This string contains impressions of all autocomplete matches shown | 67 // This string contains impressions of all autocomplete matches shown |
| 66 // at the query submission time. For privacy reasons, we require the | 68 // at the query submission time. For privacy reasons, we require the |
| 67 // search provider to support HTTPS protocol in order to receive the AQS | 69 // search provider to support HTTPS protocol in order to receive the AQS |
| 68 // param. | 70 // param. |
| 69 // For more details, see http://goto.google.com/binary-clients-logging . | 71 // For more details, see http://goto.google.com/binary-clients-logging . |
| 70 std::string assisted_query_stats; | 72 std::string assisted_query_stats; |
| 71 | 73 |
| 72 // TODO: Remove along with "aq" CGI param. | 74 // TODO: Remove along with "aq" CGI param. |
| 73 int accepted_suggestion; | 75 int accepted_suggestion; |
| 74 | 76 |
| 75 // The 0-based position of the cursor within the query string at the time | 77 // The 0-based position of the cursor within the query string at the time |
| 76 // the request was issued. Set to string16::npos if not used. | 78 // the request was issued. Set to string16::npos if not used. |
| 77 size_t cursor_position; | 79 size_t cursor_position; |
| 78 | 80 |
| 79 // The start-edge margin of the omnibox in pixels, used in extended Instant | 81 // The start-edge margin of the omnibox in pixels, used in extended Instant |
| 80 // to align the preview contents with the omnibox. | 82 // to align the preview contents with the omnibox. |
| 81 int omnibox_start_margin; | 83 int omnibox_start_margin; |
| 82 | 84 |
| 83 // The URL of the current webpage to be used for experimental zero-prefix | 85 // The URL of the current webpage to be used for experimental zero-prefix |
| 84 // suggestions. | 86 // suggestions. |
| 85 std::string zero_prefix_url; | 87 std::string zero_prefix_url; |
| 88 |
| 89 // If set, ReplaceSearchTerms() will automatically append any extra query |
| 90 // params specified via the --extra-search-query-params command-line |
| 91 // argument. Generally, this should be set when dealing with the search or |
| 92 // instant TemplateURLRefs of the default search engine and the caller cares |
| 93 // about the query portion of the URL. Since neither TemplateURLRef nor |
| 94 // indeed TemplateURL know whether a TemplateURL is the default search |
| 95 // engine, callers instead must set this manually. |
| 96 bool append_extra_query_params; |
| 86 }; | 97 }; |
| 87 | 98 |
| 88 TemplateURLRef(TemplateURL* owner, Type type); | 99 TemplateURLRef(TemplateURL* owner, Type type); |
| 89 TemplateURLRef(TemplateURL* owner, size_t index_in_owner); | 100 TemplateURLRef(TemplateURL* owner, size_t index_in_owner); |
| 90 ~TemplateURLRef(); | 101 ~TemplateURLRef(); |
| 91 | 102 |
| 92 // Returns the raw URL. None of the parameters will have been replaced. | 103 // Returns the raw URL. None of the parameters will have been replaced. |
| 93 std::string GetURL() const; | 104 std::string GetURL() const; |
| 94 | 105 |
| 95 // Returns true if this URL supports replacement. | 106 // Returns true if this URL supports replacement. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 void ParseIfNecessary() const; | 248 void ParseIfNecessary() const; |
| 238 | 249 |
| 239 // Like ParseIfNecessary but usable on threads other than the UI thread. | 250 // Like ParseIfNecessary but usable on threads other than the UI thread. |
| 240 void ParseIfNecessaryUsingTermsData( | 251 void ParseIfNecessaryUsingTermsData( |
| 241 const SearchTermsData& search_terms_data) const; | 252 const SearchTermsData& search_terms_data) const; |
| 242 | 253 |
| 243 // Extracts the query key and host from the url. | 254 // Extracts the query key and host from the url. |
| 244 void ParseHostAndSearchTermKey( | 255 void ParseHostAndSearchTermKey( |
| 245 const SearchTermsData& search_terms_data) const; | 256 const SearchTermsData& search_terms_data) const; |
| 246 | 257 |
| 258 // Replaces all replacements in |parsed_url_| with their actual values and |
| 259 // returns the result. This is the main functionality of |
| 260 // ReplaceSearchTermsUsingTermsData(). |
| 261 std::string HandleReplacements( |
| 262 const SearchTermsArgs& search_terms_args, |
| 263 const SearchTermsData& search_terms_data) const; |
| 264 |
| 247 // The TemplateURL that contains us. This should outlive us. | 265 // The TemplateURL that contains us. This should outlive us. |
| 248 TemplateURL* const owner_; | 266 TemplateURL* const owner_; |
| 249 | 267 |
| 250 // What kind of URL we are. | 268 // What kind of URL we are. |
| 251 const Type type_; | 269 const Type type_; |
| 252 | 270 |
| 253 // If |type_| is |INDEXED|, this |index_in_owner_| is used instead to refer to | 271 // If |type_| is |INDEXED|, this |index_in_owner_| is used instead to refer to |
| 254 // a url within our owner. | 272 // a url within our owner. |
| 255 const size_t index_in_owner_; | 273 const size_t index_in_owner_; |
| 256 | 274 |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 TemplateURLRef url_ref_; | 599 TemplateURLRef url_ref_; |
| 582 TemplateURLRef suggestions_url_ref_; | 600 TemplateURLRef suggestions_url_ref_; |
| 583 TemplateURLRef instant_url_ref_; | 601 TemplateURLRef instant_url_ref_; |
| 584 | 602 |
| 585 // TODO(sky): Add date last parsed OSD file. | 603 // TODO(sky): Add date last parsed OSD file. |
| 586 | 604 |
| 587 DISALLOW_COPY_AND_ASSIGN(TemplateURL); | 605 DISALLOW_COPY_AND_ASSIGN(TemplateURL); |
| 588 }; | 606 }; |
| 589 | 607 |
| 590 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ | 608 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ |
| OLD | NEW |