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(); | |
76 | |
77 // The version of contextual search. | |
78 int version; | |
79 | |
80 // Offset into content of the start of the user selection. | |
Peter Kasting
2014/06/06 17:51:33
Nit: Should "content" be "the page content" everyw
jeremycho
2014/06/06 21:51:45
Done.
| |
81 size_t start; | |
82 | |
83 // Offset into content of the end of the user selection. | |
84 size_t end; | |
85 | |
86 // The user selection. | |
87 std::string selection; | |
88 | |
89 // The text including and surrounding the user selection. | |
90 std::string content; | |
91 | |
92 // The URL of the page containing the user selection. | |
93 std::string base_page_url; | |
94 | |
95 // The encoding of content. | |
96 std::string encoding; | |
97 }; | |
98 | |
73 // The search terms (query). | 99 // The search terms (query). |
74 base::string16 search_terms; | 100 base::string16 search_terms; |
75 | 101 |
76 // The original (input) query. | 102 // The original (input) query. |
77 base::string16 original_query; | 103 base::string16 original_query; |
78 | 104 |
79 // The optional assisted query stats, aka AQS, used for logging purposes. | 105 // The optional assisted query stats, aka AQS, used for logging purposes. |
80 // This string contains impressions of all autocomplete matches shown | 106 // This string contains impressions of all autocomplete matches shown |
81 // at the query submission time. For privacy reasons, we require the | 107 // at the query submission time. For privacy reasons, we require the |
82 // search provider to support HTTPS protocol in order to receive the AQS | 108 // 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 | 159 |
134 // If set, ReplaceSearchTerms() will append a param to the TemplateURLRef to | 160 // If set, ReplaceSearchTerms() will append a param to the TemplateURLRef to |
135 // update the search results page incrementally even if that is otherwise | 161 // update the search results page incrementally even if that is otherwise |
136 // disabled by google.com preferences. See comments on | 162 // disabled by google.com preferences. See comments on |
137 // chrome::ForceInstantResultsParam(). | 163 // chrome::ForceInstantResultsParam(). |
138 bool force_instant_results; | 164 bool force_instant_results; |
139 | 165 |
140 // True if the search was made using the app list search box. Otherwise, the | 166 // True if the search was made using the app list search box. Otherwise, the |
141 // search was made using the omnibox. | 167 // search was made using the omnibox. |
142 bool from_app_list; | 168 bool from_app_list; |
169 | |
170 ContextualSearchParams contextual_search_params; | |
143 }; | 171 }; |
144 | 172 |
145 TemplateURLRef(TemplateURL* owner, Type type); | 173 TemplateURLRef(TemplateURL* owner, Type type); |
146 TemplateURLRef(TemplateURL* owner, size_t index_in_owner); | 174 TemplateURLRef(TemplateURL* owner, size_t index_in_owner); |
147 ~TemplateURLRef(); | 175 ~TemplateURLRef(); |
148 | 176 |
149 // Returns the raw URL. None of the parameters will have been replaced. | 177 // Returns the raw URL. None of the parameters will have been replaced. |
150 std::string GetURL() const; | 178 std::string GetURL() const; |
151 | 179 |
152 // Returns the raw string of the post params. Please see comments in | 180 // 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, | 292 GOOGLE_CURSOR_POSITION, |
265 GOOGLE_IMAGE_ORIGINAL_HEIGHT, | 293 GOOGLE_IMAGE_ORIGINAL_HEIGHT, |
266 GOOGLE_IMAGE_ORIGINAL_WIDTH, | 294 GOOGLE_IMAGE_ORIGINAL_WIDTH, |
267 GOOGLE_IMAGE_SEARCH_SOURCE, | 295 GOOGLE_IMAGE_SEARCH_SOURCE, |
268 GOOGLE_IMAGE_THUMBNAIL, | 296 GOOGLE_IMAGE_THUMBNAIL, |
269 GOOGLE_IMAGE_URL, | 297 GOOGLE_IMAGE_URL, |
270 GOOGLE_FORCE_INSTANT_RESULTS, | 298 GOOGLE_FORCE_INSTANT_RESULTS, |
271 GOOGLE_INSTANT_EXTENDED_ENABLED, | 299 GOOGLE_INSTANT_EXTENDED_ENABLED, |
272 GOOGLE_NTP_IS_THEMED, | 300 GOOGLE_NTP_IS_THEMED, |
273 GOOGLE_OMNIBOX_START_MARGIN, | 301 GOOGLE_OMNIBOX_START_MARGIN, |
302 GOOGLE_CONTEXTUAL_SEARCH_VERSION, | |
303 GOOGLE_CONTEXTUAL_SEARCH_CONTEXT_DATA, | |
Peter Kasting
2014/06/06 17:51:33
Nit: Should this just be named GOOGLE_CONTEXTUAL_S
jeremycho
2014/06/06 21:51:45
The struct also contains version, which is why I n
| |
274 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION, | 304 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION, |
275 GOOGLE_PAGE_CLASSIFICATION, | 305 GOOGLE_PAGE_CLASSIFICATION, |
276 GOOGLE_RLZ, | 306 GOOGLE_RLZ, |
277 GOOGLE_SEARCH_CLIENT, | 307 GOOGLE_SEARCH_CLIENT, |
278 GOOGLE_SEARCH_FIELDTRIAL_GROUP, | 308 GOOGLE_SEARCH_FIELDTRIAL_GROUP, |
279 GOOGLE_SESSION_TOKEN, | 309 GOOGLE_SESSION_TOKEN, |
280 GOOGLE_SUGGEST_CLIENT, | 310 GOOGLE_SUGGEST_CLIENT, |
281 GOOGLE_SUGGEST_REQUEST_ID, | 311 GOOGLE_SUGGEST_REQUEST_ID, |
282 GOOGLE_UNESCAPED_SEARCH_TERMS, | 312 GOOGLE_UNESCAPED_SEARCH_TERMS, |
283 LANGUAGE, | 313 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 | 467 // 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. | 468 // it requires substitutions first). This must be non-empty. |
439 void SetURL(const std::string& url); | 469 void SetURL(const std::string& url); |
440 const std::string& url() const { return url_; } | 470 const std::string& url() const { return url_; } |
441 | 471 |
442 // Optional additional raw URLs. | 472 // Optional additional raw URLs. |
443 std::string suggestions_url; | 473 std::string suggestions_url; |
444 std::string instant_url; | 474 std::string instant_url; |
445 std::string image_url; | 475 std::string image_url; |
446 std::string new_tab_url; | 476 std::string new_tab_url; |
477 std::string contextual_search_url; | |
447 | 478 |
448 // The following post_params are comma-separated lists used to specify the | 479 // The following post_params are comma-separated lists used to specify the |
449 // post parameters for the corresponding URL. | 480 // post parameters for the corresponding URL. |
450 std::string search_url_post_params; | 481 std::string search_url_post_params; |
451 std::string suggestions_url_post_params; | 482 std::string suggestions_url_post_params; |
452 std::string instant_url_post_params; | 483 std::string instant_url_post_params; |
453 std::string image_url_post_params; | 484 std::string image_url_post_params; |
454 | 485 |
455 // Optional favicon for the TemplateURL. | 486 // Optional favicon for the TemplateURL. |
456 GURL favicon_url; | 487 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. | 615 // displayed even if it is LTR and the UI is RTL. |
585 base::string16 AdjustedShortNameForLocaleDirection() const; | 616 base::string16 AdjustedShortNameForLocaleDirection() const; |
586 | 617 |
587 const base::string16& keyword() const { return data_.keyword(); } | 618 const base::string16& keyword() const { return data_.keyword(); } |
588 | 619 |
589 const std::string& url() const { return data_.url(); } | 620 const std::string& url() const { return data_.url(); } |
590 const std::string& suggestions_url() const { return data_.suggestions_url; } | 621 const std::string& suggestions_url() const { return data_.suggestions_url; } |
591 const std::string& instant_url() const { return data_.instant_url; } | 622 const std::string& instant_url() const { return data_.instant_url; } |
592 const std::string& image_url() const { return data_.image_url; } | 623 const std::string& image_url() const { return data_.image_url; } |
593 const std::string& new_tab_url() const { return data_.new_tab_url; } | 624 const std::string& new_tab_url() const { return data_.new_tab_url; } |
625 const std::string& contextual_search_url() const { | |
626 return data_.contextual_search_url; | |
627 } | |
594 const std::string& search_url_post_params() const { | 628 const std::string& search_url_post_params() const { |
595 return data_.search_url_post_params; | 629 return data_.search_url_post_params; |
596 } | 630 } |
597 const std::string& suggestions_url_post_params() const { | 631 const std::string& suggestions_url_post_params() const { |
598 return data_.suggestions_url_post_params; | 632 return data_.suggestions_url_post_params; |
599 } | 633 } |
600 const std::string& instant_url_post_params() const { | 634 const std::string& instant_url_post_params() const { |
601 return data_.instant_url_post_params; | 635 return data_.instant_url_post_params; |
602 } | 636 } |
603 const std::string& image_url_post_params() const { | 637 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; | 673 return data_.search_terms_replacement_key; |
640 } | 674 } |
641 | 675 |
642 const TemplateURLRef& url_ref() const { return url_ref_; } | 676 const TemplateURLRef& url_ref() const { return url_ref_; } |
643 const TemplateURLRef& suggestions_url_ref() const { | 677 const TemplateURLRef& suggestions_url_ref() const { |
644 return suggestions_url_ref_; | 678 return suggestions_url_ref_; |
645 } | 679 } |
646 const TemplateURLRef& instant_url_ref() const { return instant_url_ref_; } | 680 const TemplateURLRef& instant_url_ref() const { return instant_url_ref_; } |
647 const TemplateURLRef& image_url_ref() const { return image_url_ref_; } | 681 const TemplateURLRef& image_url_ref() const { return image_url_ref_; } |
648 const TemplateURLRef& new_tab_url_ref() const { return new_tab_url_ref_; } | 682 const TemplateURLRef& new_tab_url_ref() const { return new_tab_url_ref_; } |
683 const TemplateURLRef& contextual_search_url_ref() const { | |
684 return contextual_search_url_ref_; | |
685 } | |
649 | 686 |
650 // Returns true if |url| supports replacement. | 687 // Returns true if |url| supports replacement. |
651 bool SupportsReplacement() const; | 688 bool SupportsReplacement() const; |
652 | 689 |
653 // Like SupportsReplacement but usable on threads other than the UI thread. | 690 // Like SupportsReplacement but usable on threads other than the UI thread. |
654 bool SupportsReplacementUsingTermsData( | 691 bool SupportsReplacementUsingTermsData( |
655 const SearchTermsData& search_terms_data) const; | 692 const SearchTermsData& search_terms_data) const; |
656 | 693 |
657 // Returns true if any URLRefs use Googe base URLs. | 694 // Returns true if any URLRefs use Googe base URLs. |
658 bool HasGoogleBaseURLs() const; | 695 bool HasGoogleBaseURLs() const; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
769 url::Parsed::ComponentType* search_terms_component, | 806 url::Parsed::ComponentType* search_terms_component, |
770 url::Component* search_terms_position); | 807 url::Component* search_terms_position); |
771 | 808 |
772 Profile* profile_; | 809 Profile* profile_; |
773 TemplateURLData data_; | 810 TemplateURLData data_; |
774 TemplateURLRef url_ref_; | 811 TemplateURLRef url_ref_; |
775 TemplateURLRef suggestions_url_ref_; | 812 TemplateURLRef suggestions_url_ref_; |
776 TemplateURLRef instant_url_ref_; | 813 TemplateURLRef instant_url_ref_; |
777 TemplateURLRef image_url_ref_; | 814 TemplateURLRef image_url_ref_; |
778 TemplateURLRef new_tab_url_ref_; | 815 TemplateURLRef new_tab_url_ref_; |
816 TemplateURLRef contextual_search_url_ref_; | |
779 scoped_ptr<AssociatedExtensionInfo> extension_info_; | 817 scoped_ptr<AssociatedExtensionInfo> extension_info_; |
780 | 818 |
781 // TODO(sky): Add date last parsed OSD file. | 819 // TODO(sky): Add date last parsed OSD file. |
782 | 820 |
783 DISALLOW_COPY_AND_ASSIGN(TemplateURL); | 821 DISALLOW_COPY_AND_ASSIGN(TemplateURL); |
784 }; | 822 }; |
785 | 823 |
786 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ | 824 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ |
OLD | NEW |