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

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

Issue 354773002: Reduces dependency from AutocompleteMatch to Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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_controller.cc
diff --git a/chrome/browser/autocomplete/autocomplete_controller.cc b/chrome/browser/autocomplete/autocomplete_controller.cc
index 951990045fb54e2168a734ec9f733b0236984d81..4c04f9d7fb9218a19f8dba086eb19829daf0a487 100644
--- a/chrome/browser/autocomplete/autocomplete_controller.cc
+++ b/chrome/browser/autocomplete/autocomplete_controller.cc
@@ -27,6 +27,7 @@
#include "chrome/browser/omnibox/omnibox_field_trial.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/search.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/browser/notification_service.h"
@@ -406,7 +407,9 @@ void AutocompleteController::ResetSession() {
void AutocompleteController::UpdateMatchDestinationURL(
base::TimeDelta query_formulation_time,
AutocompleteMatch* match) const {
- TemplateURL* template_url = match->GetTemplateURL(profile_, false);
+ TemplateURLService* service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
blundell 2014/06/26 09:00:00 This class will eventually need to have the Templa
Jun Mukai 2014/06/26 21:01:19 Agree, it would be better to pass TemplateURLServi
+ TemplateURL* template_url = match->GetTemplateURL(service, false);
if (!template_url || !match->search_terms_args.get() ||
match->search_terms_args->assisted_query_stats.empty())
return;
@@ -453,8 +456,11 @@ void AutocompleteController::UpdateResult(
i != providers_.end(); ++i)
result_.AppendMatches((*i)->matches());
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+
// Sort the matches and trim to a small number of "best" matches.
- result_.SortAndCull(input_, profile_);
+ result_.SortAndCull(input_, template_url_service);
// Need to validate before invoking CopyOldMatches as the old matches are not
// valid against the current input.
@@ -465,7 +471,7 @@ void AutocompleteController::UpdateResult(
if (!done_) {
// This conditional needs to match the conditional in Start that invokes
// StartExpireTimer.
- result_.CopyOldMatches(input_, last_result, profile_);
+ result_.CopyOldMatches(input_, last_result, template_url_service);
}
UpdateKeywordDescriptions(&result_);
@@ -507,10 +513,12 @@ void AutocompleteController::UpdateAssociatedKeywords(
return;
std::set<base::string16> keywords;
+ TemplateURLService* service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
for (ACMatches::iterator match(result->begin()); match != result->end();
++match) {
base::string16 keyword(
- match->GetSubstitutingExplicitlyInvokedKeyword(profile_));
+ match->GetSubstitutingExplicitlyInvokedKeyword(service));
if (!keyword.empty()) {
keywords.insert(keyword);
continue;
@@ -537,6 +545,8 @@ void AutocompleteController::UpdateAssociatedKeywords(
void AutocompleteController::UpdateKeywordDescriptions(
AutocompleteResult* result) {
base::string16 last_keyword;
+ TemplateURLService* service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
for (AutocompleteResult::iterator i(result->begin()); i != result->end();
++i) {
if (AutocompleteMatch::IsSearchType(i->type)) {
@@ -546,7 +556,7 @@ void AutocompleteController::UpdateKeywordDescriptions(
i->description_class.clear();
DCHECK(!i->keyword.empty());
if (i->keyword != last_keyword) {
- const TemplateURL* template_url = i->GetTemplateURL(profile_, false);
+ const TemplateURL* template_url = i->GetTemplateURL(service, false);
if (template_url) {
// For extension keywords, just make the description the extension
// name -- don't assume that the normal search keyword description is
@@ -597,9 +607,11 @@ void AutocompleteController::UpdateAssistedQueryStats(
AppendAvailableAutocompletion(
last_type, last_subtype, count, &autocompletions);
// Go over all matches and set AQS if the match supports it.
+ TemplateURLService* service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
for (size_t index = 0; index < result->size(); ++index) {
AutocompleteMatch* match = result->match_at(index);
- const TemplateURL* template_url = match->GetTemplateURL(profile_, false);
+ const TemplateURL* template_url = match->GetTemplateURL(service, false);
if (!template_url || !match->search_terms_args.get())
continue;
std::string selected_index;
« no previous file with comments | « no previous file | chrome/browser/autocomplete/autocomplete_match.h » ('j') | chrome/browser/autocomplete/autocomplete_match.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698