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 |
(...skipping 22 matching lines...) Expand all Loading... | |
88 int accepted_suggestion; | 89 int accepted_suggestion; |
89 | 90 |
90 // The 0-based position of the cursor within the query string at the time | 91 // The 0-based position of the cursor within the query string at the time |
91 // the request was issued. Set to base::string16::npos if not used. | 92 // the request was issued. Set to base::string16::npos if not used. |
92 size_t cursor_position; | 93 size_t cursor_position; |
93 | 94 |
94 // The start-edge margin of the omnibox in pixels, used in extended Instant | 95 // The start-edge margin of the omnibox in pixels, used in extended Instant |
95 // to align the preview contents with the omnibox. | 96 // to align the preview contents with the omnibox. |
96 int omnibox_start_margin; | 97 int omnibox_start_margin; |
97 | 98 |
99 // The version of contextual search. | |
100 int contextual_search_version; | |
101 | |
102 // Offset into contextual_search_content of the start of the user selection. | |
103 int contextual_search_start; | |
104 | |
105 // Offset into contextual_search_content of the end of the user selection. | |
106 int contextual_search_end; | |
107 | |
108 // The text including and surrounding the user selection. | |
109 std::string contextual_search_content; | |
110 | |
111 // The encoding of contextual_search_content. | |
112 std::string contextual_search_encoding; | |
113 | |
pedro (no code reviews)
2014/06/02 17:39:51
What about the page's URL?
donnd
2014/06/02 18:09:46
+1
jeremycho
2014/06/02 21:24:08
Done.
| |
98 // The URL of the current webpage to be used for experimental zero-prefix | 114 // The URL of the current webpage to be used for experimental zero-prefix |
99 // suggestions. | 115 // suggestions. |
100 std::string current_page_url; | 116 std::string current_page_url; |
101 | 117 |
102 // Which omnibox the user used to type the prefix. | 118 // Which omnibox the user used to type the prefix. |
103 AutocompleteInput::PageClassification page_classification; | 119 AutocompleteInput::PageClassification page_classification; |
104 | 120 |
105 // True for searches issued with the bookmark bar pref set to shown. | 121 // True for searches issued with the bookmark bar pref set to shown. |
106 bool bookmark_bar_pinned; | 122 bool bookmark_bar_pinned; |
107 | 123 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 GOOGLE_CURSOR_POSITION, | 280 GOOGLE_CURSOR_POSITION, |
265 GOOGLE_IMAGE_ORIGINAL_HEIGHT, | 281 GOOGLE_IMAGE_ORIGINAL_HEIGHT, |
266 GOOGLE_IMAGE_ORIGINAL_WIDTH, | 282 GOOGLE_IMAGE_ORIGINAL_WIDTH, |
267 GOOGLE_IMAGE_SEARCH_SOURCE, | 283 GOOGLE_IMAGE_SEARCH_SOURCE, |
268 GOOGLE_IMAGE_THUMBNAIL, | 284 GOOGLE_IMAGE_THUMBNAIL, |
269 GOOGLE_IMAGE_URL, | 285 GOOGLE_IMAGE_URL, |
270 GOOGLE_FORCE_INSTANT_RESULTS, | 286 GOOGLE_FORCE_INSTANT_RESULTS, |
271 GOOGLE_INSTANT_EXTENDED_ENABLED, | 287 GOOGLE_INSTANT_EXTENDED_ENABLED, |
272 GOOGLE_NTP_IS_THEMED, | 288 GOOGLE_NTP_IS_THEMED, |
273 GOOGLE_OMNIBOX_START_MARGIN, | 289 GOOGLE_OMNIBOX_START_MARGIN, |
290 GOOGLE_CONTEXTUAL_SEARCH_VERSION, | |
291 GOOGLE_CONTEXTUAL_SEARCH_START, | |
292 GOOGLE_CONTEXTUAL_SEARCH_END, | |
293 GOOGLE_CONTEXTUAL_SEARCH_CONTENT, | |
294 GOOGLE_CONTEXTUAL_SEARCH_ENCODING, | |
274 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION, | 295 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION, |
275 GOOGLE_PAGE_CLASSIFICATION, | 296 GOOGLE_PAGE_CLASSIFICATION, |
276 GOOGLE_RLZ, | 297 GOOGLE_RLZ, |
277 GOOGLE_SEARCH_CLIENT, | 298 GOOGLE_SEARCH_CLIENT, |
278 GOOGLE_SEARCH_FIELDTRIAL_GROUP, | 299 GOOGLE_SEARCH_FIELDTRIAL_GROUP, |
279 GOOGLE_SESSION_TOKEN, | 300 GOOGLE_SESSION_TOKEN, |
280 GOOGLE_SUGGEST_CLIENT, | 301 GOOGLE_SUGGEST_CLIENT, |
281 GOOGLE_SUGGEST_REQUEST_ID, | 302 GOOGLE_SUGGEST_REQUEST_ID, |
282 GOOGLE_UNESCAPED_SEARCH_TERMS, | 303 GOOGLE_UNESCAPED_SEARCH_TERMS, |
283 LANGUAGE, | 304 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 | 458 // 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. | 459 // it requires substitutions first). This must be non-empty. |
439 void SetURL(const std::string& url); | 460 void SetURL(const std::string& url); |
440 const std::string& url() const { return url_; } | 461 const std::string& url() const { return url_; } |
441 | 462 |
442 // Optional additional raw URLs. | 463 // Optional additional raw URLs. |
443 std::string suggestions_url; | 464 std::string suggestions_url; |
444 std::string instant_url; | 465 std::string instant_url; |
445 std::string image_url; | 466 std::string image_url; |
446 std::string new_tab_url; | 467 std::string new_tab_url; |
468 std::string contextual_search_url; | |
447 | 469 |
448 // The following post_params are comma-separated lists used to specify the | 470 // The following post_params are comma-separated lists used to specify the |
449 // post parameters for the corresponding URL. | 471 // post parameters for the corresponding URL. |
450 std::string search_url_post_params; | 472 std::string search_url_post_params; |
451 std::string suggestions_url_post_params; | 473 std::string suggestions_url_post_params; |
452 std::string instant_url_post_params; | 474 std::string instant_url_post_params; |
453 std::string image_url_post_params; | 475 std::string image_url_post_params; |
454 | 476 |
455 // Optional favicon for the TemplateURL. | 477 // Optional favicon for the TemplateURL. |
456 GURL favicon_url; | 478 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. | 606 // displayed even if it is LTR and the UI is RTL. |
585 base::string16 AdjustedShortNameForLocaleDirection() const; | 607 base::string16 AdjustedShortNameForLocaleDirection() const; |
586 | 608 |
587 const base::string16& keyword() const { return data_.keyword(); } | 609 const base::string16& keyword() const { return data_.keyword(); } |
588 | 610 |
589 const std::string& url() const { return data_.url(); } | 611 const std::string& url() const { return data_.url(); } |
590 const std::string& suggestions_url() const { return data_.suggestions_url; } | 612 const std::string& suggestions_url() const { return data_.suggestions_url; } |
591 const std::string& instant_url() const { return data_.instant_url; } | 613 const std::string& instant_url() const { return data_.instant_url; } |
592 const std::string& image_url() const { return data_.image_url; } | 614 const std::string& image_url() const { return data_.image_url; } |
593 const std::string& new_tab_url() const { return data_.new_tab_url; } | 615 const std::string& new_tab_url() const { return data_.new_tab_url; } |
616 const std::string& contextual_search_url() const { | |
617 return data_.contextual_search_url; | |
618 } | |
594 const std::string& search_url_post_params() const { | 619 const std::string& search_url_post_params() const { |
595 return data_.search_url_post_params; | 620 return data_.search_url_post_params; |
596 } | 621 } |
597 const std::string& suggestions_url_post_params() const { | 622 const std::string& suggestions_url_post_params() const { |
598 return data_.suggestions_url_post_params; | 623 return data_.suggestions_url_post_params; |
599 } | 624 } |
600 const std::string& instant_url_post_params() const { | 625 const std::string& instant_url_post_params() const { |
601 return data_.instant_url_post_params; | 626 return data_.instant_url_post_params; |
602 } | 627 } |
603 const std::string& image_url_post_params() const { | 628 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; | 664 return data_.search_terms_replacement_key; |
640 } | 665 } |
641 | 666 |
642 const TemplateURLRef& url_ref() const { return url_ref_; } | 667 const TemplateURLRef& url_ref() const { return url_ref_; } |
643 const TemplateURLRef& suggestions_url_ref() const { | 668 const TemplateURLRef& suggestions_url_ref() const { |
644 return suggestions_url_ref_; | 669 return suggestions_url_ref_; |
645 } | 670 } |
646 const TemplateURLRef& instant_url_ref() const { return instant_url_ref_; } | 671 const TemplateURLRef& instant_url_ref() const { return instant_url_ref_; } |
647 const TemplateURLRef& image_url_ref() const { return image_url_ref_; } | 672 const TemplateURLRef& image_url_ref() const { return image_url_ref_; } |
648 const TemplateURLRef& new_tab_url_ref() const { return new_tab_url_ref_; } | 673 const TemplateURLRef& new_tab_url_ref() const { return new_tab_url_ref_; } |
674 const TemplateURLRef& contextual_search_url_ref() const { | |
675 return contextual_search_url_ref_; | |
676 } | |
649 | 677 |
650 // Returns true if |url| supports replacement. | 678 // Returns true if |url| supports replacement. |
651 bool SupportsReplacement() const; | 679 bool SupportsReplacement() const; |
652 | 680 |
653 // Like SupportsReplacement but usable on threads other than the UI thread. | 681 // Like SupportsReplacement but usable on threads other than the UI thread. |
654 bool SupportsReplacementUsingTermsData( | 682 bool SupportsReplacementUsingTermsData( |
655 const SearchTermsData& search_terms_data) const; | 683 const SearchTermsData& search_terms_data) const; |
656 | 684 |
657 // Returns true if any URLRefs use Googe base URLs. | 685 // Returns true if any URLRefs use Googe base URLs. |
658 bool HasGoogleBaseURLs() const; | 686 bool HasGoogleBaseURLs() const; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
769 url::Parsed::ComponentType* search_terms_component, | 797 url::Parsed::ComponentType* search_terms_component, |
770 url::Component* search_terms_position); | 798 url::Component* search_terms_position); |
771 | 799 |
772 Profile* profile_; | 800 Profile* profile_; |
773 TemplateURLData data_; | 801 TemplateURLData data_; |
774 TemplateURLRef url_ref_; | 802 TemplateURLRef url_ref_; |
775 TemplateURLRef suggestions_url_ref_; | 803 TemplateURLRef suggestions_url_ref_; |
776 TemplateURLRef instant_url_ref_; | 804 TemplateURLRef instant_url_ref_; |
777 TemplateURLRef image_url_ref_; | 805 TemplateURLRef image_url_ref_; |
778 TemplateURLRef new_tab_url_ref_; | 806 TemplateURLRef new_tab_url_ref_; |
807 TemplateURLRef contextual_search_url_ref_; | |
779 scoped_ptr<AssociatedExtensionInfo> extension_info_; | 808 scoped_ptr<AssociatedExtensionInfo> extension_info_; |
780 | 809 |
781 // TODO(sky): Add date last parsed OSD file. | 810 // TODO(sky): Add date last parsed OSD file. |
782 | 811 |
783 DISALLOW_COPY_AND_ASSIGN(TemplateURL); | 812 DISALLOW_COPY_AND_ASSIGN(TemplateURL); |
784 }; | 813 }; |
785 | 814 |
786 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ | 815 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ |
OLD | NEW |