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

Side by Side Diff: chrome/browser/ui/search_engines/edit_search_engine_controller.cc

Issue 183853011: Move TrimWhitespace to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/search_engines/edit_search_engine_controller.h" 5 #include "chrome/browser/ui/search_engines/edit_search_engine_controller.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search_engines/template_url.h" 10 #include "chrome/browser/search_engines/template_url.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // When we have no Delegate, we know that the template_url_ hasn't yet been 115 // When we have no Delegate, we know that the template_url_ hasn't yet been
116 // added to the model, so we need to clean it up. 116 // added to the model, so we need to clean it up.
117 delete template_url_; 117 delete template_url_;
118 template_url_ = NULL; 118 template_url_ = NULL;
119 } 119 }
120 } 120 }
121 121
122 std::string EditSearchEngineController::GetFixedUpURL( 122 std::string EditSearchEngineController::GetFixedUpURL(
123 const std::string& url_input) const { 123 const std::string& url_input) const {
124 std::string url; 124 std::string url;
125 TrimWhitespace(TemplateURLRef::DisplayURLToURLRef( 125 base::TrimWhitespace(TemplateURLRef::DisplayURLToURLRef(
126 base::UTF8ToUTF16(url_input)), 126 base::UTF8ToUTF16(url_input)),
127 TRIM_ALL, &url); 127 base::TRIM_ALL, &url);
128 if (url.empty()) 128 if (url.empty())
129 return url; 129 return url;
130 130
131 // Parse the string as a URL to determine the scheme. If we need to, add the 131 // Parse the string as a URL to determine the scheme. If we need to, add the
132 // scheme. As the scheme may be expanded (as happens with {google:baseURL}) 132 // scheme. As the scheme may be expanded (as happens with {google:baseURL})
133 // we need to replace the search terms before testing for the scheme. 133 // we need to replace the search terms before testing for the scheme.
134 TemplateURLData data; 134 TemplateURLData data;
135 data.SetURL(url); 135 data.SetURL(url);
136 TemplateURL t_url(profile_, data); 136 TemplateURL t_url(profile_, data);
137 std::string expanded_url(t_url.url_ref().ReplaceSearchTerms( 137 std::string expanded_url(t_url.url_ref().ReplaceSearchTerms(
138 TemplateURLRef::SearchTermsArgs(base::ASCIIToUTF16("x")))); 138 TemplateURLRef::SearchTermsArgs(base::ASCIIToUTF16("x"))));
139 url_parse::Parsed parts; 139 url_parse::Parsed parts;
140 std::string scheme(URLFixerUpper::SegmentURL(expanded_url, &parts)); 140 std::string scheme(URLFixerUpper::SegmentURL(expanded_url, &parts));
141 if (!parts.scheme.is_valid()) 141 if (!parts.scheme.is_valid())
142 url.insert(0, scheme + "://"); 142 url.insert(0, scheme + "://");
143 143
144 return url; 144 return url;
145 } 145 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_view.cc ('k') | chrome/browser/ui/views/download/download_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698