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

Side by Side Diff: components/search_engines/desktop_search_utils.cc

Issue 1983773002: Cache SearchEngineType of TemplateURL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor-extracting-terms-from-template-url
Patch Set: Move calculation to TemplateURLData Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/search_engines/desktop_search_utils.h" 5 #include "components/search_engines/desktop_search_utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 if (!base::FeatureList::IsEnabled(kDesktopSearchRedirectionFeature)) { 106 if (!base::FeatureList::IsEnabled(kDesktopSearchRedirectionFeature)) {
107 RecordDesktopSearchURLAction( 107 RecordDesktopSearchURLAction(
108 DESKTOP_SEARCH_URL_ACTION_NO_REDIRECTION_FEATURE_DISABLED); 108 DESKTOP_SEARCH_URL_ACTION_NO_REDIRECTION_FEATURE_DISABLED);
109 return false; 109 return false;
110 } 110 }
111 111
112 // Check if the default search engine is Bing. 112 // Check if the default search engine is Bing.
113 const TemplateURL* default_search_engine = 113 const TemplateURL* default_search_engine =
114 template_url_service->GetDefaultSearchProvider(); 114 template_url_service->GetDefaultSearchProvider();
115 if (default_search_engine && 115 if (default_search_engine &&
116 TemplateURLPrepopulateData::GetEngineType( 116 default_search_engine->GetEngineType(
117 *default_search_engine, template_url_service->search_terms_data()) == 117 template_url_service->search_terms_data()) ==
118 SEARCH_ENGINE_BING) { 118 SEARCH_ENGINE_BING) {
119 RecordDesktopSearchURLAction( 119 RecordDesktopSearchURLAction(
120 DESKTOP_SEARCH_URL_ACTION_NO_REDIRECTION_DEFAULT_SEARCH_IS_BING); 120 DESKTOP_SEARCH_URL_ACTION_NO_REDIRECTION_DEFAULT_SEARCH_IS_BING);
121 return false; 121 return false;
122 } 122 }
123 123
124 // Replace |url| by a default search engine URL. 124 // Replace |url| by a default search engine URL.
125 GURL search_url( 125 GURL search_url(
126 GetDefaultSearchURLForSearchTerms(template_url_service, search_terms)); 126 GetDefaultSearchURLForSearchTerms(template_url_service, search_terms));
127 if (!search_url.is_valid()) { 127 if (!search_url.is_valid()) {
128 RecordDesktopSearchURLAction( 128 RecordDesktopSearchURLAction(
129 DESKTOP_SEARCH_URL_ACTION_NO_REDIRECTION_INVALID_SEARCH_ENGINE); 129 DESKTOP_SEARCH_URL_ACTION_NO_REDIRECTION_INVALID_SEARCH_ENGINE);
130 return false; 130 return false;
131 } 131 }
132 132
133 RecordDesktopSearchURLAction(DESKTOP_SEARCH_URL_ACTION_REDIRECTION); 133 RecordDesktopSearchURLAction(DESKTOP_SEARCH_URL_ACTION_REDIRECTION);
134 134
135 url->Swap(&search_url); 135 url->Swap(&search_url);
136 return !pref_service->GetBoolean( 136 return !pref_service->GetBoolean(
137 prefs::kDesktopSearchRedirectionInfobarShownPref); 137 prefs::kDesktopSearchRedirectionInfobarShownPref);
138 } 138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698