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

Unified Diff: components/search_engines/template_url.cc

Issue 2347973002: Enable Chrome to tweak search engines for some locales (Closed)
Patch Set: fix compile 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 side-by-side diff with in-line comments
Download patch
Index: components/search_engines/template_url.cc
diff --git a/components/search_engines/template_url.cc b/components/search_engines/template_url.cc
index 62a2d094f0c3f1857b7f5aa14ea194f9ad0c5db5..d08b3b9320e254430fad3c4747baa46aad6e05cc 100644
--- a/components/search_engines/template_url.cc
+++ b/components/search_engines/template_url.cc
@@ -1182,28 +1182,22 @@ std::string TemplateURLRef::HandleReplacements(
// TemplateURL ----------------------------------------------------------------
TemplateURL::AssociatedExtensionInfo::AssociatedExtensionInfo(
- Type type,
const std::string& extension_id)
- : type(type),
- extension_id(extension_id),
- wants_to_be_default_engine(false) {
- DCHECK_NE(NORMAL, type);
-}
+ : extension_id(extension_id), wants_to_be_default_engine(false) {}
TemplateURL::AssociatedExtensionInfo::~AssociatedExtensionInfo() {
}
-TemplateURL::TemplateURL(const TemplateURLData& data)
+TemplateURL::TemplateURL(const TemplateURLData& data, Type type)
: data_(data),
url_ref_(nullptr),
- suggestions_url_ref_(this,
- TemplateURLRef::SUGGEST),
- instant_url_ref_(this,
- TemplateURLRef::INSTANT),
+ suggestions_url_ref_(this, TemplateURLRef::SUGGEST),
+ instant_url_ref_(this, TemplateURLRef::INSTANT),
image_url_ref_(this, TemplateURLRef::IMAGE),
new_tab_url_ref_(this, TemplateURLRef::NEW_TAB),
contextual_search_url_ref_(this, TemplateURLRef::CONTEXTUAL_SEARCH),
- engine_type_(SEARCH_ENGINE_UNKNOWN) {
+ engine_type_(SEARCH_ENGINE_UNKNOWN),
+ type_(type) {
ResizeURLRefVector();
SetPrepopulateId(data_.prepopulate_id);
@@ -1307,7 +1301,7 @@ bool TemplateURL::HasGoogleBaseURLs(
bool TemplateURL::IsGoogleSearchURLWithReplaceableKeyword(
const SearchTermsData& search_terms_data) const {
- return (GetType() == NORMAL) &&
+ return (type_ == NORMAL) &&
url_ref_->HasGoogleBaseURLs(search_terms_data) &&
google_util::IsGoogleHostname(base::UTF16ToUTF8(data_.keyword()),
google_util::DISALLOW_SUBDOMAIN);
@@ -1322,10 +1316,6 @@ bool TemplateURL::HasSameKeywordAs(
search_terms_data));
}
-TemplateURL::Type TemplateURL::GetType() const {
- return extension_info_ ? extension_info_->type : NORMAL;
-}
-
std::string TemplateURL::GetExtensionId() const {
DCHECK(extension_info_);
return extension_info_->extension_id;
@@ -1499,7 +1489,7 @@ void TemplateURL::ResetKeywordIfNecessary(
const SearchTermsData& search_terms_data,
bool force) {
if (IsGoogleSearchURLWithReplaceableKeyword(search_terms_data) || force) {
- DCHECK(GetType() != OMNIBOX_API_EXTENSION);
+ DCHECK(type_ != OMNIBOX_API_EXTENSION);
Peter Kasting 2016/09/21 21:45:08 Nit: DCHECK_NE(OMNIBOX_API_EXTENSION, type_)?
Ian Wen 2016/09/21 23:12:38 Done.
GURL url(GenerateSearchURL(search_terms_data));
if (url.is_valid())
data_.SetKeyword(GenerateKeyword(url));

Powered by Google App Engine
This is Rietveld 408576698