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

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

Issue 10033017: More misc. cleanups to minimize future refactoring diffs. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/net/url_fixer_upper.h" 9 #include "chrome/browser/net/url_fixer_upper.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const TemplateURL* turl_with_keyword = 69 const TemplateURL* turl_with_keyword =
70 TemplateURLServiceFactory::GetForProfile(profile_)-> 70 TemplateURLServiceFactory::GetForProfile(profile_)->
71 GetTemplateURLForKeyword(keyword_input_trimmed); 71 GetTemplateURLForKeyword(keyword_input_trimmed);
72 return (turl_with_keyword == NULL || turl_with_keyword == template_url_); 72 return (turl_with_keyword == NULL || turl_with_keyword == template_url_);
73 } 73 }
74 74
75 void EditSearchEngineController::AcceptAddOrEdit( 75 void EditSearchEngineController::AcceptAddOrEdit(
76 const string16& title_input, 76 const string16& title_input,
77 const string16& keyword_input, 77 const string16& keyword_input,
78 const std::string& url_input) { 78 const std::string& url_input) {
79 DCHECK(!keyword_input.empty());
79 std::string url_string = GetFixedUpURL(url_input); 80 std::string url_string = GetFixedUpURL(url_input);
80 DCHECK(!url_string.empty()); 81 DCHECK(!url_string.empty());
81 82
82 TemplateURLService* template_url_service = 83 TemplateURLService* template_url_service =
83 TemplateURLServiceFactory::GetForProfile(profile_); 84 TemplateURLServiceFactory::GetForProfile(profile_);
84 const TemplateURL* existing = 85 const TemplateURL* existing =
85 template_url_service->GetTemplateURLForKeyword(keyword_input); 86 template_url_service->GetTemplateURLForKeyword(keyword_input);
86 if (existing && (!edit_keyword_delegate_ || existing != template_url_)) { 87 if (existing && (!edit_keyword_delegate_ || existing != template_url_)) {
87 // An entry may have been added with the same keyword string while the 88 // An entry may have been added with the same keyword string while the
88 // user edited the dialog, either automatically or by the user (if we're 89 // user edited the dialog, either automatically or by the user (if we're
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 std::string expanded_url(t_url.url_ref().ReplaceSearchTerms(ASCIIToUTF16("x"), 136 std::string expanded_url(t_url.url_ref().ReplaceSearchTerms(ASCIIToUTF16("x"),
136 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())); 137 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
137 url_parse::Parsed parts; 138 url_parse::Parsed parts;
138 std::string scheme(URLFixerUpper::SegmentURL(expanded_url, &parts)); 139 std::string scheme(URLFixerUpper::SegmentURL(expanded_url, &parts));
139 if (!parts.scheme.is_valid()) 140 if (!parts.scheme.is_valid())
140 url.insert(0, scheme + "://"); 141 url.insert(0, scheme + "://");
141 142
142 return url; 143 return url;
143 } 144 }
144 145
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698