Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: chrome/browser/search_engines/template_url.h

Issue 308053009: Add contextual search to the template url system (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 URL of the page containing the user selection.
112 std::string contextual_search_base_page_url;
113
114 // The encoding of contextual_search_content.
115 std::string contextual_search_encoding;
116
Peter Kasting 2014/06/03 21:47:09 Maybe all these should be in some sub-struct to gr
jeremycho 2014/06/04 00:22:11 Done. On 2014/06/03 21:47:09, Peter Kasting wrote
98 // The URL of the current webpage to be used for experimental zero-prefix 117 // The URL of the current webpage to be used for experimental zero-prefix
99 // suggestions. 118 // suggestions.
100 std::string current_page_url; 119 std::string current_page_url;
101 120
102 // Which omnibox the user used to type the prefix. 121 // Which omnibox the user used to type the prefix.
103 AutocompleteInput::PageClassification page_classification; 122 AutocompleteInput::PageClassification page_classification;
104 123
105 // True for searches issued with the bookmark bar pref set to shown. 124 // True for searches issued with the bookmark bar pref set to shown.
106 bool bookmark_bar_pinned; 125 bool bookmark_bar_pinned;
107 126
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 GOOGLE_CURSOR_POSITION, 283 GOOGLE_CURSOR_POSITION,
265 GOOGLE_IMAGE_ORIGINAL_HEIGHT, 284 GOOGLE_IMAGE_ORIGINAL_HEIGHT,
266 GOOGLE_IMAGE_ORIGINAL_WIDTH, 285 GOOGLE_IMAGE_ORIGINAL_WIDTH,
267 GOOGLE_IMAGE_SEARCH_SOURCE, 286 GOOGLE_IMAGE_SEARCH_SOURCE,
268 GOOGLE_IMAGE_THUMBNAIL, 287 GOOGLE_IMAGE_THUMBNAIL,
269 GOOGLE_IMAGE_URL, 288 GOOGLE_IMAGE_URL,
270 GOOGLE_FORCE_INSTANT_RESULTS, 289 GOOGLE_FORCE_INSTANT_RESULTS,
271 GOOGLE_INSTANT_EXTENDED_ENABLED, 290 GOOGLE_INSTANT_EXTENDED_ENABLED,
272 GOOGLE_NTP_IS_THEMED, 291 GOOGLE_NTP_IS_THEMED,
273 GOOGLE_OMNIBOX_START_MARGIN, 292 GOOGLE_OMNIBOX_START_MARGIN,
293 GOOGLE_CONTEXTUAL_SEARCH_VERSION,
294 GOOGLE_CONTEXTUAL_SEARCH_START,
295 GOOGLE_CONTEXTUAL_SEARCH_END,
296 GOOGLE_CONTEXTUAL_SEARCH_CONTENT,
297 GOOGLE_CONTEXTUAL_SEARCH_BASE_PAGE_URL,
298 GOOGLE_CONTEXTUAL_SEARCH_ENCODING,
274 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION, 299 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION,
275 GOOGLE_PAGE_CLASSIFICATION, 300 GOOGLE_PAGE_CLASSIFICATION,
276 GOOGLE_RLZ, 301 GOOGLE_RLZ,
277 GOOGLE_SEARCH_CLIENT, 302 GOOGLE_SEARCH_CLIENT,
278 GOOGLE_SEARCH_FIELDTRIAL_GROUP, 303 GOOGLE_SEARCH_FIELDTRIAL_GROUP,
279 GOOGLE_SESSION_TOKEN, 304 GOOGLE_SESSION_TOKEN,
280 GOOGLE_SUGGEST_CLIENT, 305 GOOGLE_SUGGEST_CLIENT,
281 GOOGLE_SUGGEST_REQUEST_ID, 306 GOOGLE_SUGGEST_REQUEST_ID,
282 GOOGLE_UNESCAPED_SEARCH_TERMS, 307 GOOGLE_UNESCAPED_SEARCH_TERMS,
283 LANGUAGE, 308 LANGUAGE,
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 // The raw URL for the TemplateURL, which may not be valid as-is (e.g. because 462 // 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. 463 // it requires substitutions first). This must be non-empty.
439 void SetURL(const std::string& url); 464 void SetURL(const std::string& url);
440 const std::string& url() const { return url_; } 465 const std::string& url() const { return url_; }
441 466
442 // Optional additional raw URLs. 467 // Optional additional raw URLs.
443 std::string suggestions_url; 468 std::string suggestions_url;
444 std::string instant_url; 469 std::string instant_url;
445 std::string image_url; 470 std::string image_url;
446 std::string new_tab_url; 471 std::string new_tab_url;
472 std::string contextual_search_url;
447 473
448 // The following post_params are comma-separated lists used to specify the 474 // The following post_params are comma-separated lists used to specify the
449 // post parameters for the corresponding URL. 475 // post parameters for the corresponding URL.
450 std::string search_url_post_params; 476 std::string search_url_post_params;
451 std::string suggestions_url_post_params; 477 std::string suggestions_url_post_params;
452 std::string instant_url_post_params; 478 std::string instant_url_post_params;
453 std::string image_url_post_params; 479 std::string image_url_post_params;
454 480
455 // Optional favicon for the TemplateURL. 481 // Optional favicon for the TemplateURL.
456 GURL favicon_url; 482 GURL favicon_url;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 // displayed even if it is LTR and the UI is RTL. 610 // displayed even if it is LTR and the UI is RTL.
585 base::string16 AdjustedShortNameForLocaleDirection() const; 611 base::string16 AdjustedShortNameForLocaleDirection() const;
586 612
587 const base::string16& keyword() const { return data_.keyword(); } 613 const base::string16& keyword() const { return data_.keyword(); }
588 614
589 const std::string& url() const { return data_.url(); } 615 const std::string& url() const { return data_.url(); }
590 const std::string& suggestions_url() const { return data_.suggestions_url; } 616 const std::string& suggestions_url() const { return data_.suggestions_url; }
591 const std::string& instant_url() const { return data_.instant_url; } 617 const std::string& instant_url() const { return data_.instant_url; }
592 const std::string& image_url() const { return data_.image_url; } 618 const std::string& image_url() const { return data_.image_url; }
593 const std::string& new_tab_url() const { return data_.new_tab_url; } 619 const std::string& new_tab_url() const { return data_.new_tab_url; }
620 const std::string& contextual_search_url() const {
621 return data_.contextual_search_url;
622 }
594 const std::string& search_url_post_params() const { 623 const std::string& search_url_post_params() const {
595 return data_.search_url_post_params; 624 return data_.search_url_post_params;
596 } 625 }
597 const std::string& suggestions_url_post_params() const { 626 const std::string& suggestions_url_post_params() const {
598 return data_.suggestions_url_post_params; 627 return data_.suggestions_url_post_params;
599 } 628 }
600 const std::string& instant_url_post_params() const { 629 const std::string& instant_url_post_params() const {
601 return data_.instant_url_post_params; 630 return data_.instant_url_post_params;
602 } 631 }
603 const std::string& image_url_post_params() const { 632 const std::string& image_url_post_params() const {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 return data_.search_terms_replacement_key; 668 return data_.search_terms_replacement_key;
640 } 669 }
641 670
642 const TemplateURLRef& url_ref() const { return url_ref_; } 671 const TemplateURLRef& url_ref() const { return url_ref_; }
643 const TemplateURLRef& suggestions_url_ref() const { 672 const TemplateURLRef& suggestions_url_ref() const {
644 return suggestions_url_ref_; 673 return suggestions_url_ref_;
645 } 674 }
646 const TemplateURLRef& instant_url_ref() const { return instant_url_ref_; } 675 const TemplateURLRef& instant_url_ref() const { return instant_url_ref_; }
647 const TemplateURLRef& image_url_ref() const { return image_url_ref_; } 676 const TemplateURLRef& image_url_ref() const { return image_url_ref_; }
648 const TemplateURLRef& new_tab_url_ref() const { return new_tab_url_ref_; } 677 const TemplateURLRef& new_tab_url_ref() const { return new_tab_url_ref_; }
678 const TemplateURLRef& contextual_search_url_ref() const {
679 return contextual_search_url_ref_;
680 }
649 681
650 // Returns true if |url| supports replacement. 682 // Returns true if |url| supports replacement.
651 bool SupportsReplacement() const; 683 bool SupportsReplacement() const;
652 684
653 // Like SupportsReplacement but usable on threads other than the UI thread. 685 // Like SupportsReplacement but usable on threads other than the UI thread.
654 bool SupportsReplacementUsingTermsData( 686 bool SupportsReplacementUsingTermsData(
655 const SearchTermsData& search_terms_data) const; 687 const SearchTermsData& search_terms_data) const;
656 688
657 // Returns true if any URLRefs use Googe base URLs. 689 // Returns true if any URLRefs use Googe base URLs.
658 bool HasGoogleBaseURLs() const; 690 bool HasGoogleBaseURLs() const;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 url::Parsed::ComponentType* search_terms_component, 801 url::Parsed::ComponentType* search_terms_component,
770 url::Component* search_terms_position); 802 url::Component* search_terms_position);
771 803
772 Profile* profile_; 804 Profile* profile_;
773 TemplateURLData data_; 805 TemplateURLData data_;
774 TemplateURLRef url_ref_; 806 TemplateURLRef url_ref_;
775 TemplateURLRef suggestions_url_ref_; 807 TemplateURLRef suggestions_url_ref_;
776 TemplateURLRef instant_url_ref_; 808 TemplateURLRef instant_url_ref_;
777 TemplateURLRef image_url_ref_; 809 TemplateURLRef image_url_ref_;
778 TemplateURLRef new_tab_url_ref_; 810 TemplateURLRef new_tab_url_ref_;
811 TemplateURLRef contextual_search_url_ref_;
779 scoped_ptr<AssociatedExtensionInfo> extension_info_; 812 scoped_ptr<AssociatedExtensionInfo> extension_info_;
780 813
781 // TODO(sky): Add date last parsed OSD file. 814 // TODO(sky): Add date last parsed OSD file.
782 815
783 DISALLOW_COPY_AND_ASSIGN(TemplateURL); 816 DISALLOW_COPY_AND_ASSIGN(TemplateURL);
784 }; 817 };
785 818
786 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ 819 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698