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

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

Issue 2816353002: Make const versions GetTemplateURLForKeyword, GetTemplateURLForGUID, GetTemplateURLForHost (Closed)
Patch Set: Make definition and declaration order of new functions match Created 3 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
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/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/metrics/user_metrics.h" 9 #include "base/metrics/user_metrics.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 void EditSearchEngineController::AcceptAddOrEdit( 81 void EditSearchEngineController::AcceptAddOrEdit(
82 const base::string16& title_input, 82 const base::string16& title_input,
83 const base::string16& keyword_input, 83 const base::string16& keyword_input,
84 const std::string& url_input) { 84 const std::string& url_input) {
85 DCHECK(!keyword_input.empty()); 85 DCHECK(!keyword_input.empty());
86 std::string url_string = GetFixedUpURL(url_input); 86 std::string url_string = GetFixedUpURL(url_input);
87 DCHECK(!url_string.empty()); 87 DCHECK(!url_string.empty());
88 88
89 TemplateURLService* template_url_service = 89 TemplateURLService* template_url_service =
90 TemplateURLServiceFactory::GetForProfile(profile_); 90 TemplateURLServiceFactory::GetForProfile(profile_);
91 TemplateURL* existing = 91 const TemplateURL* existing =
92 template_url_service->GetTemplateURLForKeyword(keyword_input); 92 template_url_service->GetTemplateURLForKeyword(keyword_input);
93 if (existing && (!edit_keyword_delegate_ || existing != template_url_)) { 93 if (existing && (!edit_keyword_delegate_ || existing != template_url_)) {
94 // An entry may have been added with the same keyword string while the 94 // An entry may have been added with the same keyword string while the
95 // user edited the dialog, either automatically or by the user (if we're 95 // user edited the dialog, either automatically or by the user (if we're
96 // confirming a JS addition, they could have the Options dialog open at the 96 // confirming a JS addition, they could have the Options dialog open at the
97 // same time). If so, just ignore this add. 97 // same time). If so, just ignore this add.
98 // TODO(pamg): Really, we should modify the entry so this later one 98 // TODO(pamg): Really, we should modify the entry so this later one
99 // overwrites it. But we don't expect this case to be common. 99 // overwrites it. But we don't expect this case to be common.
100 CleanUpCancelledAdd(); 100 CleanUpCancelledAdd();
101 return; 101 return;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 std::string expanded_url(t_url.url_ref().ReplaceSearchTerms( 143 std::string expanded_url(t_url.url_ref().ReplaceSearchTerms(
144 TemplateURLRef::SearchTermsArgs(base::ASCIIToUTF16("x")), 144 TemplateURLRef::SearchTermsArgs(base::ASCIIToUTF16("x")),
145 TemplateURLServiceFactory::GetForProfile(profile_)->search_terms_data())); 145 TemplateURLServiceFactory::GetForProfile(profile_)->search_terms_data()));
146 url::Parsed parts; 146 url::Parsed parts;
147 std::string scheme(url_formatter::SegmentURL(expanded_url, &parts)); 147 std::string scheme(url_formatter::SegmentURL(expanded_url, &parts));
148 if (!parts.scheme.is_valid()) 148 if (!parts.scheme.is_valid())
149 url.insert(0, scheme + "://"); 149 url.insert(0, scheme + "://");
150 150
151 return url; 151 return url;
152 } 152 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/instant_search_prerenderer_unittest.cc ('k') | components/omnibox/browser/autocomplete_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698