Chromium Code Reviews| 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 <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 | 46 |
| 47 // Which kind of URL within our owner we are. This allows us to get at the | 47 // Which kind of URL within our owner we are. This allows us to get at the |
| 48 // correct string field. Use |INDEXED| to indicate that the numerical | 48 // correct string field. Use |INDEXED| to indicate that the numerical |
| 49 // |index_in_owner_| should be used instead. | 49 // |index_in_owner_| should be used instead. |
| 50 enum Type { | 50 enum Type { |
| 51 SEARCH, | 51 SEARCH, |
| 52 SUGGEST, | 52 SUGGEST, |
| 53 INSTANT, | 53 INSTANT, |
| 54 IMAGE, | 54 IMAGE, |
| 55 NEW_TAB, | 55 NEW_TAB, |
| 56 CONTEXTUAL_SEARCH, | |
| 56 INDEXED | 57 INDEXED |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 // Type to store <content_type, post_data> pair for POST URLs. | 60 // Type to store <content_type, post_data> pair for POST URLs. |
| 60 // The |content_type|(first part of the pair) is the content-type of | 61 // The |content_type|(first part of the pair) is the content-type of |
| 61 // the |post_data|(second part of the pair) which is encoded in | 62 // the |post_data|(second part of the pair) which is encoded in |
| 62 // "multipart/form-data" format, it also contains the MIME boundary used in | 63 // "multipart/form-data" format, it also contains the MIME boundary used in |
| 63 // the |post_data|. See http://tools.ietf.org/html/rfc2046 for the details. | 64 // the |post_data|. See http://tools.ietf.org/html/rfc2046 for the details. |
| 64 typedef std::pair<std::string, std::string> PostContent; | 65 typedef std::pair<std::string, std::string> PostContent; |
| 65 | 66 |
| 66 // This struct encapsulates arguments passed to | 67 // This struct encapsulates arguments passed to |
| 67 // TemplateURLRef::ReplaceSearchTerms methods. By default, only search_terms | 68 // TemplateURLRef::ReplaceSearchTerms methods. By default, only search_terms |
| 68 // is required and is passed in the constructor. | 69 // is required and is passed in the constructor. |
| 69 struct SearchTermsArgs { | 70 struct SearchTermsArgs { |
| 70 explicit SearchTermsArgs(const base::string16& search_terms); | 71 explicit SearchTermsArgs(const base::string16& search_terms); |
| 71 ~SearchTermsArgs(); | 72 ~SearchTermsArgs(); |
| 72 | 73 |
| 74 struct ContextualSearchParams { | |
| 75 ContextualSearchParams() : version(-1), start(-1), end(-1) { | |
|
Peter Kasting
2014/06/04 00:40:49
It's surprising you don't have a 6-arg variant to
jeremycho
2014/06/04 21:49:35
If it's being used in a /search, then only version
| |
| 76 } | |
| 77 | |
| 78 // The version of contextual search. | |
| 79 int version; | |
| 80 | |
| 81 // Offset into content of the start of the user selection. | |
| 82 int start; | |
|
Peter Kasting
2014/06/04 00:40:49
These should probably be size_ts and use npos to r
jeremycho
2014/06/04 21:49:35
Done.
| |
| 83 | |
| 84 // Offset into content of the end of the user selection. | |
| 85 int end; | |
| 86 | |
| 87 // The text including and surrounding the user selection. | |
| 88 std::string content; | |
| 89 | |
| 90 // The URL of the page containing the user selection. | |
| 91 std::string base_page_url; | |
| 92 | |
| 93 // The encoding of content. | |
| 94 std::string encoding; | |
| 95 }; | |
| 96 | |
| 73 // The search terms (query). | 97 // The search terms (query). |
| 74 base::string16 search_terms; | 98 base::string16 search_terms; |
| 75 | 99 |
| 76 // The original (input) query. | 100 // The original (input) query. |
| 77 base::string16 original_query; | 101 base::string16 original_query; |
| 78 | 102 |
| 79 // The optional assisted query stats, aka AQS, used for logging purposes. | 103 // The optional assisted query stats, aka AQS, used for logging purposes. |
| 80 // This string contains impressions of all autocomplete matches shown | 104 // This string contains impressions of all autocomplete matches shown |
| 81 // at the query submission time. For privacy reasons, we require the | 105 // at the query submission time. For privacy reasons, we require the |
| 82 // search provider to support HTTPS protocol in order to receive the AQS | 106 // search provider to support HTTPS protocol in order to receive the AQS |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 | 157 |
| 134 // If set, ReplaceSearchTerms() will append a param to the TemplateURLRef to | 158 // If set, ReplaceSearchTerms() will append a param to the TemplateURLRef to |
| 135 // update the search results page incrementally even if that is otherwise | 159 // update the search results page incrementally even if that is otherwise |
| 136 // disabled by google.com preferences. See comments on | 160 // disabled by google.com preferences. See comments on |
| 137 // chrome::ForceInstantResultsParam(). | 161 // chrome::ForceInstantResultsParam(). |
| 138 bool force_instant_results; | 162 bool force_instant_results; |
| 139 | 163 |
| 140 // True if the search was made using the app list search box. Otherwise, the | 164 // True if the search was made using the app list search box. Otherwise, the |
| 141 // search was made using the omnibox. | 165 // search was made using the omnibox. |
| 142 bool from_app_list; | 166 bool from_app_list; |
| 167 | |
| 168 ContextualSearchParams contextual_search_params; | |
| 143 }; | 169 }; |
| 144 | 170 |
| 145 TemplateURLRef(TemplateURL* owner, Type type); | 171 TemplateURLRef(TemplateURL* owner, Type type); |
| 146 TemplateURLRef(TemplateURL* owner, size_t index_in_owner); | 172 TemplateURLRef(TemplateURL* owner, size_t index_in_owner); |
| 147 ~TemplateURLRef(); | 173 ~TemplateURLRef(); |
| 148 | 174 |
| 149 // Returns the raw URL. None of the parameters will have been replaced. | 175 // Returns the raw URL. None of the parameters will have been replaced. |
| 150 std::string GetURL() const; | 176 std::string GetURL() const; |
| 151 | 177 |
| 152 // Returns the raw string of the post params. Please see comments in | 178 // Returns the raw string of the post params. Please see comments in |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 GOOGLE_CURSOR_POSITION, | 290 GOOGLE_CURSOR_POSITION, |
| 265 GOOGLE_IMAGE_ORIGINAL_HEIGHT, | 291 GOOGLE_IMAGE_ORIGINAL_HEIGHT, |
| 266 GOOGLE_IMAGE_ORIGINAL_WIDTH, | 292 GOOGLE_IMAGE_ORIGINAL_WIDTH, |
| 267 GOOGLE_IMAGE_SEARCH_SOURCE, | 293 GOOGLE_IMAGE_SEARCH_SOURCE, |
| 268 GOOGLE_IMAGE_THUMBNAIL, | 294 GOOGLE_IMAGE_THUMBNAIL, |
| 269 GOOGLE_IMAGE_URL, | 295 GOOGLE_IMAGE_URL, |
| 270 GOOGLE_FORCE_INSTANT_RESULTS, | 296 GOOGLE_FORCE_INSTANT_RESULTS, |
| 271 GOOGLE_INSTANT_EXTENDED_ENABLED, | 297 GOOGLE_INSTANT_EXTENDED_ENABLED, |
| 272 GOOGLE_NTP_IS_THEMED, | 298 GOOGLE_NTP_IS_THEMED, |
| 273 GOOGLE_OMNIBOX_START_MARGIN, | 299 GOOGLE_OMNIBOX_START_MARGIN, |
| 300 GOOGLE_CONTEXTUAL_SEARCH_VERSION, | |
| 301 GOOGLE_CONTEXTUAL_SEARCH_START, | |
| 302 GOOGLE_CONTEXTUAL_SEARCH_END, | |
| 303 GOOGLE_CONTEXTUAL_SEARCH_CONTENT, | |
| 304 GOOGLE_CONTEXTUAL_SEARCH_BASE_PAGE_URL, | |
| 305 GOOGLE_CONTEXTUAL_SEARCH_ENCODING, | |
| 274 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION, | 306 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION, |
| 275 GOOGLE_PAGE_CLASSIFICATION, | 307 GOOGLE_PAGE_CLASSIFICATION, |
| 276 GOOGLE_RLZ, | 308 GOOGLE_RLZ, |
| 277 GOOGLE_SEARCH_CLIENT, | 309 GOOGLE_SEARCH_CLIENT, |
| 278 GOOGLE_SEARCH_FIELDTRIAL_GROUP, | 310 GOOGLE_SEARCH_FIELDTRIAL_GROUP, |
| 279 GOOGLE_SESSION_TOKEN, | 311 GOOGLE_SESSION_TOKEN, |
| 280 GOOGLE_SUGGEST_CLIENT, | 312 GOOGLE_SUGGEST_CLIENT, |
| 281 GOOGLE_SUGGEST_REQUEST_ID, | 313 GOOGLE_SUGGEST_REQUEST_ID, |
| 282 GOOGLE_UNESCAPED_SEARCH_TERMS, | 314 GOOGLE_UNESCAPED_SEARCH_TERMS, |
| 283 LANGUAGE, | 315 LANGUAGE, |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 // The raw URL for the TemplateURL, which may not be valid as-is (e.g. because | 469 // The raw URL for the TemplateURL, which may not be valid as-is (e.g. because |
| 438 // it requires substitutions first). This must be non-empty. | 470 // it requires substitutions first). This must be non-empty. |
| 439 void SetURL(const std::string& url); | 471 void SetURL(const std::string& url); |
| 440 const std::string& url() const { return url_; } | 472 const std::string& url() const { return url_; } |
| 441 | 473 |
| 442 // Optional additional raw URLs. | 474 // Optional additional raw URLs. |
| 443 std::string suggestions_url; | 475 std::string suggestions_url; |
| 444 std::string instant_url; | 476 std::string instant_url; |
| 445 std::string image_url; | 477 std::string image_url; |
| 446 std::string new_tab_url; | 478 std::string new_tab_url; |
| 479 std::string contextual_search_url; | |
| 447 | 480 |
| 448 // The following post_params are comma-separated lists used to specify the | 481 // The following post_params are comma-separated lists used to specify the |
| 449 // post parameters for the corresponding URL. | 482 // post parameters for the corresponding URL. |
| 450 std::string search_url_post_params; | 483 std::string search_url_post_params; |
| 451 std::string suggestions_url_post_params; | 484 std::string suggestions_url_post_params; |
| 452 std::string instant_url_post_params; | 485 std::string instant_url_post_params; |
| 453 std::string image_url_post_params; | 486 std::string image_url_post_params; |
| 454 | 487 |
| 455 // Optional favicon for the TemplateURL. | 488 // Optional favicon for the TemplateURL. |
| 456 GURL favicon_url; | 489 GURL favicon_url; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 // displayed even if it is LTR and the UI is RTL. | 617 // displayed even if it is LTR and the UI is RTL. |
| 585 base::string16 AdjustedShortNameForLocaleDirection() const; | 618 base::string16 AdjustedShortNameForLocaleDirection() const; |
| 586 | 619 |
| 587 const base::string16& keyword() const { return data_.keyword(); } | 620 const base::string16& keyword() const { return data_.keyword(); } |
| 588 | 621 |
| 589 const std::string& url() const { return data_.url(); } | 622 const std::string& url() const { return data_.url(); } |
| 590 const std::string& suggestions_url() const { return data_.suggestions_url; } | 623 const std::string& suggestions_url() const { return data_.suggestions_url; } |
| 591 const std::string& instant_url() const { return data_.instant_url; } | 624 const std::string& instant_url() const { return data_.instant_url; } |
| 592 const std::string& image_url() const { return data_.image_url; } | 625 const std::string& image_url() const { return data_.image_url; } |
| 593 const std::string& new_tab_url() const { return data_.new_tab_url; } | 626 const std::string& new_tab_url() const { return data_.new_tab_url; } |
| 627 const std::string& contextual_search_url() const { | |
| 628 return data_.contextual_search_url; | |
| 629 } | |
| 594 const std::string& search_url_post_params() const { | 630 const std::string& search_url_post_params() const { |
| 595 return data_.search_url_post_params; | 631 return data_.search_url_post_params; |
| 596 } | 632 } |
| 597 const std::string& suggestions_url_post_params() const { | 633 const std::string& suggestions_url_post_params() const { |
| 598 return data_.suggestions_url_post_params; | 634 return data_.suggestions_url_post_params; |
| 599 } | 635 } |
| 600 const std::string& instant_url_post_params() const { | 636 const std::string& instant_url_post_params() const { |
| 601 return data_.instant_url_post_params; | 637 return data_.instant_url_post_params; |
| 602 } | 638 } |
| 603 const std::string& image_url_post_params() const { | 639 const std::string& image_url_post_params() const { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 639 return data_.search_terms_replacement_key; | 675 return data_.search_terms_replacement_key; |
| 640 } | 676 } |
| 641 | 677 |
| 642 const TemplateURLRef& url_ref() const { return url_ref_; } | 678 const TemplateURLRef& url_ref() const { return url_ref_; } |
| 643 const TemplateURLRef& suggestions_url_ref() const { | 679 const TemplateURLRef& suggestions_url_ref() const { |
| 644 return suggestions_url_ref_; | 680 return suggestions_url_ref_; |
| 645 } | 681 } |
| 646 const TemplateURLRef& instant_url_ref() const { return instant_url_ref_; } | 682 const TemplateURLRef& instant_url_ref() const { return instant_url_ref_; } |
| 647 const TemplateURLRef& image_url_ref() const { return image_url_ref_; } | 683 const TemplateURLRef& image_url_ref() const { return image_url_ref_; } |
| 648 const TemplateURLRef& new_tab_url_ref() const { return new_tab_url_ref_; } | 684 const TemplateURLRef& new_tab_url_ref() const { return new_tab_url_ref_; } |
| 685 const TemplateURLRef& contextual_search_url_ref() const { | |
| 686 return contextual_search_url_ref_; | |
| 687 } | |
| 649 | 688 |
| 650 // Returns true if |url| supports replacement. | 689 // Returns true if |url| supports replacement. |
| 651 bool SupportsReplacement() const; | 690 bool SupportsReplacement() const; |
| 652 | 691 |
| 653 // Like SupportsReplacement but usable on threads other than the UI thread. | 692 // Like SupportsReplacement but usable on threads other than the UI thread. |
| 654 bool SupportsReplacementUsingTermsData( | 693 bool SupportsReplacementUsingTermsData( |
| 655 const SearchTermsData& search_terms_data) const; | 694 const SearchTermsData& search_terms_data) const; |
| 656 | 695 |
| 657 // Returns true if any URLRefs use Googe base URLs. | 696 // Returns true if any URLRefs use Googe base URLs. |
| 658 bool HasGoogleBaseURLs() const; | 697 bool HasGoogleBaseURLs() const; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 769 url::Parsed::ComponentType* search_terms_component, | 808 url::Parsed::ComponentType* search_terms_component, |
| 770 url::Component* search_terms_position); | 809 url::Component* search_terms_position); |
| 771 | 810 |
| 772 Profile* profile_; | 811 Profile* profile_; |
| 773 TemplateURLData data_; | 812 TemplateURLData data_; |
| 774 TemplateURLRef url_ref_; | 813 TemplateURLRef url_ref_; |
| 775 TemplateURLRef suggestions_url_ref_; | 814 TemplateURLRef suggestions_url_ref_; |
| 776 TemplateURLRef instant_url_ref_; | 815 TemplateURLRef instant_url_ref_; |
| 777 TemplateURLRef image_url_ref_; | 816 TemplateURLRef image_url_ref_; |
| 778 TemplateURLRef new_tab_url_ref_; | 817 TemplateURLRef new_tab_url_ref_; |
| 818 TemplateURLRef contextual_search_url_ref_; | |
| 779 scoped_ptr<AssociatedExtensionInfo> extension_info_; | 819 scoped_ptr<AssociatedExtensionInfo> extension_info_; |
| 780 | 820 |
| 781 // TODO(sky): Add date last parsed OSD file. | 821 // TODO(sky): Add date last parsed OSD file. |
| 782 | 822 |
| 783 DISALLOW_COPY_AND_ASSIGN(TemplateURL); | 823 DISALLOW_COPY_AND_ASSIGN(TemplateURL); |
| 784 }; | 824 }; |
| 785 | 825 |
| 786 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ | 826 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ |
| OLD | NEW |