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

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

Issue 555012: Removed restriction for {} so that javascript blocks can be used in the url.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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 | « no previous file | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <vector> 9 #include <vector>
9 10
10 #include "base/time.h" 11 #include "base/time.h"
11 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
13 #include "testing/gtest/include/gtest/gtest_prod.h"
12 14
13 class TemplateURL; 15 class TemplateURL;
14 16
15 // TemplateURL represents the relevant portions of the Open Search Description 17 // TemplateURL represents the relevant portions of the Open Search Description
16 // Document (http://www.opensearch.org/Specifications/OpenSearch). 18 // Document (http://www.opensearch.org/Specifications/OpenSearch).
17 // The main use case for TemplateURL is to use the TemplateURLRef returned by 19 // The main use case for TemplateURL is to use the TemplateURLRef returned by
18 // suggestions_url or url for keyword/suggestion expansion: 20 // suggestions_url or url for keyword/suggestion expansion:
19 // . suggestions_url describes a URL that is ideal for as you type suggestions. 21 // . suggestions_url describes a URL that is ideal for as you type suggestions.
20 // The returned results are in the mime type application/x-suggestions+json. 22 // The returned results are in the mime type application/x-suggestions+json.
21 // . url describes a URL that may be used as a shortcut. Returned results are 23 // . url describes a URL that may be used as a shortcut. Returned results are
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 const std::string& term) const; 106 const std::string& term) const;
105 107
106 // Returns true if this TemplateURLRef has a replacement term of 108 // Returns true if this TemplateURLRef has a replacement term of
107 // {google:baseURL} or {google:baseSuggestURL}. 109 // {google:baseURL} or {google:baseSuggestURL}.
108 bool HasGoogleBaseURLs() const; 110 bool HasGoogleBaseURLs() const;
109 111
110 private: 112 private:
111 friend class TemplateURL; 113 friend class TemplateURL;
112 friend class TemplateURLModelTest; 114 friend class TemplateURLModelTest;
113 friend class TemplateURLTest; 115 friend class TemplateURLTest;
116 FRIEND_TEST(TemplateURLTest, ParseParameterKnown);
117 FRIEND_TEST(TemplateURLTest, ParseParameterUnknown);
118 FRIEND_TEST(TemplateURLTest, ParseURLEmpty);
119 FRIEND_TEST(TemplateURLTest, ParseURLNoTemplateEnd);
120 FRIEND_TEST(TemplateURLTest, ParseURLNoKnownParameters);
121 FRIEND_TEST(TemplateURLTest, ParseURLTwoParameters);
122 FRIEND_TEST(TemplateURLTest, ParseURLNestedParameter);
114 123
115 // Enumeration of the known types. 124 // Enumeration of the known types.
116 enum ReplacementType { 125 enum ReplacementType {
117 ENCODING, 126 ENCODING,
118 GOOGLE_ACCEPTED_SUGGESTION, 127 GOOGLE_ACCEPTED_SUGGESTION,
119 GOOGLE_BASE_URL, 128 GOOGLE_BASE_URL,
120 GOOGLE_BASE_SUGGEST_URL, 129 GOOGLE_BASE_SUGGEST_URL,
121 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION, 130 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION,
122 GOOGLE_RLZ, 131 GOOGLE_RLZ,
123 GOOGLE_UNESCAPED_SEARCH_TERMS, 132 GOOGLE_UNESCAPED_SEARCH_TERMS,
(...skipping 15 matching lines...) Expand all
139 // method invalidates any cached values. 148 // method invalidates any cached values.
140 void InvalidateCachedValues() const; 149 void InvalidateCachedValues() const;
141 150
142 // Resets the url. 151 // Resets the url.
143 void Set(const std::wstring& url, int index_offset, int page_offset); 152 void Set(const std::wstring& url, int index_offset, int page_offset);
144 153
145 // Parses the parameter in url at the specified offset. start/end specify the 154 // Parses the parameter in url at the specified offset. start/end specify the
146 // range of the parameter in the url, including the braces. If the parameter 155 // range of the parameter in the url, including the braces. If the parameter
147 // is valid, url is updated to reflect the appropriate parameter. If 156 // is valid, url is updated to reflect the appropriate parameter. If
148 // the parameter is one of the known parameters an element is added to 157 // the parameter is one of the known parameters an element is added to
149 // replacements indicating the type and range of the element. 158 // replacements indicating the type and range of the element. The original
159 // parameter is erased from the url.
150 // 160 //
151 // If the parameter is not a known parameter, false is returned. 161 // If the parameter is not a known parameter, it's not erased and false is
162 // returned.
152 bool ParseParameter(size_t start, 163 bool ParseParameter(size_t start,
153 size_t end, 164 size_t end,
154 std::wstring* url, 165 std::wstring* url,
155 Replacements* replacements) const; 166 Replacements* replacements) const;
156 167
157 // Parses the specified url, replacing parameters as necessary. If 168 // Parses the specified url, replacing parameters as necessary. If
158 // successful, valid is set to true, and the parsed url is returned. For all 169 // successful, valid is set to true, and the parsed url is returned. For all
159 // known parameters that are encountered an entry is added to replacements. 170 // known parameters that are encountered an entry is added to replacements.
160 // If there is an error parsing (unknown parameter, or bogus url), valid is 171 // If there is an error parsing the url, valid is set to false, and an empty
161 // set to false, and an empty string is returned. 172 // string is returned.
162 std::wstring ParseURL(const std::wstring& url, 173 std::wstring ParseURL(const std::wstring& url,
163 Replacements* replacements, 174 Replacements* replacements,
164 bool* valid) const; 175 bool* valid) const;
165 176
166 // If the url has not yet been parsed, ParseURL is invoked. 177 // If the url has not yet been parsed, ParseURL is invoked.
167 // NOTE: While this is const, it modifies parsed_, valid_, parsed_url_ and 178 // NOTE: While this is const, it modifies parsed_, valid_, parsed_url_ and
168 // search_offset_. 179 // search_offset_.
169 void ParseIfNecessary() const; 180 void ParseIfNecessary() const;
170 181
171 // Extracts the query key and host from the url. 182 // Extracts the query key and host from the url.
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 std::vector<std::string> input_encodings_; 444 std::vector<std::string> input_encodings_;
434 IDType id_; 445 IDType id_;
435 base::Time date_created_; 446 base::Time date_created_;
436 int usage_count_; 447 int usage_count_;
437 int prepopulate_id_; 448 int prepopulate_id_;
438 449
439 // TODO(sky): Add date last parsed OSD file. 450 // TODO(sky): Add date last parsed OSD file.
440 }; 451 };
441 452
442 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ 453 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/search_engines/template_url.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698