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

Unified Diff: chrome/browser/search_engines/edit_search_engine_controller.cc

Issue 361032: Added validation to adding new search engines (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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/cocoa/edit_search_engine_cocoa_controller_unittest.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search_engines/edit_search_engine_controller.cc
===================================================================
--- chrome/browser/search_engines/edit_search_engine_controller.cc (revision 31034)
+++ chrome/browser/search_engines/edit_search_engine_controller.cc (working copy)
@@ -24,7 +24,7 @@
bool EditSearchEngineController::IsTitleValid(
const std::wstring& title_input) const {
- return !title_input.empty();
+ return !CollapseWhitespace(title_input, true).empty();
}
bool EditSearchEngineController::IsURLValid(
@@ -50,10 +50,12 @@
bool EditSearchEngineController::IsKeywordValid(
const std::wstring& keyword_input) const {
- if (keyword_input.empty())
- return true; // Always allow no keyword.
+ std::wstring keyword_input_trimmed(CollapseWhitespace(keyword_input, true));
+ if (keyword_input_trimmed.empty())
+ return false; // Do not allow empty keyword.
const TemplateURL* turl_with_keyword =
- profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword_input);
+ profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(
+ keyword_input_trimmed);
return (turl_with_keyword == NULL || turl_with_keyword == template_url_);
}
« no previous file with comments | « chrome/browser/cocoa/edit_search_engine_cocoa_controller_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698