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

Unified Diff: components/search_engines/template_url.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/search_engines/template_url.h ('k') | components/search_engines/template_url_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/search_engines/template_url.cc
diff --git a/components/search_engines/template_url.cc b/components/search_engines/template_url.cc
index a9b6c9b6d7d521de9cd8bf928d73090505dc5d7b..007121864b5bca1aaaceea7a19620d5a496c121e 100644
--- a/components/search_engines/template_url.cc
+++ b/components/search_engines/template_url.cc
@@ -323,11 +323,10 @@ bool TemplateURLRef::EncodeFormData(const PostParams& post_params,
// Encodes the post parameters.
std::string* post_data = &post_content->second;
post_data->clear();
- for (PostParams::const_iterator param = post_params.begin();
- param != post_params.end(); ++param) {
- DCHECK(!param->first.empty());
- net::AddMultipartValueForUpload(param->first, param->second, boundary,
- std::string(), post_data);
+ for (const auto& param : post_params) {
+ DCHECK(!param.name.empty());
+ net::AddMultipartValueForUpload(param.name, param.value, boundary,
+ param.content_type, post_data);
}
net::AddMultipartFinalDelimiterForUpload(boundary, post_data);
return true;
@@ -714,7 +713,8 @@ std::string TemplateURLRef::ParseURL(const std::string& url,
size_t replacements_size = replacements->size();
if (IsTemplateParameterString(value))
ParseParameter(0, value.length() - 1, &value, replacements);
- post_params->push_back(std::make_pair(parts[0], value));
+ PostParam param = { parts[0], value };
+ post_params->push_back(param);
// If there was a replacement added, points its index to last added
// PostParam.
if (replacements->size() > replacements_size) {
@@ -797,8 +797,8 @@ void TemplateURLRef::HandleReplacement(const std::string& name,
size_t pos = replacement.index;
if (replacement.is_post_param) {
DCHECK_LT(pos, post_params_.size());
- DCHECK(!post_params_[pos].first.empty());
- post_params_[pos].second = value;
+ DCHECK(!post_params_[pos].name.empty());
+ post_params_[pos].value = value;
} else {
url->insert(pos, name.empty() ? value : (name + "=" + value + "&"));
}
@@ -1097,6 +1097,7 @@ std::string TemplateURLRef::HandleReplacements(
case GOOGLE_IMAGE_THUMBNAIL:
HandleReplacement(
std::string(), search_terms_args.image_thumbnail_content, *i, &url);
+ post_params_[i->index].content_type = "image/jpeg";
break;
case GOOGLE_IMAGE_URL:
« no previous file with comments | « components/search_engines/template_url.h ('k') | components/search_engines/template_url_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698