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

Side by Side Diff: chrome/browser/search_engines/template_url_service.cc

Issue 9811022: Misc. small cleanups to minimize TemplateURL refactoring diffs: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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/search_engines/template_url_service.h" 5 #include "chrome/browser/search_engines/template_url_service.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/i18n/case_conversion.h" 10 #include "base/i18n/case_conversion.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 236 }
237 237
238 bool TemplateURLService::CanReplaceKeyword( 238 bool TemplateURLService::CanReplaceKeyword(
239 const string16& keyword, 239 const string16& keyword,
240 const GURL& url, 240 const GURL& url,
241 const TemplateURL** template_url_to_replace) { 241 const TemplateURL** template_url_to_replace) {
242 DCHECK(!keyword.empty()); // This should only be called for non-empty 242 DCHECK(!keyword.empty()); // This should only be called for non-empty
243 // keywords. If we need to support empty kewords 243 // keywords. If we need to support empty kewords
244 // the code needs to change slightly. 244 // the code needs to change slightly.
245 const TemplateURL* existing_url = GetTemplateURLForKeyword(keyword); 245 const TemplateURL* existing_url = GetTemplateURLForKeyword(keyword);
246 if (template_url_to_replace)
247 *template_url_to_replace = existing_url;
246 if (existing_url) { 248 if (existing_url) {
247 // We already have a TemplateURL for this keyword. Only allow it to be 249 // We already have a TemplateURL for this keyword. Only allow it to be
248 // replaced if the TemplateURL can be replaced. 250 // replaced if the TemplateURL can be replaced.
249 if (template_url_to_replace)
250 *template_url_to_replace = existing_url;
251 return CanReplace(existing_url); 251 return CanReplace(existing_url);
252 } 252 }
253 253
254 // We don't have a TemplateURL with keyword. Only allow a new one if there 254 // We don't have a TemplateURL with keyword. Only allow a new one if there
255 // isn't a TemplateURL for the specified host, or there is one but it can 255 // isn't a TemplateURL for the specified host, or there is one but it can
256 // be replaced. We do this to ensure that if the user assigns a different 256 // be replaced. We do this to ensure that if the user assigns a different
257 // keyword to a generated TemplateURL, we won't regenerate another keyword for 257 // keyword to a generated TemplateURL, we won't regenerate another keyword for
258 // the same host. 258 // the same host.
259 if (url.is_valid() && !url.host().empty()) 259 if (url.is_valid() && !url.host().empty())
260 return CanReplaceKeywordForHost(url.host(), template_url_to_replace); 260 return CanReplaceKeywordForHost(url.host(), template_url_to_replace);
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 dst->set_input_encodings(input_encodings); 1908 dst->set_input_encodings(input_encodings);
1909 dst->set_show_in_default_list(specifics.show_in_default_list()); 1909 dst->set_show_in_default_list(specifics.show_in_default_list());
1910 dst->SetSuggestionsURL(specifics.suggestions_url(), 0, 0); 1910 dst->SetSuggestionsURL(specifics.suggestions_url(), 0, 0);
1911 dst->SetPrepopulateId(specifics.prepopulate_id()); 1911 dst->SetPrepopulateId(specifics.prepopulate_id());
1912 dst->set_autogenerate_keyword(specifics.autogenerate_keyword()); 1912 dst->set_autogenerate_keyword(specifics.autogenerate_keyword());
1913 dst->SetInstantURL(specifics.instant_url(), 0, 0); 1913 dst->SetInstantURL(specifics.instant_url(), 0, 0);
1914 dst->set_last_modified( 1914 dst->set_last_modified(
1915 base::Time::FromInternalValue(specifics.last_modified())); 1915 base::Time::FromInternalValue(specifics.last_modified()));
1916 dst->set_sync_guid(specifics.sync_guid()); 1916 dst->set_sync_guid(specifics.sync_guid());
1917 } 1917 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698