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

Side by Side Diff: components/search_engines/template_url.h

Issue 939713003: Enabled the "search web for image" context menu item when "Yandex" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: The last arg of ExpectPostParamIs got a default value; the version number increased. Created 5 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_ 5 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_
6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_ 6 #define COMPONENTS_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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 base::string16* search_terms, 278 base::string16* search_terms,
279 const SearchTermsData& search_terms_data, 279 const SearchTermsData& search_terms_data,
280 url::Parsed::ComponentType* search_term_component, 280 url::Parsed::ComponentType* search_term_component,
281 url::Component* search_terms_position) const; 281 url::Component* search_terms_position) const;
282 282
283 // Whether the URL uses POST (as opposed to GET). 283 // Whether the URL uses POST (as opposed to GET).
284 bool UsesPOSTMethod(const SearchTermsData& search_terms_data) const; 284 bool UsesPOSTMethod(const SearchTermsData& search_terms_data) const;
285 285
286 private: 286 private:
287 friend class TemplateURL; 287 friend class TemplateURL;
288 friend class TemplateURLTest;
288 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, SetPrepopulatedAndParse); 289 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, SetPrepopulatedAndParse);
289 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseParameterKnown); 290 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseParameterKnown);
290 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseParameterUnknown); 291 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseParameterUnknown);
291 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLEmpty); 292 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLEmpty);
292 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNoTemplateEnd); 293 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNoTemplateEnd);
293 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNoKnownParameters); 294 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNoKnownParameters);
294 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLTwoParameters); 295 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLTwoParameters);
295 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNestedParameter); 296 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNestedParameter);
296 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, URLRefTestImageURLWithPOST); 297 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, URLRefTestImageURLWithPOST);
297 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ReflectsBookmarkBarPinned); 298 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ReflectsBookmarkBarPinned);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 Replacement(ReplacementType type, size_t index) 338 Replacement(ReplacementType type, size_t index)
338 : type(type), index(index), is_post_param(false) {} 339 : type(type), index(index), is_post_param(false) {}
339 ReplacementType type; 340 ReplacementType type;
340 size_t index; 341 size_t index;
341 // Indicates the location in where the replacement is replaced. If 342 // Indicates the location in where the replacement is replaced. If
342 // |is_post_param| is false, |index| indicates the byte position in 343 // |is_post_param| is false, |index| indicates the byte position in
343 // |parsed_url_|. Otherwise, |index| is the index of |post_params_|. 344 // |parsed_url_|. Otherwise, |index| is the index of |post_params_|.
344 bool is_post_param; 345 bool is_post_param;
345 }; 346 };
346 347
348 // Stores a single parameter for a POST.
349 struct PostParam {
350 std::string name;
351 std::string value;
352 std::string content_type;
353 };
354
347 // The list of elements to replace. 355 // The list of elements to replace.
348 typedef std::vector<struct Replacement> Replacements; 356 typedef std::vector<struct Replacement> Replacements;
349 // Type to store <key, value> pairs for POST URLs.
350 typedef std::pair<std::string, std::string> PostParam;
351 typedef std::vector<PostParam> PostParams; 357 typedef std::vector<PostParam> PostParams;
352 358
353 // TemplateURLRef internally caches values to make replacement quick. This 359 // TemplateURLRef internally caches values to make replacement quick. This
354 // method invalidates any cached values. 360 // method invalidates any cached values.
355 void InvalidateCachedValues() const; 361 void InvalidateCachedValues() const;
356 362
357 // Parses the parameter in url at the specified offset. start/end specify the 363 // Parses the parameter in url at the specified offset. start/end specify the
358 // range of the parameter in the url, including the braces. If the parameter 364 // range of the parameter in the url, including the braces. If the parameter
359 // is valid, url is updated to reflect the appropriate parameter. If 365 // is valid, url is updated to reflect the appropriate parameter. If
360 // the parameter is one of the known parameters an element is added to 366 // the parameter is one of the known parameters an element is added to
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 TemplateURLRef new_tab_url_ref_; 725 TemplateURLRef new_tab_url_ref_;
720 TemplateURLRef contextual_search_url_ref_; 726 TemplateURLRef contextual_search_url_ref_;
721 scoped_ptr<AssociatedExtensionInfo> extension_info_; 727 scoped_ptr<AssociatedExtensionInfo> extension_info_;
722 728
723 // TODO(sky): Add date last parsed OSD file. 729 // TODO(sky): Add date last parsed OSD file.
724 730
725 DISALLOW_COPY_AND_ASSIGN(TemplateURL); 731 DISALLOW_COPY_AND_ASSIGN(TemplateURL);
726 }; 732 };
727 733
728 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_ 734 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_
OLDNEW
« no previous file with comments | « components/search_engines/prepopulated_engines.json ('k') | components/search_engines/template_url.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698