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

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

Issue 2290503003: Remove use of stl_util in search_engines. (Closed)
Patch Set: rebase Created 4 years, 3 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/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
8 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/search_engines/template_url_service_factory.h" 12 #include "chrome/browser/search_engines/template_url_service_factory.h"
12 #include "components/search_engines/template_url.h" 13 #include "components/search_engines/template_url.h"
13 #include "components/search_engines/template_url_service.h" 14 #include "components/search_engines/template_url_service.h"
14 #include "components/url_formatter/url_fixer.h" 15 #include "components/url_formatter/url_fixer.h"
15 #include "content/public/browser/user_metrics.h" 16 #include "content/public/browser/user_metrics.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // 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
98 // 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.
99 CleanUpCancelledAdd(); 100 CleanUpCancelledAdd();
100 return; 101 return;
101 } 102 }
102 103
103 if (!edit_keyword_delegate_) { 104 if (!edit_keyword_delegate_) {
104 // Confiming an entry we got from JS. We have a template_url_, but it 105 // Confiming an entry we got from JS. We have a template_url_, but it
105 // hasn't yet been added to the model. 106 // hasn't yet been added to the model.
106 DCHECK(template_url_); 107 DCHECK(template_url_);
107 // TemplateURLService takes ownership of template_url_. 108 template_url_service->AddWithOverrides(base::WrapUnique(template_url_),
Peter Kasting 2016/09/01 08:21:39 Urgh, apparently sometimes this class owns this ra
Avi (use Gerrit) 2016/09/01 15:14:47 Yep, this is super sloppy. I'm going to pass since
Peter Kasting 2016/09/01 20:25:05 Filed https://bugs.chromium.org/p/chromium/issues/
108 template_url_service->AddWithOverrides(template_url_, title_input, 109 title_input, keyword_input,
109 keyword_input, url_string); 110 url_string);
110 content::RecordAction(UserMetricsAction("KeywordEditor_AddKeywordJS")); 111 content::RecordAction(UserMetricsAction("KeywordEditor_AddKeywordJS"));
111 } else { 112 } else {
112 // Adding or modifying an entry via the Delegate. 113 // Adding or modifying an entry via the Delegate.
113 edit_keyword_delegate_->OnEditedKeyword(template_url_, title_input, 114 edit_keyword_delegate_->OnEditedKeyword(template_url_, title_input,
114 keyword_input, url_string); 115 keyword_input, url_string);
115 } 116 }
116 } 117 }
117 118
118 void EditSearchEngineController::CleanUpCancelledAdd() { 119 void EditSearchEngineController::CleanUpCancelledAdd() {
119 if (!edit_keyword_delegate_ && template_url_) { 120 if (!edit_keyword_delegate_ && template_url_) {
(...skipping 22 matching lines...) Expand all
142 std::string expanded_url(t_url.url_ref().ReplaceSearchTerms( 143 std::string expanded_url(t_url.url_ref().ReplaceSearchTerms(
143 TemplateURLRef::SearchTermsArgs(base::ASCIIToUTF16("x")), 144 TemplateURLRef::SearchTermsArgs(base::ASCIIToUTF16("x")),
144 TemplateURLServiceFactory::GetForProfile(profile_)->search_terms_data())); 145 TemplateURLServiceFactory::GetForProfile(profile_)->search_terms_data()));
145 url::Parsed parts; 146 url::Parsed parts;
146 std::string scheme(url_formatter::SegmentURL(expanded_url, &parts)); 147 std::string scheme(url_formatter::SegmentURL(expanded_url, &parts));
147 if (!parts.scheme.is_valid()) 148 if (!parts.scheme.is_valid())
148 url.insert(0, scheme + "://"); 149 url.insert(0, scheme + "://");
149 150
150 return url; 151 return url;
151 } 152 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698