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

Unified Diff: chrome/browser/views/edit_keyword_controller.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/edit_keyword_controller.cc
===================================================================
--- chrome/browser/views/edit_keyword_controller.cc (revision 18266)
+++ chrome/browser/views/edit_keyword_controller.cc (working copy)
@@ -298,8 +298,8 @@
// If the url has a search term, replace it with a random string and make
// sure the resulting URL is valid. We don't check the validity of the url
// with the search term as that is not necessarily valid.
- return template_ref.ReplaceSearchTerms(TemplateURL(), L"a",
- TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()).is_valid();
+ return GURL(WideToUTF8(template_ref.ReplaceSearchTerms(TemplateURL(), L"a",
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()))).is_valid();
}
std::wstring EditKeywordController::GetURL() const {
@@ -309,14 +309,19 @@
if (url.empty())
return url;
- // Parse the string as a URL to determine the scheme. If a scheme hasn't been
- // specified, we add it.
+ // Parse the string as a URL to determine the scheme. If we need to, add the
+ // scheme. As the scheme may be expanded (as happens with {google:baseURL})
+ // we need to replace the search terms before testing for the scheme.
+ TemplateURL t_url;
+ t_url.SetURL(url, 0, 0);
+ std::wstring expanded_url =
+ t_url.url()->ReplaceSearchTerms(t_url, L"x", 0, std::wstring());
url_parse::Parsed parts;
- std::wstring scheme(URLFixerUpper::SegmentURL(url, &parts));
- if (!parts.scheme.is_valid()) {
- std::wstring fixed_scheme(scheme);
- fixed_scheme.append(L"://");
- url.insert(0, fixed_scheme);
+ std::string scheme(
+ URLFixerUpper::SegmentURL(WideToUTF8(expanded_url), &parts));
+ if(!parts.scheme.is_valid()) {
+ scheme.append("://");
+ url.insert(0, UTF8ToWide(scheme));
}
return url;
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698