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

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

Issue 354773002: Reduces dependency from AutocompleteMatch to Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix 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 37dfca009444ba0485cc889be725d86c9d63c2d6..b5b4a5a63c0eb2139476fcac736eae1658a6a69f 100644
--- a/chrome/browser/autocomplete/autocomplete_match.cc
+++ b/chrome/browser/autocomplete/autocomplete_match.cc
@@ -13,10 +13,7 @@
#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 {
@@ -345,7 +342,8 @@ bool AutocompleteMatch::IsSpecializedSearchType(Type type) {
type == AutocompleteMatchType::SEARCH_SUGGEST_ANSWER;
}
-void AutocompleteMatch::ComputeStrippedDestinationURL(Profile* profile) {
+void AutocompleteMatch::ComputeStrippedDestinationURL(
+ TemplateURLService* template_url_service) {
stripped_destination_url = destination_url;
if (!stripped_destination_url.is_valid())
return;
@@ -355,18 +353,19 @@ void AutocompleteMatch::ComputeStrippedDestinationURL(Profile* profile) {
// 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(profile, true);
- UIThreadSearchTermsData search_terms_data(profile);
+ TemplateURL* template_url = GetTemplateURL(template_url_service, true);
if (template_url != NULL &&
- template_url->SupportsReplacement(search_terms_data)) {
+ template_url->SupportsReplacement(
+ template_url_service->search_terms_data())) {
base::string16 search_terms;
- if (template_url->ExtractSearchTermsFromURL(stripped_destination_url,
- search_terms_data,
- &search_terms)) {
+ if (template_url->ExtractSearchTermsFromURL(
+ stripped_destination_url,
+ template_url_service->search_terms_data(),
+ &search_terms)) {
stripped_destination_url =
GURL(template_url->url_ref().ReplaceSearchTerms(
TemplateURLRef::SearchTermsArgs(search_terms),
- search_terms_data));
+ template_url_service->search_terms_data()));
}
}
@@ -399,29 +398,32 @@ void AutocompleteMatch::ComputeStrippedDestinationURL(Profile* profile) {
replacements);
}
-void AutocompleteMatch::GetKeywordUIState(Profile* profile,
- base::string16* keyword,
- bool* is_keyword_hint) const {
+void AutocompleteMatch::GetKeywordUIState(
+ TemplateURLService* template_url_service,
+ base::string16* keyword,
+ bool* is_keyword_hint) const {
*is_keyword_hint = associated_keyword.get() != NULL;
keyword->assign(*is_keyword_hint ? associated_keyword->keyword :
- GetSubstitutingExplicitlyInvokedKeyword(profile));
+ GetSubstitutingExplicitlyInvokedKeyword(template_url_service));
}
base::string16 AutocompleteMatch::GetSubstitutingExplicitlyInvokedKeyword(
- Profile* profile) const {
+ TemplateURLService* template_url_service) const {
if (transition != content::PAGE_TRANSITION_KEYWORD)
return base::string16();
- const TemplateURL* t_url = GetTemplateURL(profile, false);
+ if (template_url_service == NULL)
Peter Kasting 2014/06/30 23:55:46 Nit: Combine this with the conditional above
Jun Mukai 2014/07/01 00:08:01 Done.
+ return base::string16();
+
+ const TemplateURL* t_url = GetTemplateURL(template_url_service, false);
return (t_url &&
- t_url->SupportsReplacement(UIThreadSearchTermsData(profile))) ?
+ t_url->SupportsReplacement(
+ template_url_service->search_terms_data())) ?
keyword : base::string16();
}
TemplateURL* AutocompleteMatch::GetTemplateURL(
- Profile* profile, bool allow_fallback_to_destination_host) const {
- DCHECK(profile);
- TemplateURLService* template_url_service =
- TemplateURLServiceFactory::GetForProfile(profile);
+ TemplateURLService* template_url_service,
+ bool allow_fallback_to_destination_host) const {
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