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

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: *sigh* another rebase! 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 // Which kind of URL within our owner we are. This allows us to get at the 48 // Which kind of URL within our owner we are. This allows us to get at the
49 // correct string field. Use |INDEXED| to indicate that the numerical 49 // correct string field. Use |INDEXED| to indicate that the numerical
50 // |index_in_owner_| should be used instead. 50 // |index_in_owner_| should be used instead.
51 enum Type { 51 enum Type {
52 SEARCH, 52 SEARCH,
53 SUGGEST, 53 SUGGEST,
54 INSTANT, 54 INSTANT,
55 IMAGE, 55 IMAGE,
56 NEW_TAB, 56 NEW_TAB,
57 CONTEXTUAL_SEARCH,
57 INDEXED 58 INDEXED
58 }; 59 };
59 60
60 // Type to store <content_type, post_data> pair for POST URLs. 61 // Type to store <content_type, post_data> pair for POST URLs.
61 // The |content_type|(first part of the pair) is the content-type of 62 // The |content_type|(first part of the pair) is the content-type of
62 // the |post_data|(second part of the pair) which is encoded in 63 // the |post_data|(second part of the pair) which is encoded in
63 // "multipart/form-data" format, it also contains the MIME boundary used in 64 // "multipart/form-data" format, it also contains the MIME boundary used in
64 // the |post_data|. See http://tools.ietf.org/html/rfc2046 for the details. 65 // the |post_data|. See http://tools.ietf.org/html/rfc2046 for the details.
65 typedef std::pair<std::string, std::string> PostContent; 66 typedef std::pair<std::string, std::string> PostContent;
66 67
67 // This struct encapsulates arguments passed to 68 // This struct encapsulates arguments passed to
68 // TemplateURLRef::ReplaceSearchTerms methods. By default, only search_terms 69 // TemplateURLRef::ReplaceSearchTerms methods. By default, only search_terms
69 // is required and is passed in the constructor. 70 // is required and is passed in the constructor.
70 struct SearchTermsArgs { 71 struct SearchTermsArgs {
71 explicit SearchTermsArgs(const base::string16& search_terms); 72 explicit SearchTermsArgs(const base::string16& search_terms);
72 ~SearchTermsArgs(); 73 ~SearchTermsArgs();
73 74
75 struct ContextualSearchParams {
76 ContextualSearchParams();
77 ContextualSearchParams(const int version,
78 const size_t start,
79 const size_t end,
80 const std::string& selection,
81 const std::string& content,
82 const std::string& base_page_url,
83 const std::string& encoding);
84 ~ContextualSearchParams();
85
86 // The version of contextual search.
87 int version;
88
89 // Offset into the page content of the start of the user selection.
90 size_t start;
91
92 // Offset into the page content of the end of the user selection.
93 size_t end;
94
95 // The user selection.
96 std::string selection;
97
98 // The text including and surrounding the user selection.
99 std::string content;
100
101 // The URL of the page containing the user selection.
102 std::string base_page_url;
103
104 // The encoding of content.
105 std::string encoding;
106 };
107
74 // The search terms (query). 108 // The search terms (query).
75 base::string16 search_terms; 109 base::string16 search_terms;
76 110
77 // The original (input) query. 111 // The original (input) query.
78 base::string16 original_query; 112 base::string16 original_query;
79 113
80 // The type the original input query was identified as. 114 // The type the original input query was identified as.
81 AutocompleteInput::Type input_type; 115 AutocompleteInput::Type input_type;
82 116
83 // The optional assisted query stats, aka AQS, used for logging purposes. 117 // The optional assisted query stats, aka AQS, used for logging purposes.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 171
138 // If set, ReplaceSearchTerms() will append a param to the TemplateURLRef to 172 // If set, ReplaceSearchTerms() will append a param to the TemplateURLRef to
139 // update the search results page incrementally even if that is otherwise 173 // update the search results page incrementally even if that is otherwise
140 // disabled by google.com preferences. See comments on 174 // disabled by google.com preferences. See comments on
141 // chrome::ForceInstantResultsParam(). 175 // chrome::ForceInstantResultsParam().
142 bool force_instant_results; 176 bool force_instant_results;
143 177
144 // True if the search was made using the app list search box. Otherwise, the 178 // True if the search was made using the app list search box. Otherwise, the
145 // search was made using the omnibox. 179 // search was made using the omnibox.
146 bool from_app_list; 180 bool from_app_list;
181
182 ContextualSearchParams contextual_search_params;
147 }; 183 };
148 184
149 TemplateURLRef(TemplateURL* owner, Type type); 185 TemplateURLRef(TemplateURL* owner, Type type);
150 TemplateURLRef(TemplateURL* owner, size_t index_in_owner); 186 TemplateURLRef(TemplateURL* owner, size_t index_in_owner);
151 ~TemplateURLRef(); 187 ~TemplateURLRef();
152 188
153 // Returns the raw URL. None of the parameters will have been replaced. 189 // Returns the raw URL. None of the parameters will have been replaced.
154 std::string GetURL() const; 190 std::string GetURL() const;
155 191
156 // Returns the raw string of the post params. Please see comments in 192 // Returns the raw string of the post params. Please see comments in
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 GOOGLE_FORCE_INSTANT_RESULTS, 305 GOOGLE_FORCE_INSTANT_RESULTS,
270 GOOGLE_IMAGE_ORIGINAL_HEIGHT, 306 GOOGLE_IMAGE_ORIGINAL_HEIGHT,
271 GOOGLE_IMAGE_ORIGINAL_WIDTH, 307 GOOGLE_IMAGE_ORIGINAL_WIDTH,
272 GOOGLE_IMAGE_SEARCH_SOURCE, 308 GOOGLE_IMAGE_SEARCH_SOURCE,
273 GOOGLE_IMAGE_THUMBNAIL, 309 GOOGLE_IMAGE_THUMBNAIL,
274 GOOGLE_IMAGE_URL, 310 GOOGLE_IMAGE_URL,
275 GOOGLE_INPUT_TYPE, 311 GOOGLE_INPUT_TYPE,
276 GOOGLE_INSTANT_EXTENDED_ENABLED, 312 GOOGLE_INSTANT_EXTENDED_ENABLED,
277 GOOGLE_NTP_IS_THEMED, 313 GOOGLE_NTP_IS_THEMED,
278 GOOGLE_OMNIBOX_START_MARGIN, 314 GOOGLE_OMNIBOX_START_MARGIN,
315 GOOGLE_CONTEXTUAL_SEARCH_VERSION,
316 GOOGLE_CONTEXTUAL_SEARCH_CONTEXT_DATA,
279 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION, 317 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION,
280 GOOGLE_PAGE_CLASSIFICATION, 318 GOOGLE_PAGE_CLASSIFICATION,
281 GOOGLE_RLZ, 319 GOOGLE_RLZ,
282 GOOGLE_SEARCH_CLIENT, 320 GOOGLE_SEARCH_CLIENT,
283 GOOGLE_SEARCH_FIELDTRIAL_GROUP, 321 GOOGLE_SEARCH_FIELDTRIAL_GROUP,
284 GOOGLE_SESSION_TOKEN, 322 GOOGLE_SESSION_TOKEN,
285 GOOGLE_SUGGEST_CLIENT, 323 GOOGLE_SUGGEST_CLIENT,
286 GOOGLE_SUGGEST_REQUEST_ID, 324 GOOGLE_SUGGEST_REQUEST_ID,
287 GOOGLE_UNESCAPED_SEARCH_TERMS, 325 GOOGLE_UNESCAPED_SEARCH_TERMS,
288 LANGUAGE, 326 LANGUAGE,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 // displayed even if it is LTR and the UI is RTL. 519 // displayed even if it is LTR and the UI is RTL.
482 base::string16 AdjustedShortNameForLocaleDirection() const; 520 base::string16 AdjustedShortNameForLocaleDirection() const;
483 521
484 const base::string16& keyword() const { return data_.keyword(); } 522 const base::string16& keyword() const { return data_.keyword(); }
485 523
486 const std::string& url() const { return data_.url(); } 524 const std::string& url() const { return data_.url(); }
487 const std::string& suggestions_url() const { return data_.suggestions_url; } 525 const std::string& suggestions_url() const { return data_.suggestions_url; }
488 const std::string& instant_url() const { return data_.instant_url; } 526 const std::string& instant_url() const { return data_.instant_url; }
489 const std::string& image_url() const { return data_.image_url; } 527 const std::string& image_url() const { return data_.image_url; }
490 const std::string& new_tab_url() const { return data_.new_tab_url; } 528 const std::string& new_tab_url() const { return data_.new_tab_url; }
529 const std::string& contextual_search_url() const {
530 return data_.contextual_search_url;
531 }
491 const std::string& search_url_post_params() const { 532 const std::string& search_url_post_params() const {
492 return data_.search_url_post_params; 533 return data_.search_url_post_params;
493 } 534 }
494 const std::string& suggestions_url_post_params() const { 535 const std::string& suggestions_url_post_params() const {
495 return data_.suggestions_url_post_params; 536 return data_.suggestions_url_post_params;
496 } 537 }
497 const std::string& instant_url_post_params() const { 538 const std::string& instant_url_post_params() const {
498 return data_.instant_url_post_params; 539 return data_.instant_url_post_params;
499 } 540 }
500 const std::string& image_url_post_params() const { 541 const std::string& image_url_post_params() const {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 return data_.search_terms_replacement_key; 577 return data_.search_terms_replacement_key;
537 } 578 }
538 579
539 const TemplateURLRef& url_ref() const { return url_ref_; } 580 const TemplateURLRef& url_ref() const { return url_ref_; }
540 const TemplateURLRef& suggestions_url_ref() const { 581 const TemplateURLRef& suggestions_url_ref() const {
541 return suggestions_url_ref_; 582 return suggestions_url_ref_;
542 } 583 }
543 const TemplateURLRef& instant_url_ref() const { return instant_url_ref_; } 584 const TemplateURLRef& instant_url_ref() const { return instant_url_ref_; }
544 const TemplateURLRef& image_url_ref() const { return image_url_ref_; } 585 const TemplateURLRef& image_url_ref() const { return image_url_ref_; }
545 const TemplateURLRef& new_tab_url_ref() const { return new_tab_url_ref_; } 586 const TemplateURLRef& new_tab_url_ref() const { return new_tab_url_ref_; }
587 const TemplateURLRef& contextual_search_url_ref() const {
588 return contextual_search_url_ref_;
589 }
546 590
547 // Returns true if |url| supports replacement. 591 // Returns true if |url| supports replacement.
548 bool SupportsReplacement() const; 592 bool SupportsReplacement() const;
549 593
550 // Like SupportsReplacement but usable on threads other than the UI thread. 594 // Like SupportsReplacement but usable on threads other than the UI thread.
551 bool SupportsReplacementUsingTermsData( 595 bool SupportsReplacementUsingTermsData(
552 const SearchTermsData& search_terms_data) const; 596 const SearchTermsData& search_terms_data) const;
553 597
554 // Returns true if any URLRefs use Googe base URLs. 598 // Returns true if any URLRefs use Googe base URLs.
555 bool HasGoogleBaseURLs() const; 599 bool HasGoogleBaseURLs() const;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 url::Parsed::ComponentType* search_terms_component, 710 url::Parsed::ComponentType* search_terms_component,
667 url::Component* search_terms_position); 711 url::Component* search_terms_position);
668 712
669 Profile* profile_; 713 Profile* profile_;
670 TemplateURLData data_; 714 TemplateURLData data_;
671 TemplateURLRef url_ref_; 715 TemplateURLRef url_ref_;
672 TemplateURLRef suggestions_url_ref_; 716 TemplateURLRef suggestions_url_ref_;
673 TemplateURLRef instant_url_ref_; 717 TemplateURLRef instant_url_ref_;
674 TemplateURLRef image_url_ref_; 718 TemplateURLRef image_url_ref_;
675 TemplateURLRef new_tab_url_ref_; 719 TemplateURLRef new_tab_url_ref_;
720 TemplateURLRef contextual_search_url_ref_;
676 scoped_ptr<AssociatedExtensionInfo> extension_info_; 721 scoped_ptr<AssociatedExtensionInfo> extension_info_;
677 722
678 // TODO(sky): Add date last parsed OSD file. 723 // TODO(sky): Add date last parsed OSD file.
679 724
680 DISALLOW_COPY_AND_ASSIGN(TemplateURL); 725 DISALLOW_COPY_AND_ASSIGN(TemplateURL);
681 }; 726 };
682 727
683 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ 728 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698