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

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

Issue 10537154: A working implementation of AQS (Assisted Query Stats). (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Addressed comments and added more docs. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/instant/instant_loader.cc ('k') | chrome/browser/search_engines/template_url.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 30 matching lines...) Expand all
41 }; 41 };
42 42
43 // Which kind of URL within our owner we are. This allows us to get at the 43 // Which kind of URL within our owner we are. This allows us to get at the
44 // correct string field. 44 // correct string field.
45 enum Type { 45 enum Type {
46 SEARCH, 46 SEARCH,
47 SUGGEST, 47 SUGGEST,
48 INSTANT, 48 INSTANT,
49 }; 49 };
50 50
51 // This struct encapsulates arguments passed to
52 // TemplateURLRef::ReplaceSearchTerms methods. By default, only search_terms
53 // is required and is passed in the constructor.
54 struct SearchTermsArgs {
55 explicit SearchTermsArgs(const string16& search_terms);
56
57 // The search terms (query).
58 const string16 search_terms;
59 // The original (input) query.
60 string16 original_query;
61 // The optional assisted query stats, aka AQS, used for logging purposes.
62 // This string contains impressions of all autocomplete matches shown
63 // at the query submission time. For privacy reasons, we require the
64 // search provider to support HTTPS protocol in order to receive the AQS
65 // param.
66 // For more details, see http://goto.google.com/binary-clients-logging .
67 std::string assisted_query_stats;
68
69 // TODO: Remove along with "aq" CGI param.
70 int accepted_suggestion;
71 };
72
51 TemplateURLRef(TemplateURL* owner, Type type); 73 TemplateURLRef(TemplateURL* owner, Type type);
52 ~TemplateURLRef(); 74 ~TemplateURLRef();
53 75
54 // Returns the raw URL. None of the parameters will have been replaced. 76 // Returns the raw URL. None of the parameters will have been replaced.
55 std::string GetURL() const; 77 std::string GetURL() const;
56 78
57 // Returns true if this URL supports replacement. 79 // Returns true if this URL supports replacement.
58 bool SupportsReplacement() const; 80 bool SupportsReplacement() const;
59 81
60 // Like SupportsReplacement but usable on threads other than the UI thread. 82 // Like SupportsReplacement but usable on threads other than the UI thread.
61 bool SupportsReplacementUsingTermsData( 83 bool SupportsReplacementUsingTermsData(
62 const SearchTermsData& search_terms_data) const; 84 const SearchTermsData& search_terms_data) const;
63 85
64 // Returns a string that is the result of replacing the search terms in 86 // Returns a string that is the result of replacing the search terms in
65 // the url with the specified value. We use our owner's input encoding. 87 // the url with the specified arguments. We use our owner's input encoding.
66 // 88 //
67 // If this TemplateURLRef does not support replacement (SupportsReplacement 89 // If this TemplateURLRef does not support replacement (SupportsReplacement
68 // returns false), an empty string is returned. 90 // returns false), an empty string is returned.
69 std::string ReplaceSearchTerms( 91 std::string ReplaceSearchTerms(
70 const string16& terms, 92 const SearchTermsArgs& search_terms_args) const;
71 int accepted_suggestion,
72 const string16& original_query_for_suggestion) const;
73 93
74 // Just like ReplaceSearchTerms except that it takes SearchTermsData to supply 94 // Just like ReplaceSearchTerms except that it takes SearchTermsData to supply
75 // the data for some search terms. Most of the time ReplaceSearchTerms should 95 // the data for some search terms. Most of the time ReplaceSearchTerms should
76 // be called. 96 // be called.
77 std::string ReplaceSearchTermsUsingTermsData( 97 std::string ReplaceSearchTermsUsingTermsData(
78 const string16& terms, 98 const SearchTermsArgs& search_terms_args,
79 int accepted_suggestion,
80 const string16& original_query_for_suggestion,
81 const SearchTermsData& search_terms_data) const; 99 const SearchTermsData& search_terms_data) const;
82 100
83 // Returns true if the TemplateURLRef is valid. An invalid TemplateURLRef is 101 // Returns true if the TemplateURLRef is valid. An invalid TemplateURLRef is
84 // one that contains unknown terms, or invalid characters. 102 // one that contains unknown terms, or invalid characters.
85 bool IsValid() const; 103 bool IsValid() const;
86 104
87 // Like IsValid but usable on threads other than the UI thread. 105 // Like IsValid but usable on threads other than the UI thread.
88 bool IsValidUsingTermsData(const SearchTermsData& search_terms_data) const; 106 bool IsValidUsingTermsData(const SearchTermsData& search_terms_data) const;
89 107
90 // Returns a string representation of this TemplateURLRef suitable for 108 // Returns a string representation of this TemplateURLRef suitable for
(...skipping 28 matching lines...) Expand all
119 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLEmpty); 137 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLEmpty);
120 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNoTemplateEnd); 138 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNoTemplateEnd);
121 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNoKnownParameters); 139 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNoKnownParameters);
122 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLTwoParameters); 140 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLTwoParameters);
123 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNestedParameter); 141 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNestedParameter);
124 142
125 // Enumeration of the known types. 143 // Enumeration of the known types.
126 enum ReplacementType { 144 enum ReplacementType {
127 ENCODING, 145 ENCODING,
128 GOOGLE_ACCEPTED_SUGGESTION, 146 GOOGLE_ACCEPTED_SUGGESTION,
147 GOOGLE_ASSISTED_QUERY_STATS,
129 GOOGLE_BASE_URL, 148 GOOGLE_BASE_URL,
130 GOOGLE_BASE_SUGGEST_URL, 149 GOOGLE_BASE_SUGGEST_URL,
131 GOOGLE_INSTANT_ENABLED, 150 GOOGLE_INSTANT_ENABLED,
132 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION, 151 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION,
133 GOOGLE_RLZ, 152 GOOGLE_RLZ,
134 GOOGLE_SEARCH_FIELDTRIAL_GROUP, 153 GOOGLE_SEARCH_FIELDTRIAL_GROUP,
135 GOOGLE_UNESCAPED_SEARCH_TERMS, 154 GOOGLE_UNESCAPED_SEARCH_TERMS,
136 LANGUAGE, 155 LANGUAGE,
137 SEARCH_TERMS, 156 SEARCH_TERMS,
138 }; 157 };
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 TemplateURLRef url_ref_; 443 TemplateURLRef url_ref_;
425 TemplateURLRef suggestions_url_ref_; 444 TemplateURLRef suggestions_url_ref_;
426 TemplateURLRef instant_url_ref_; 445 TemplateURLRef instant_url_ref_;
427 446
428 // TODO(sky): Add date last parsed OSD file. 447 // TODO(sky): Add date last parsed OSD file.
429 448
430 DISALLOW_COPY_AND_ASSIGN(TemplateURL); 449 DISALLOW_COPY_AND_ASSIGN(TemplateURL);
431 }; 450 };
432 451
433 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ 452 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_loader.cc ('k') | chrome/browser/search_engines/template_url.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698