OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/time.h" | 13 #include "base/time.h" |
14 #include "chrome/browser/search_engines/search_engine_type.h" | 14 #include "chrome/browser/search_engines/search_engine_type.h" |
15 #include "chrome/browser/search_engines/template_url_id.h" | 15 #include "chrome/browser/search_engines/template_url_id.h" |
16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
17 | 17 |
18 class PrefService; | 18 class PrefService; |
19 class Profile; | |
19 class SearchTermsData; | 20 class SearchTermsData; |
20 class TemplateURL; | 21 class TemplateURL; |
21 class WebDataService; | 22 class WebDataService; |
22 struct WDKeywordsResult; | 23 struct WDKeywordsResult; |
23 | 24 |
24 // TemplateURL represents the relevant portions of the Open Search Description | 25 // TemplateURL represents the relevant portions of the Open Search Description |
25 // Document (http://www.opensearch.org/Specifications/OpenSearch). | 26 // Document (http://www.opensearch.org/Specifications/OpenSearch). |
26 // The main use case for TemplateURL is to use the TemplateURLRef returned by | 27 // The main use case for TemplateURL is to use the TemplateURLRef returned by |
27 // suggestions_url or url for keyword/suggestion expansion: | 28 // suggestions_url or url for keyword/suggestion expansion: |
28 // . suggestions_url describes a URL that is ideal for as you type suggestions. | 29 // . suggestions_url describes a URL that is ideal for as you type suggestions. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 const SearchTermsData& search_terms_data) const; | 65 const SearchTermsData& search_terms_data) const; |
65 | 66 |
66 // Returns a string that is the result of replacing the search terms in | 67 // Returns a string that is the result of replacing the search terms in |
67 // the url with the specified value. | 68 // the url with the specified value. |
68 // | 69 // |
69 // If this TemplateURLRef does not support replacement (SupportsReplacement | 70 // If this TemplateURLRef does not support replacement (SupportsReplacement |
70 // returns false), an empty string is returned. | 71 // returns false), an empty string is returned. |
71 // | 72 // |
72 // The TemplateURL is used to determine the input encoding for the term. | 73 // The TemplateURL is used to determine the input encoding for the term. |
73 std::string ReplaceSearchTerms( | 74 std::string ReplaceSearchTerms( |
75 Profile* profile, | |
Peter Kasting
2011/08/11 00:35:17
Nit: You should comment about what we use this arg
| |
74 const TemplateURL& host, | 76 const TemplateURL& host, |
75 const string16& terms, | 77 const string16& terms, |
76 int accepted_suggestion, | 78 int accepted_suggestion, |
77 const string16& original_query_for_suggestion) const; | 79 const string16& original_query_for_suggestion) const; |
78 | 80 |
79 // Just like ReplaceSearchTerms except that it takes SearchTermsData to supply | 81 // Just like ReplaceSearchTerms except that it takes SearchTermsData to supply |
80 // the data for some search terms. Most of the time ReplaceSearchTerms should | 82 // the data for some search terms. Most of the time ReplaceSearchTerms should |
81 // be called. | 83 // be called. |
82 std::string ReplaceSearchTermsUsingTermsData( | 84 std::string ReplaceSearchTermsUsingTermsData( |
83 const TemplateURL& host, | 85 const TemplateURL& host, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNoKnownParameters); | 153 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNoKnownParameters); |
152 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLTwoParameters); | 154 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLTwoParameters); |
153 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNestedParameter); | 155 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNestedParameter); |
154 | 156 |
155 // Enumeration of the known types. | 157 // Enumeration of the known types. |
156 enum ReplacementType { | 158 enum ReplacementType { |
157 ENCODING, | 159 ENCODING, |
158 GOOGLE_ACCEPTED_SUGGESTION, | 160 GOOGLE_ACCEPTED_SUGGESTION, |
159 GOOGLE_BASE_URL, | 161 GOOGLE_BASE_URL, |
160 GOOGLE_BASE_SUGGEST_URL, | 162 GOOGLE_BASE_SUGGEST_URL, |
163 GOOGLE_INSTANT_FIELD_TRIAL_GROUP, | |
161 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION, | 164 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION, |
162 GOOGLE_RLZ, | 165 GOOGLE_RLZ, |
163 GOOGLE_SEARCH_FIELDTRIAL_GROUP, | 166 GOOGLE_SEARCH_FIELDTRIAL_GROUP, |
164 GOOGLE_UNESCAPED_SEARCH_TERMS, | 167 GOOGLE_UNESCAPED_SEARCH_TERMS, |
165 LANGUAGE, | 168 LANGUAGE, |
166 SEARCH_TERMS, | 169 SEARCH_TERMS, |
167 }; | 170 }; |
168 | 171 |
169 // Used to identify an element of the raw url that can be replaced. | 172 // Used to identify an element of the raw url that can be replaced. |
170 struct Replacement { | 173 struct Replacement { |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 int logo_id_; | 542 int logo_id_; |
540 int prepopulate_id_; | 543 int prepopulate_id_; |
541 // The primary unique identifier for Sync. This is only set on TemplateURLs | 544 // The primary unique identifier for Sync. This is only set on TemplateURLs |
542 // that have been associated with Sync. | 545 // that have been associated with Sync. |
543 std::string sync_guid_; | 546 std::string sync_guid_; |
544 | 547 |
545 // TODO(sky): Add date last parsed OSD file. | 548 // TODO(sky): Add date last parsed OSD file. |
546 }; | 549 }; |
547 | 550 |
548 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ | 551 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ |
OLD | NEW |