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

Unified Diff: chrome/browser/search_engines/template_url.cc

Issue 272573004: Handle TemplateURLService load failure better, and make some test correctness fixes that will be ne… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback. Created 6 years, 7 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/search_engines/template_url.cc
diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc
index 874b4bbaa33bed834f6211b2bcf0b8aac9fc5ff7..f19bf61821bcb4f376dd9062647a043a9b7589b9 100644
--- a/chrome/browser/search_engines/template_url.cc
+++ b/chrome/browser/search_engines/template_url.cc
@@ -1112,6 +1112,33 @@ GURL TemplateURL::GenerateFaviconURL(const GURL& url) {
return url.ReplaceComponents(rep);
}
+// static
+bool TemplateURL::MatchesData(const TemplateURL* t_url,
+ const TemplateURLData* data) {
+ if (!t_url || !data)
+ return !t_url && !data;
+
+ return (t_url->short_name() == data->short_name) &&
+ t_url->HasSameKeywordAs(*data) &&
+ (t_url->url() == data->url()) &&
+ (t_url->suggestions_url() == data->suggestions_url) &&
+ (t_url->instant_url() == data->instant_url) &&
+ (t_url->image_url() == data->image_url) &&
+ (t_url->new_tab_url() == data->new_tab_url) &&
+ (t_url->search_url_post_params() == data->search_url_post_params) &&
+ (t_url->suggestions_url_post_params() ==
+ data->suggestions_url_post_params) &&
+ (t_url->instant_url_post_params() == data->instant_url_post_params) &&
+ (t_url->image_url_post_params() == data->image_url_post_params) &&
+ (t_url->favicon_url() == data->favicon_url) &&
+ (t_url->safe_for_autoreplace() == data->safe_for_autoreplace) &&
+ (t_url->show_in_default_list() == data->show_in_default_list) &&
+ (t_url->input_encodings() == data->input_encodings) &&
+ (t_url->alternate_urls() == data->alternate_urls) &&
+ (t_url->search_terms_replacement_key() ==
+ data->search_terms_replacement_key);
+}
+
base::string16 TemplateURL::AdjustedShortNameForLocaleDirection() const {
base::string16 bidi_safe_short_name = data_.short_name;
base::i18n::AdjustStringForLocaleDirection(&bidi_safe_short_name);
@@ -1132,6 +1159,14 @@ bool TemplateURL::SupportsReplacementUsingTermsData(
return url_ref_.SupportsReplacementUsingTermsData(search_terms_data);
}
+bool TemplateURL::HasGoogleBaseURLs() const {
+ return url_ref_.HasGoogleBaseURLs() ||
+ suggestions_url_ref_.HasGoogleBaseURLs() ||
+ instant_url_ref_.HasGoogleBaseURLs() ||
+ image_url_ref_.HasGoogleBaseURLs() ||
+ new_tab_url_ref_.HasGoogleBaseURLs();
+}
+
bool TemplateURL::IsGoogleSearchURLWithReplaceableKeyword() const {
return (GetType() == NORMAL) && url_ref_.HasGoogleBaseURLs() &&
google_util::IsGoogleHostname(base::UTF16ToUTF8(data_.keyword()),

Powered by Google App Engine
This is Rietveld 408576698