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

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

Issue 10021008: Reland r131019: Move most TemplateURL data members to a new struct, TemplateURLData. This allows us… (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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/search_engines/edit_search_engine_controller.cc
===================================================================
--- chrome/browser/ui/search_engines/edit_search_engine_controller.cc (revision 131175)
+++ chrome/browser/ui/search_engines/edit_search_engine_controller.cc (working copy)
@@ -41,8 +41,9 @@
// contains replacement strings. We do this by constructing a dummy
// TemplateURL owner because |template_url_| might be NULL and we can't call
// TemplateURLRef::IsValid() when its owner is NULL.
- TemplateURL t_url;
- t_url.SetURL(url);
+ TemplateURLData data;
+ data.SetURL(url);
+ TemplateURL t_url(data);
const TemplateURLRef& template_ref = t_url.url_ref();
if (!template_ref.IsValid())
return false;
@@ -97,15 +98,9 @@
// Confiming an entry we got from JS. We have a template_url_, but it
// hasn't yet been added to the model.
DCHECK(template_url_);
- // const_cast is ugly, but this is the same thing the TemplateURLService
- // does in a similar situation (updating an existing TemplateURL with
- // data from a new one).
- TemplateURL* modifiable_url = const_cast<TemplateURL*>(template_url_);
- modifiable_url->set_short_name(title_input);
- modifiable_url->set_keyword(keyword_input);
- modifiable_url->SetURL(url_string);
// TemplateURLService takes ownership of template_url_.
- template_url_service->Add(modifiable_url);
+ template_url_service->AddWithOverrides(template_url_, title_input,
+ keyword_input, url_string);
content::RecordAction(UserMetricsAction("KeywordEditor_AddKeywordJS"));
} else {
// Adding or modifying an entry via the Delegate.
@@ -134,8 +129,9 @@
// Parse the string as a URL to determine the scheme. If we need to, add the
// scheme. As the scheme may be expanded (as happens with {google:baseURL})
// we need to replace the search terms before testing for the scheme.
- TemplateURL t_url;
- t_url.SetURL(url);
+ TemplateURLData data;
+ data.SetURL(url);
+ TemplateURL t_url(data);
std::string expanded_url(t_url.url_ref().ReplaceSearchTerms(ASCIIToUTF16("x"),
TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
url_parse::Parsed parts;

Powered by Google App Engine
This is Rietveld 408576698