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

Unified Diff: chrome/browser/autocomplete/autocomplete_match.cc

Issue 363893002: Revert of Reduces dependency from AutocompleteMatch to Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/autocomplete_match.cc
diff --git a/chrome/browser/autocomplete/autocomplete_match.cc b/chrome/browser/autocomplete/autocomplete_match.cc
index 9a3d13c2705d99b78554b734701d63d0a2e052f2..37dfca009444ba0485cc889be725d86c9d63c2d6 100644
--- a/chrome/browser/autocomplete/autocomplete_match.cc
+++ b/chrome/browser/autocomplete/autocomplete_match.cc
@@ -13,7 +13,10 @@
#include "base/time/time.h"
#include "chrome/browser/autocomplete/autocomplete_provider.h"
#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
#include "components/search_engines/template_url.h"
+#include "content/public/common/url_constants.h"
#include "grit/theme_resources.h"
namespace {
@@ -342,8 +345,7 @@
type == AutocompleteMatchType::SEARCH_SUGGEST_ANSWER;
}
-void AutocompleteMatch::ComputeStrippedDestinationURL(
- TemplateURLService* template_url_service) {
+void AutocompleteMatch::ComputeStrippedDestinationURL(Profile* profile) {
stripped_destination_url = destination_url;
if (!stripped_destination_url.is_valid())
return;
@@ -353,19 +355,18 @@
// to eliminate cases like past search URLs from history that differ only
// by some obscure query param from each other or from the search/keyword
// provider matches.
- TemplateURL* template_url = GetTemplateURL(template_url_service, true);
+ TemplateURL* template_url = GetTemplateURL(profile, true);
+ UIThreadSearchTermsData search_terms_data(profile);
if (template_url != NULL &&
- template_url->SupportsReplacement(
- template_url_service->search_terms_data())) {
+ template_url->SupportsReplacement(search_terms_data)) {
base::string16 search_terms;
- if (template_url->ExtractSearchTermsFromURL(
- stripped_destination_url,
- template_url_service->search_terms_data(),
- &search_terms)) {
+ if (template_url->ExtractSearchTermsFromURL(stripped_destination_url,
+ search_terms_data,
+ &search_terms)) {
stripped_destination_url =
GURL(template_url->url_ref().ReplaceSearchTerms(
TemplateURLRef::SearchTermsArgs(search_terms),
- template_url_service->search_terms_data()));
+ search_terms_data));
}
}
@@ -398,32 +399,29 @@
replacements);
}
-void AutocompleteMatch::GetKeywordUIState(
- TemplateURLService* template_url_service,
- base::string16* keyword,
- bool* is_keyword_hint) const {
+void AutocompleteMatch::GetKeywordUIState(Profile* profile,
+ base::string16* keyword,
+ bool* is_keyword_hint) const {
*is_keyword_hint = associated_keyword.get() != NULL;
keyword->assign(*is_keyword_hint ? associated_keyword->keyword :
- GetSubstitutingExplicitlyInvokedKeyword(template_url_service));
+ GetSubstitutingExplicitlyInvokedKeyword(profile));
}
base::string16 AutocompleteMatch::GetSubstitutingExplicitlyInvokedKeyword(
- TemplateURLService* template_url_service) const {
- if (transition != content::PAGE_TRANSITION_KEYWORD ||
- template_url_service == NULL) {
+ Profile* profile) const {
+ if (transition != content::PAGE_TRANSITION_KEYWORD)
return base::string16();
- }
-
- const TemplateURL* t_url = GetTemplateURL(template_url_service, false);
+ const TemplateURL* t_url = GetTemplateURL(profile, false);
return (t_url &&
- t_url->SupportsReplacement(
- template_url_service->search_terms_data())) ?
+ t_url->SupportsReplacement(UIThreadSearchTermsData(profile))) ?
keyword : base::string16();
}
TemplateURL* AutocompleteMatch::GetTemplateURL(
- TemplateURLService* template_url_service,
- bool allow_fallback_to_destination_host) const {
+ Profile* profile, bool allow_fallback_to_destination_host) const {
+ DCHECK(profile);
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile);
if (template_url_service == NULL)
return NULL;
TemplateURL* template_url = keyword.empty() ? NULL :
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_match.h ('k') | chrome/browser/autocomplete/autocomplete_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698