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

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

Issue 126052: Fixes bug where keyword editor would end up prefixing all keyword urls... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "chrome/browser/search_engines/template_url.h" 5 #include "chrome/browser/search_engines/template_url.h"
6 6
7 #include "app/gfx/favicon_size.h" 7 #include "app/gfx/favicon_size.h"
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 std::string::npos) { 223 std::string::npos) {
224 search_term_key_ = query_string.substr(key.begin, key.len); 224 search_term_key_ = query_string.substr(key.begin, key.len);
225 host_ = url.host(); 225 host_ = url.host();
226 path_ = url.path(); 226 path_ = url.path();
227 break; 227 break;
228 } 228 }
229 } 229 }
230 } 230 }
231 } 231 }
232 232
233 GURL TemplateURLRef::ReplaceSearchTerms( 233 std::wstring TemplateURLRef::ReplaceSearchTerms(
234 const TemplateURL& host, 234 const TemplateURL& host,
235 const std::wstring& terms, 235 const std::wstring& terms,
236 int accepted_suggestion, 236 int accepted_suggestion,
237 const std::wstring& original_query_for_suggestion) const { 237 const std::wstring& original_query_for_suggestion) const {
238 ParseIfNecessary(); 238 ParseIfNecessary();
239 if (!valid_) 239 if (!valid_)
240 return GURL(); 240 return std::wstring();
241 241
242 if (replacements_.empty()) 242 if (replacements_.empty())
243 return GURL(WideToUTF8(parsed_url_)); 243 return parsed_url_;
244 244
245 // Encode the search terms so that we know the encoding. 245 // Encode the search terms so that we know the encoding.
246 const std::vector<std::string>& encodings = host.input_encodings(); 246 const std::vector<std::string>& encodings = host.input_encodings();
247 std::wstring encoded_terms; 247 std::wstring encoded_terms;
248 std::wstring encoded_original_query; 248 std::wstring encoded_original_query;
249 std::wstring input_encoding; 249 std::wstring input_encoding;
250 for (size_t i = 0; i < encodings.size(); ++i) { 250 for (size_t i = 0; i < encodings.size(); ++i) {
251 if (EscapeQueryParamValue(terms, encodings[i].c_str(), &encoded_terms)) { 251 if (EscapeQueryParamValue(terms, encodings[i].c_str(), &encoded_terms)) {
252 if (!original_query_for_suggestion.empty()) { 252 if (!original_query_for_suggestion.empty()) {
253 EscapeQueryParamValue(original_query_for_suggestion, 253 EscapeQueryParamValue(original_query_for_suggestion,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 case SEARCH_TERMS: 323 case SEARCH_TERMS:
324 url.insert(i->index, encoded_terms); 324 url.insert(i->index, encoded_terms);
325 break; 325 break;
326 326
327 default: 327 default:
328 NOTREACHED(); 328 NOTREACHED();
329 break; 329 break;
330 } 330 }
331 } 331 }
332 332
333 return GURL(WideToUTF8(url)); 333 return url;
334 } 334 }
335 335
336 bool TemplateURLRef::SupportsReplacement() const { 336 bool TemplateURLRef::SupportsReplacement() const {
337 ParseIfNecessary(); 337 ParseIfNecessary();
338 return valid_ && supports_replacements_; 338 return valid_ && supports_replacements_;
339 } 339 }
340 340
341 bool TemplateURLRef::IsValid() const { 341 bool TemplateURLRef::IsValid() const {
342 ParseIfNecessary(); 342 ParseIfNecessary();
343 return valid_; 343 return valid_;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 } 566 }
567 return GURL(); 567 return GURL();
568 } 568 }
569 569
570 void TemplateURL::InvalidateCachedValues() const { 570 void TemplateURL::InvalidateCachedValues() const {
571 url_.InvalidateCachedValues(); 571 url_.InvalidateCachedValues();
572 suggestions_url_.InvalidateCachedValues(); 572 suggestions_url_.InvalidateCachedValues();
573 if (autogenerate_keyword_) 573 if (autogenerate_keyword_)
574 keyword_.clear(); 574 keyword_.clear();
575 } 575 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url.h ('k') | chrome/browser/search_engines/template_url_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698