diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-11 13:17:00 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-11 13:17:00 +0000 |
commit | 35f1f4f0cc2c1a6fbcb5816f4fceb3eb92d04e3c (patch) | |
tree | 53f51a2ebbed3718ac214cba3209b7b0630a4f3f | |
parent | fe4d0c57e4842a913e386a89c67143e0321ca6fe (diff) | |
download | chromium_src-35f1f4f0cc2c1a6fbcb5816f4fceb3eb92d04e3c.zip chromium_src-35f1f4f0cc2c1a6fbcb5816f4fceb3eb92d04e3c.tar.gz chromium_src-35f1f4f0cc2c1a6fbcb5816f4fceb3eb92d04e3c.tar.bz2 |
autocomplete: Add AutocompleteProvider::Type enum.
This drops the AutocompleteProvider class's name field in
favor of an enum describing its type. It also updates
AutocompleteController to take a bitmap describing the types
of providers that it should create, making it easier to use
AutocompleteController in places besides the omnibox.
BUG=141877,147724
TEST=none
TBR=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10909130
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156004 0039d316-1c4b-4281-b951-d872f2087c98
31 files changed, 276 insertions, 218 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_browsertest.cc b/chrome/browser/autocomplete/autocomplete_browsertest.cc index ca38c40..0c91c9c 100644 --- a/chrome/browser/autocomplete/autocomplete_browsertest.cc +++ b/chrome/browser/autocomplete/autocomplete_browsertest.cc @@ -37,10 +37,9 @@ string16 AutocompleteResultAsString(const AutocompleteResult& result) { std::string output(base::StringPrintf("{%" PRIuS "} ", result.size())); for (size_t i = 0; i < result.size(); ++i) { AutocompleteMatch match = result.match_at(i); - std::string provider_name = match.provider->name(); output.append(base::StringPrintf("[\"%s\" by \"%s\"] ", UTF16ToUTF8(match.contents).c_str(), - provider_name.c_str())); + match.provider->GetName())); } return UTF8ToUTF16(output); } diff --git a/chrome/browser/autocomplete/autocomplete_classifier.cc b/chrome/browser/autocomplete/autocomplete_classifier.cc index 9d26485..28f870e 100644 --- a/chrome/browser/autocomplete/autocomplete_classifier.cc +++ b/chrome/browser/autocomplete/autocomplete_classifier.cc @@ -8,10 +8,24 @@ #include "chrome/browser/autocomplete/autocomplete_controller.h" #include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/autocomplete/autocomplete_match.h" +#include "chrome/browser/autocomplete/autocomplete_provider.h" #include "googleurl/src/gurl.h" +// static +const int AutocompleteClassifier::kDefaultOmniboxProviders = + AutocompleteProvider::TYPE_BUILTIN | + AutocompleteProvider::TYPE_EXTENSION_APP | + AutocompleteProvider::TYPE_HISTORY_CONTENTS | + AutocompleteProvider::TYPE_HISTORY_QUICK | + AutocompleteProvider::TYPE_HISTORY_URL | + AutocompleteProvider::TYPE_KEYWORD | + AutocompleteProvider::TYPE_SEARCH | + AutocompleteProvider::TYPE_SHORTCUTS | + AutocompleteProvider::TYPE_ZERO_SUGGEST; + AutocompleteClassifier::AutocompleteClassifier(Profile* profile) - : controller_(new AutocompleteController(profile, NULL)), + : controller_(new AutocompleteController(profile, NULL, + kDefaultOmniboxProviders)), inside_classify_(false) { } diff --git a/chrome/browser/autocomplete/autocomplete_classifier.h b/chrome/browser/autocomplete/autocomplete_classifier.h index 3bb6f8d..17e6474 100644 --- a/chrome/browser/autocomplete/autocomplete_classifier.h +++ b/chrome/browser/autocomplete/autocomplete_classifier.h @@ -18,6 +18,11 @@ class Profile; class AutocompleteClassifier : public ProfileKeyedService { public: + // Bitmap of AutocompleteProvider::Type values describing the default set of + // providers queried for the omnibox. Intended to be passed to + // AutocompleteController(). + static const int kDefaultOmniboxProviders; + explicit AutocompleteClassifier(Profile* profile); virtual ~AutocompleteClassifier(); diff --git a/chrome/browser/autocomplete/autocomplete_controller.cc b/chrome/browser/autocomplete/autocomplete_controller.cc index 5c8d772..fc051a0 100644 --- a/chrome/browser/autocomplete/autocomplete_controller.cc +++ b/chrome/browser/autocomplete/autocomplete_controller.cc @@ -76,43 +76,59 @@ const int AutocompleteController::kNoItemSelected = -1; AutocompleteController::AutocompleteController( Profile* profile, - AutocompleteControllerDelegate* delegate) + AutocompleteControllerDelegate* delegate, + int provider_types) : delegate_(delegate), keyword_provider_(NULL), + search_provider_(NULL), zero_suggest_provider_(NULL), done_(true), in_start_(false), in_zero_suggest_(false), profile_(profile) { - search_provider_ = new SearchProvider(this, profile); - providers_.push_back(search_provider_); -#if !defined(OS_ANDROID) - // History quick provider is enabled on all platforms other than Android. - bool hqp_enabled = true; - providers_.push_back(new HistoryQuickProvider(this, profile)); - // Search provider/"tab to search" is enabled on all platforms other than - // Android. - keyword_provider_ = new KeywordProvider(this, profile); - providers_.push_back(keyword_provider_); -#else - // TODO(mrossetti): Remove the following and permanently modify the - // HistoryURLProvider to not search titles once HQP is turned on permanently. + bool use_hqp = !!(provider_types & AutocompleteProvider::TYPE_HISTORY_QUICK); + // TODO(mrossetti): Permanently modify the HistoryURLProvider to not search + // titles once HQP is turned on permanently. + // History quick provider can be used on all platforms other than Android. // TODO(jcivelli): Enable the History Quick Provider and figure out why it // reports the wrong results for some pages. - bool hqp_enabled = false; -#endif // !OS_ANDROID - providers_.push_back(new HistoryURLProvider(this, profile)); - providers_.push_back(new ShortcutsProvider(this, profile)); - providers_.push_back(new HistoryContentsProvider(this, profile, hqp_enabled)); - providers_.push_back(new BuiltinProvider(this, profile)); - providers_.push_back(new ExtensionAppProvider(this, profile)); - // Create ZeroSuggest if its switch is present. +#if defined(OS_ANDROID) + use_hqp = false; +#endif + + if (provider_types & AutocompleteProvider::TYPE_BUILTIN) + providers_.push_back(new BuiltinProvider(this, profile)); + if (provider_types & AutocompleteProvider::TYPE_EXTENSION_APP) + providers_.push_back(new ExtensionAppProvider(this, profile)); + if (provider_types & AutocompleteProvider::TYPE_HISTORY_CONTENTS) + providers_.push_back(new HistoryContentsProvider(this, profile, use_hqp)); + if (use_hqp) + providers_.push_back(new HistoryQuickProvider(this, profile)); + if (provider_types & AutocompleteProvider::TYPE_HISTORY_URL) + providers_.push_back(new HistoryURLProvider(this, profile)); + // Search provider/"tab to search" can be used on all platforms other than + // Android. +#if !defined(OS_ANDROID) + if (provider_types & AutocompleteProvider::TYPE_KEYWORD) { + keyword_provider_ = new KeywordProvider(this, profile); + providers_.push_back(keyword_provider_); + } +#endif + if (provider_types & AutocompleteProvider::TYPE_SEARCH) { + search_provider_ = new SearchProvider(this, profile); + providers_.push_back(search_provider_); + } + if (provider_types & AutocompleteProvider::TYPE_SHORTCUTS) + providers_.push_back(new ShortcutsProvider(this, profile)); + CommandLine* cl = CommandLine::ForCurrentProcess(); - if (cl->HasSwitch(switches::kExperimentalZeroSuggestURLPrefix)) { + if ((provider_types & AutocompleteProvider::TYPE_ZERO_SUGGEST) && + cl->HasSwitch(switches::kExperimentalZeroSuggestURLPrefix)) { zero_suggest_provider_ = new ZeroSuggestProvider(this, profile, cl->GetSwitchValueASCII(switches::kExperimentalZeroSuggestURLPrefix)); providers_.push_back(zero_suggest_provider_); } + for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i) (*i)->AddRef(); } @@ -393,8 +409,9 @@ void AutocompleteController::UpdateKeywordDescriptions( string16 last_keyword; for (AutocompleteResult::iterator i(result->begin()); i != result->end(); ++i) { - if ((i->provider == keyword_provider_ && !i->keyword.empty()) || - (i->provider == search_provider_ && + if ((i->provider->type() == AutocompleteProvider::TYPE_KEYWORD && + !i->keyword.empty()) || + (i->provider->type() == AutocompleteProvider::TYPE_SEARCH && AutocompleteMatch::IsSearchType(i->type))) { i->description.clear(); i->description_class.clear(); diff --git a/chrome/browser/autocomplete/autocomplete_controller.h b/chrome/browser/autocomplete/autocomplete_controller.h index c66d024..d974d53 100644 --- a/chrome/browser/autocomplete/autocomplete_controller.h +++ b/chrome/browser/autocomplete/autocomplete_controller.h @@ -46,23 +46,12 @@ class AutocompleteController : public AutocompleteProviderListener { // Used to indicate an index that is not selected in a call to Update(). static const int kNoItemSelected; - // Normally, you will call the first constructor. Unit tests can use the - // second to set the providers to some known testing providers. The default - // providers will be overridden and the controller will take ownership of the - // providers, Release()ing them on destruction. + // |provider_types| is a bitmap containing AutocompleteProvider::Type values + // that will (potentially, depending on platform, flags, etc.) be + // instantiated. AutocompleteController(Profile* profile, - AutocompleteControllerDelegate* delegate); -#ifdef UNIT_TEST - AutocompleteController(const ACProviders& providers, Profile* profile) - : delegate_(NULL), - providers_(providers), - keyword_provider_(NULL), - search_provider_(NULL), - done_(true), - in_start_(false), - profile_(profile) { - } -#endif + AutocompleteControllerDelegate* delegate, + int provider_types); ~AutocompleteController(); // Starts an autocomplete query, which continues until all providers are @@ -128,14 +117,6 @@ class AutocompleteController : public AutocompleteProviderListener { // the popup to ensure it's not showing an out-of-date query. void ExpireCopiedEntries(); -#ifdef UNIT_TEST - void set_search_provider(SearchProvider* provider) { - search_provider_ = provider; - } - void set_keyword_provider(KeywordProvider* provider) { - keyword_provider_ = provider; - } -#endif SearchProvider* search_provider() const { return search_provider_; } KeywordProvider* keyword_provider() const { return keyword_provider_; } @@ -161,6 +142,9 @@ class AutocompleteController : public AutocompleteProviderListener { RedundantKeywordsIgnoredInResult); FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, UpdateAssistedQueryStats); + friend class SearchProviderTest; + FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, UpdateKeywordDescriptions); + // Updates |result_| to reflect the current provider state. Resets timers and // fires notifications as necessary. |is_synchronous_pass| is true only when // Start() is calling this to get the synchronous result. diff --git a/chrome/browser/autocomplete/autocomplete_match.cc b/chrome/browser/autocomplete/autocomplete_match.cc index a8b092d..f6d853e 100644 --- a/chrome/browser/autocomplete/autocomplete_match.cc +++ b/chrome/browser/autocomplete/autocomplete_match.cc @@ -438,14 +438,15 @@ void AutocompleteMatch::ValidateClassifications( size_t last_offset = classifications[0].offset; for (ACMatchClassifications::const_iterator i(classifications.begin() + 1); i != classifications.end(); ++i) { + const char* provider_name = provider ? provider->GetName() : "None"; DCHECK_GT(i->offset, last_offset) << " Classification for \"" << text << "\" with offset of " << i->offset << " is unsorted in relation to last offset of " << last_offset - << ". Provider: " << (provider ? provider->name() : "None") << "."; + << ". Provider: " << provider_name << "."; DCHECK_LT(i->offset, text.length()) << " Classification of [" << i->offset << "," << text.length() << "] is out of bounds for \"" << text << "\". Provider: " - << (provider ? provider->name() : "None") << "."; + << provider_name << "."; last_offset = i->offset; } } diff --git a/chrome/browser/autocomplete/autocomplete_provider.cc b/chrome/browser/autocomplete/autocomplete_provider.cc index d2df9e6..58cd5b1b 100644 --- a/chrome/browser/autocomplete/autocomplete_provider.cc +++ b/chrome/browser/autocomplete/autocomplete_provider.cc @@ -24,42 +24,77 @@ const size_t AutocompleteProvider::kMaxMatches = 3; AutocompleteProvider::AutocompleteProvider( AutocompleteProviderListener* listener, Profile* profile, - const char* name) + Type type) : profile_(profile), listener_(listener), done_(true), - name_(name) { + type_(type) { +} + +// static +const char* AutocompleteProvider::TypeToString(Type type) { + switch (type) { + case TYPE_BUILTIN: + return "Builtin"; + case TYPE_EXTENSION_APP: + return "ExtensionApp"; + case TYPE_HISTORY_CONTENTS: + return "HistoryContents"; + case TYPE_HISTORY_QUICK: + return "HistoryQuick"; + case TYPE_HISTORY_URL: + return "HistoryURL"; + case TYPE_KEYWORD: + return "Keyword"; + case TYPE_SEARCH: + return "Search"; + case TYPE_SHORTCUTS: + return "Shortcuts"; + case TYPE_ZERO_SUGGEST: + return "ZeroSuggest"; + default: + NOTREACHED() << "Unhandled AutocompleteProvider::Type " << type; + return "Unknown"; + } } void AutocompleteProvider::Stop(bool clear_cached_results) { done_ = true; } +const char* AutocompleteProvider::GetName() const { + return TypeToString(type_); +} + metrics::OmniboxEventProto_ProviderType AutocompleteProvider:: AsOmniboxEventProviderType() const { - if (name_ == "HistoryURL") - return metrics::OmniboxEventProto::HISTORY_URL; - if (name_ == "HistoryContents") - return metrics::OmniboxEventProto::HISTORY_CONTENTS; - if (name_ == "HistoryQuick") - return metrics::OmniboxEventProto::HISTORY_QUICK; - if (name_ == "Search") - return metrics::OmniboxEventProto::SEARCH; - if (name_ == "Keyword") - return metrics::OmniboxEventProto::KEYWORD; - if (name_ == "Builtin") - return metrics::OmniboxEventProto::BUILTIN; - if (name_ == "Shortcuts") - return metrics::OmniboxEventProto::SHORTCUTS; - if (name_ == "ExtensionApps") - return metrics::OmniboxEventProto::EXTENSION_APPS; - - NOTREACHED(); - return metrics::OmniboxEventProto::UNKNOWN_PROVIDER; + switch (type_) { + case TYPE_BUILTIN: + return metrics::OmniboxEventProto::BUILTIN; + case TYPE_EXTENSION_APP: + return metrics::OmniboxEventProto::EXTENSION_APPS; + case TYPE_HISTORY_CONTENTS: + return metrics::OmniboxEventProto::HISTORY_CONTENTS; + case TYPE_HISTORY_QUICK: + return metrics::OmniboxEventProto::HISTORY_QUICK; + case TYPE_HISTORY_URL: + return metrics::OmniboxEventProto::HISTORY_URL; + case TYPE_KEYWORD: + return metrics::OmniboxEventProto::KEYWORD; + case TYPE_SEARCH: + return metrics::OmniboxEventProto::SEARCH; + case TYPE_SHORTCUTS: + return metrics::OmniboxEventProto::SHORTCUTS; + case TYPE_ZERO_SUGGEST: + // TODO: Add to OmniboxEventProto::ProviderType. + default: + NOTREACHED() << "Unhandled AutocompleteProvider::Type " << type_; + return metrics::OmniboxEventProto::UNKNOWN_PROVIDER; + } } void AutocompleteProvider::DeleteMatch(const AutocompleteMatch& match) { - DLOG(WARNING) << "The AutocompleteProvider '" << name_ + DLOG(WARNING) << "The AutocompleteProvider '" << GetName() << "' has not implemented DeleteMatch."; } diff --git a/chrome/browser/autocomplete/autocomplete_provider.h b/chrome/browser/autocomplete/autocomplete_provider.h index 5b2066d..377a5d3 100644 --- a/chrome/browser/autocomplete/autocomplete_provider.h +++ b/chrome/browser/autocomplete/autocomplete_provider.h @@ -173,10 +173,25 @@ typedef std::vector<metrics::OmniboxEventProto_ProviderInfo> ProvidersInfo; class AutocompleteProvider : public base::RefCountedThreadSafe<AutocompleteProvider> { public: + // Different AutocompleteProvider implementations. + enum Type { + TYPE_BUILTIN = 1 << 0, + TYPE_EXTENSION_APP = 1 << 1, + TYPE_HISTORY_CONTENTS = 1 << 2, + TYPE_HISTORY_QUICK = 1 << 3, + TYPE_HISTORY_URL = 1 << 4, + TYPE_KEYWORD = 1 << 5, + TYPE_SEARCH = 1 << 6, + TYPE_SHORTCUTS = 1 << 7, + TYPE_ZERO_SUGGEST = 1 << 8, + }; AutocompleteProvider(AutocompleteProviderListener* listener, Profile* profile, - const char* name); + Type type); + + // Returns a string describing a particular AutocompleteProvider type. + static const char* TypeToString(Type type); // Called to start an autocomplete query. The provider is responsible for // tracking its matches for this query and whether it is done processing the @@ -208,10 +223,15 @@ class AutocompleteProvider // Returns whether the provider is done processing the query. bool done() const { return done_; } - // Returns the name of this provider. - const std::string& name() const { return name_; } + // Returns this provider's type. + Type type() const { return type_; } + + // Returns a string describing this provider's type. + const char* GetName() const; // Returns the enum equivalent to the name of this provider. + // TODO(derat): Make metrics use AutocompleteProvider::Type directly, or at + // least move this method to the metrics directory. metrics::OmniboxEventProto_ProviderType AsOmniboxEventProviderType() const; // Called to delete a match and the backing data that produced it. This @@ -265,8 +285,7 @@ class AutocompleteProvider ACMatches matches_; bool done_; - // The name of this provider. Used for logging. - std::string name_; + Type type_; private: DISALLOW_COPY_AND_ASSIGN(AutocompleteProvider); diff --git a/chrome/browser/autocomplete/autocomplete_provider_unittest.cc b/chrome/browser/autocomplete/autocomplete_provider_unittest.cc index 61d9cc4..67b2604 100644 --- a/chrome/browser/autocomplete/autocomplete_provider_unittest.cc +++ b/chrome/browser/autocomplete/autocomplete_provider_unittest.cc @@ -45,7 +45,7 @@ class TestProvider : public AutocompleteProvider { TestProvider(int relevance, const string16& prefix, Profile* profile, const string16 match_keyword) - : AutocompleteProvider(NULL, profile, ""), + : AutocompleteProvider(NULL, profile, AutocompleteProvider::TYPE_SEARCH), relevance_(relevance), prefix_(prefix), match_keyword_(match_keyword) { @@ -163,7 +163,11 @@ class AutocompleteProviderTest : public testing::Test, void RegisterTemplateURL(const string16 keyword, const std::string& template_url); - void ResetControllerWithTestProviders(bool same_destinations); + // Resets |controller_| with two TestProviders. |provider1_ptr| and + // |provider2_ptr| are updated to point to the new providers if non-NULL. + void ResetControllerWithTestProviders(bool same_destinations, + TestProvider** provider1_ptr, + TestProvider** provider2_ptr); // Runs a query on the input "a", and makes sure both providers' input is // properly collected. @@ -177,13 +181,10 @@ class AutocompleteProviderTest : public testing::Test, void RunQuery(const string16 query); - void ResetControllerWithTestProvidersWithKeywordAndSearchProviders(); + void ResetControllerWithKeywordAndSearchProviders(); void ResetControllerWithKeywordProvider(); void RunExactKeymatchTest(bool allow_exact_keyword_match); - // These providers are owned by the controller once it's created. - ACProviders providers_; - AutocompleteResult result_; scoped_ptr<AutocompleteController> controller_; @@ -216,11 +217,9 @@ void AutocompleteProviderTest:: RegisterTemplateURL( } void AutocompleteProviderTest::ResetControllerWithTestProviders( - bool same_destinations) { - // Forget about any existing providers. The controller owns them and will - // Release() them below, when we delete it during the call to reset(). - providers_.clear(); - + bool same_destinations, + TestProvider** provider1_ptr, + TestProvider** provider2_ptr) { // TODO: Move it outside this method, after refactoring the existing // unit tests. Specifically: // (1) Make sure that AutocompleteMatch.keyword is set iff there is @@ -234,39 +233,45 @@ void AutocompleteProviderTest::ResetControllerWithTestProviders( RegisterTemplateURL(ASCIIToUTF16(kTestTemplateURLKeyword), "http://aqs/{searchTerms}/{google:assistedQueryStats}"); + ACProviders providers; + // Construct two new providers, with either the same or different prefixes. - TestProvider* providerA = - new TestProvider(kResultsPerProvider, - ASCIIToUTF16("http://a"), - &profile_, - ASCIIToUTF16(kTestTemplateURLKeyword)); - providerA->AddRef(); - providers_.push_back(providerA); - - TestProvider* providerB = new TestProvider( + TestProvider* provider1 = new TestProvider( + kResultsPerProvider, + ASCIIToUTF16("http://a"), + &profile_, + ASCIIToUTF16(kTestTemplateURLKeyword)); + provider1->AddRef(); + providers.push_back(provider1); + + TestProvider* provider2 = new TestProvider( kResultsPerProvider * 2, same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b"), &profile_, string16()); - providerB->AddRef(); - providers_.push_back(providerB); + provider2->AddRef(); + providers.push_back(provider2); // Reset the controller to contain our new providers. - AutocompleteController* controller = - new AutocompleteController(providers_, &profile_); - controller_.reset(controller); - providerA->set_listener(controller); - providerB->set_listener(controller); + controller_.reset(new AutocompleteController(&profile_, NULL, 0)); + controller_->providers_.swap(providers); + provider1->set_listener(controller_.get()); + provider2->set_listener(controller_.get()); // The providers don't complete synchronously, so listen for "result updated" // notifications. registrar_.Add(this, chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, - content::Source<AutocompleteController>(controller)); + content::Source<AutocompleteController>(controller_.get())); + + if (provider1_ptr) + *provider1_ptr = provider1; + if (provider2_ptr) + *provider2_ptr = provider2; } void AutocompleteProviderTest:: - ResetControllerWithTestProvidersWithKeywordAndSearchProviders() { + ResetControllerWithKeywordAndSearchProviders() { TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( &profile_, &TemplateURLServiceFactory::BuildInstanceFor); @@ -289,20 +294,9 @@ void AutocompleteProviderTest:: turl_model->Add(keyword_t_url); ASSERT_NE(0, keyword_t_url->id()); - // Forget about any existing providers. The controller owns them and will - // Release() them below, when we delete it during the call to reset(). - providers_.clear(); - - // Create both a keyword and search provider, and add them in that order. - // (Order is important; see comments in RunExactKeymatchTest().) - AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, &profile_); - keyword_provider->AddRef(); - providers_.push_back(keyword_provider); - AutocompleteProvider* search_provider = new SearchProvider(NULL, &profile_); - search_provider->AddRef(); - providers_.push_back(search_provider); - - controller_.reset(new AutocompleteController(providers_, &profile_)); + controller_.reset(new AutocompleteController( + &profile_, NULL, + AutocompleteProvider::TYPE_KEYWORD | AutocompleteProvider::TYPE_SEARCH)); } void AutocompleteProviderTest::ResetControllerWithKeywordProvider() { @@ -329,20 +323,8 @@ void AutocompleteProviderTest::ResetControllerWithKeywordProvider() { turl_model->Add(keyword_t_url); ASSERT_NE(0, keyword_t_url->id()); - // Forget about any existing providers. The controller owns them and will - // Release() them below, when we delete it during the call to reset(). - providers_.clear(); - - // Create both a keyword and search provider, and add them in that order. - // (Order is important; see comments in RunExactKeymatchTest().) - KeywordProvider* keyword_provider = new KeywordProvider(NULL, &profile_); - keyword_provider->AddRef(); - providers_.push_back(keyword_provider); - - AutocompleteController* controller = - new AutocompleteController(providers_, &profile_); - controller->set_keyword_provider(keyword_provider); - controller_.reset(controller); + controller_.reset(new AutocompleteController( + &profile_, NULL, AutocompleteProvider::TYPE_KEYWORD)); } void AutocompleteProviderTest::RunTest() { @@ -419,11 +401,9 @@ void AutocompleteProviderTest::RunExactKeymatchTest( allow_exact_keyword_match, AutocompleteInput::SYNCHRONOUS_MATCHES); EXPECT_TRUE(controller_->done()); - // ResetControllerWithKeywordAndSearchProviders() adds the keyword provider - // first, then the search provider. So if the default match is a keyword - // match, it will come from provider 0, otherwise from provider 1. - EXPECT_EQ(providers_[allow_exact_keyword_match ? 0 : 1], - controller_->result().default_match()->provider); + EXPECT_EQ(allow_exact_keyword_match ? + AutocompleteProvider::TYPE_KEYWORD : AutocompleteProvider::TYPE_SEARCH, + controller_->result().default_match()->provider->type()); } void AutocompleteProviderTest::Observe( @@ -438,19 +418,21 @@ void AutocompleteProviderTest::Observe( // Tests that the default selection is set properly when updating results. TEST_F(AutocompleteProviderTest, Query) { - ResetControllerWithTestProviders(false); + TestProvider* provider1 = NULL; + TestProvider* provider2 = NULL; + ResetControllerWithTestProviders(false, &provider1, &provider2); RunTest(); // Make sure the default match gets set to the highest relevance match. The // highest relevance matches should come from the second provider. EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers ASSERT_NE(result_.end(), result_.default_match()); - EXPECT_EQ(providers_[1], result_.default_match()->provider); + EXPECT_EQ(provider2, result_.default_match()->provider); } // Tests assisted query stats. TEST_F(AutocompleteProviderTest, AssistedQueryStats) { - ResetControllerWithTestProviders(false); + ResetControllerWithTestProviders(false, NULL, NULL); RunTest(); EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers @@ -469,7 +451,9 @@ TEST_F(AutocompleteProviderTest, AssistedQueryStats) { } TEST_F(AutocompleteProviderTest, RemoveDuplicates) { - ResetControllerWithTestProviders(true); + TestProvider* provider1 = NULL; + TestProvider* provider2 = NULL; + ResetControllerWithTestProviders(true, &provider1, &provider2); RunTest(); // Make sure all the first provider's results were eliminated by the second @@ -477,11 +461,11 @@ TEST_F(AutocompleteProviderTest, RemoveDuplicates) { EXPECT_EQ(kResultsPerProvider, result_.size()); for (AutocompleteResult::const_iterator i(result_.begin()); i != result_.end(); ++i) - EXPECT_EQ(providers_[1], i->provider); + EXPECT_EQ(provider2, i->provider); } TEST_F(AutocompleteProviderTest, AllowExactKeywordMatch) { - ResetControllerWithTestProvidersWithKeywordAndSearchProviders(); + ResetControllerWithKeywordAndSearchProviders(); RunExactKeymatchTest(true); RunExactKeymatchTest(false); } @@ -529,7 +513,7 @@ TEST_F(AutocompleteProviderTest, RedundantKeywordsIgnoredInResult) { } TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) { - ResetControllerWithTestProviders(false); + ResetControllerWithTestProviders(false, NULL, NULL); { AssistedQueryStatsTestData test_data[] = { @@ -564,4 +548,3 @@ TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) { RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); } } - diff --git a/chrome/browser/autocomplete/builtin_provider.cc b/chrome/browser/autocomplete/builtin_provider.cc index b43e1eb..db7c49e 100644 --- a/chrome/browser/autocomplete/builtin_provider.cc +++ b/chrome/browser/autocomplete/builtin_provider.cc @@ -36,7 +36,8 @@ const int BuiltinProvider::kRelevance = 575; BuiltinProvider::BuiltinProvider(AutocompleteProviderListener* listener, Profile* profile) - : AutocompleteProvider(listener, profile, "Builtin") { + : AutocompleteProvider(listener, profile, + AutocompleteProvider::TYPE_BUILTIN) { std::vector<std::string> builtins(ChromePaths()); for (std::vector<std::string>::iterator i(builtins.begin()); i != builtins.end(); ++i) diff --git a/chrome/browser/autocomplete/extension_app_provider.cc b/chrome/browser/autocomplete/extension_app_provider.cc index ba2dd2c..33ffde9 100644 --- a/chrome/browser/autocomplete/extension_app_provider.cc +++ b/chrome/browser/autocomplete/extension_app_provider.cc @@ -25,7 +25,8 @@ ExtensionAppProvider::ExtensionAppProvider( AutocompleteProviderListener* listener, Profile* profile) - : AutocompleteProvider(listener, profile, "ExtensionApps") { + : AutocompleteProvider(listener, profile, + AutocompleteProvider::TYPE_EXTENSION_APP) { // Notifications of extensions loading and unloading always come from the // non-incognito profile, but we need to see them regardless, as the incognito // windows can be affected. @@ -77,8 +78,7 @@ AutocompleteMatch ExtensionAppProvider::CreateAutocompleteMatch( size_t url_match_index) { // TODO(finnur): Figure out what type to return here, might want to have // the extension icon/a generic icon show up in the Omnibox. - AutocompleteMatch match(this, 0, false, - AutocompleteMatch::EXTENSION_APP); + AutocompleteMatch match(this, 0, false, AutocompleteMatch::EXTENSION_APP); match.fill_into_edit = app.should_match_against_launch_url ? app.launch_url : input.text(); match.destination_url = GURL(app.launch_url); diff --git a/chrome/browser/autocomplete/history_contents_provider.cc b/chrome/browser/autocomplete/history_contents_provider.cc index 49fdbf4..1c15921 100644 --- a/chrome/browser/autocomplete/history_contents_provider.cc +++ b/chrome/browser/autocomplete/history_contents_provider.cc @@ -51,7 +51,8 @@ HistoryContentsProvider::HistoryContentsProvider( AutocompleteProviderListener* listener, Profile* profile, bool body_only) - : HistoryProvider(listener, profile, "HistoryContents"), + : HistoryProvider(listener, profile, + AutocompleteProvider::TYPE_HISTORY_CONTENTS), star_title_count_(0), star_contents_count_(0), title_count_(0), diff --git a/chrome/browser/autocomplete/history_provider.cc b/chrome/browser/autocomplete/history_provider.cc index ed8437f..85bcb13 100644 --- a/chrome/browser/autocomplete/history_provider.cc +++ b/chrome/browser/autocomplete/history_provider.cc @@ -19,8 +19,8 @@ HistoryProvider::HistoryProvider(AutocompleteProviderListener* listener, Profile* profile, - const char* name) - : AutocompleteProvider(listener, profile, name), + AutocompleteProvider::Type type) + : AutocompleteProvider(listener, profile, type), always_prevent_inline_autocomplete_(false) { } diff --git a/chrome/browser/autocomplete/history_provider.h b/chrome/browser/autocomplete/history_provider.h index 96de5b6..8b4f573 100644 --- a/chrome/browser/autocomplete/history_provider.h +++ b/chrome/browser/autocomplete/history_provider.h @@ -20,7 +20,7 @@ class HistoryProvider : public AutocompleteProvider { protected: HistoryProvider(AutocompleteProviderListener* listener, Profile* profile, - const char* name); + AutocompleteProvider::Type type); virtual ~HistoryProvider(); // Fixes up user URL input to make it more possible to match against. Among diff --git a/chrome/browser/autocomplete/history_quick_provider.cc b/chrome/browser/autocomplete/history_quick_provider.cc index 3bb2c32..130eaf5 100644 --- a/chrome/browser/autocomplete/history_quick_provider.cc +++ b/chrome/browser/autocomplete/history_quick_provider.cc @@ -46,7 +46,8 @@ bool HistoryQuickProvider::disabled_ = false; HistoryQuickProvider::HistoryQuickProvider( AutocompleteProviderListener* listener, Profile* profile) - : HistoryProvider(listener, profile, "HistoryQuick"), + : HistoryProvider(listener, profile, + AutocompleteProvider::TYPE_HISTORY_QUICK), languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), reorder_for_inlining_(false) { enum InliningOption { diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc index a028a4c..18f57a0 100644 --- a/chrome/browser/autocomplete/history_url_provider.cc +++ b/chrome/browser/autocomplete/history_url_provider.cc @@ -229,7 +229,8 @@ HistoryURLProviderParams::~HistoryURLProviderParams() { HistoryURLProvider::HistoryURLProvider(AutocompleteProviderListener* listener, Profile* profile) - : HistoryProvider(listener, profile, "HistoryURL"), + : HistoryProvider(listener, profile, + AutocompleteProvider::TYPE_HISTORY_URL), params_(NULL) { } diff --git a/chrome/browser/autocomplete/history_url_provider.h b/chrome/browser/autocomplete/history_url_provider.h index 7f46684..ef040d8 100644 --- a/chrome/browser/autocomplete/history_url_provider.h +++ b/chrome/browser/autocomplete/history_url_provider.h @@ -142,7 +142,8 @@ class HistoryURLProvider : public HistoryProvider { HistoryURLProvider(AutocompleteProviderListener* listener, Profile* profile, const std::string& languages) - : HistoryProvider(listener, profile, "History"), + : HistoryProvider(listener, profile, + AutocompleteProvider::TYPE_HISTORY_URL), params_(NULL), languages_(languages) {} #endif diff --git a/chrome/browser/autocomplete/keyword_provider.cc b/chrome/browser/autocomplete/keyword_provider.cc index 76df0c1..1088494 100644 --- a/chrome/browser/autocomplete/keyword_provider.cc +++ b/chrome/browser/autocomplete/keyword_provider.cc @@ -45,7 +45,8 @@ class KeywordProvider::ScopedEndExtensionKeywordMode { KeywordProvider::KeywordProvider(AutocompleteProviderListener* listener, Profile* profile) - : AutocompleteProvider(listener, profile, "Keyword"), + : AutocompleteProvider(listener, profile, + AutocompleteProvider::TYPE_KEYWORD), model_(NULL), current_input_id_(0) { // Extension suggestions always come from the original profile, since that's @@ -63,7 +64,7 @@ KeywordProvider::KeywordProvider(AutocompleteProviderListener* listener, KeywordProvider::KeywordProvider(AutocompleteProviderListener* listener, TemplateURLService* model) - : AutocompleteProvider(listener, NULL, "Keyword"), + : AutocompleteProvider(listener, NULL, AutocompleteProvider::TYPE_KEYWORD), model_(model), current_input_id_(0) { } diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc index c62c68a..068fcd7 100644 --- a/chrome/browser/autocomplete/search_provider.cc +++ b/chrome/browser/autocomplete/search_provider.cc @@ -121,7 +121,8 @@ bool SearchProvider::query_suggest_immediately_ = false; SearchProvider::SearchProvider(AutocompleteProviderListener* listener, Profile* profile) - : AutocompleteProvider(listener, profile, "Search"), + : AutocompleteProvider(listener, profile, + AutocompleteProvider::TYPE_SEARCH), providers_(TemplateURLServiceFactory::GetForProfile(profile)), suggest_results_pending_(0), suggest_field_trial_group_number_( diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc index e072b7a..ffe1fd5 100644 --- a/chrome/browser/autocomplete/search_provider_unittest.cc +++ b/chrome/browser/autocomplete/search_provider_unittest.cc @@ -669,9 +669,12 @@ TEST_F(SearchProviderTest, UpdateKeywordDescriptions) { ACProviders providers; SearchProvider* provider = provider_.release(); providers.push_back(provider); - AutocompleteController controller(providers, &profile_); - controller.set_search_provider(provider); + + AutocompleteController controller(&profile_, NULL, 0); + controller.providers_.swap(providers); + controller.search_provider_ = provider; provider->set_listener(&controller); + controller.Start(ASCIIToUTF16("k t"), string16(), false, false, true, AutocompleteInput::ALL_MATCHES); const AutocompleteResult& result = controller.result(); diff --git a/chrome/browser/autocomplete/shortcuts_provider.cc b/chrome/browser/autocomplete/shortcuts_provider.cc index 0b52176..5f4ce1e 100644 --- a/chrome/browser/autocomplete/shortcuts_provider.cc +++ b/chrome/browser/autocomplete/shortcuts_provider.cc @@ -50,7 +50,8 @@ class RemoveMatchPredicate { ShortcutsProvider::ShortcutsProvider(AutocompleteProviderListener* listener, Profile* profile) - : AutocompleteProvider(listener, profile, "Shortcuts"), + : AutocompleteProvider(listener, profile, + AutocompleteProvider::TYPE_SHORTCUTS), languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), initialized_(false) { scoped_refptr<history::ShortcutsBackend> backend = diff --git a/chrome/browser/autocomplete/zero_suggest_provider.cc b/chrome/browser/autocomplete/zero_suggest_provider.cc index 2c91986..2357b52 100644 --- a/chrome/browser/autocomplete/zero_suggest_provider.cc +++ b/chrome/browser/autocomplete/zero_suggest_provider.cc @@ -32,7 +32,8 @@ ZeroSuggestProvider::ZeroSuggestProvider( AutocompleteProviderListener* listener, Profile* profile, const std::string& url_prefix) - : AutocompleteProvider(listener, profile, "ZeroSuggest"), + : AutocompleteProvider(listener, profile, + AutocompleteProvider::TYPE_ZERO_SUGGEST), url_prefix_(url_prefix), template_url_service_(TemplateURLServiceFactory::GetForProfile(profile)) { } diff --git a/chrome/browser/extensions/api/omnibox/omnibox_apitest.cc b/chrome/browser/extensions/api/omnibox/omnibox_apitest.cc index 4b4e1db..1ba2f4b 100644 --- a/chrome/browser/extensions/api/omnibox/omnibox_apitest.cc +++ b/chrome/browser/extensions/api/omnibox/omnibox_apitest.cc @@ -35,7 +35,7 @@ string16 AutocompleteResultAsString(const AutocompleteResult& result) { std::string output(base::StringPrintf("{%" PRIuS "} ", result.size())); for (size_t i = 0; i < result.size(); ++i) { AutocompleteMatch match = result.match_at(i); - std::string provider_name = match.provider->name(); + std::string provider_name = match.provider->GetName(); output.append(base::StringPrintf("[\"%s\" by \"%s\"] ", UTF16ToUTF8(match.contents).c_str(), provider_name.c_str())); diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc index 1eeaa4d..69d2e7d 100644 --- a/chrome/browser/instant/instant_controller.cc +++ b/chrome/browser/instant/instant_controller.cc @@ -276,7 +276,7 @@ void InstantController::HandleAutocompleteResults( for (ACMatches::const_iterator match = (*provider)->matches().begin(); match != (*provider)->matches().end(); ++match) { InstantAutocompleteResult result; - result.provider = UTF8ToUTF16((*provider)->name()); + result.provider = UTF8ToUTF16((*provider)->GetName()); result.is_search = AutocompleteMatch::IsSearchType(match->type); result.contents = match->description; result.destination_url = match->destination_url; diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc index 3975d17..e02e235 100644 --- a/chrome/browser/metrics/metrics_log.cc +++ b/chrome/browser/metrics/metrics_log.cc @@ -933,7 +933,7 @@ void MetricsLog::RecordOmniboxOpenedURL(const AutocompleteLog& log) { i != log.result.end(); ++i) { OPEN_ELEMENT_FOR_SCOPE("autocompleteitem"); if (i->provider) - WriteAttribute("provider", i->provider->name()); + WriteAttribute("provider", i->provider->GetName()); const std::string result_type(AutocompleteMatch::TypeToString(i->type)); if (!result_type.empty()) WriteAttribute("resulttype", result_type); diff --git a/chrome/browser/ui/app_list/search_builder.cc b/chrome/browser/ui/app_list/search_builder.cc index 399cc64..69156ec 100644 --- a/chrome/browser/ui/app_list/search_builder.cc +++ b/chrome/browser/ui/app_list/search_builder.cc @@ -7,11 +7,12 @@ #include <string> #include "base/command_line.h" +#include "chrome/browser/autocomplete/autocomplete_classifier.h" #include "chrome/browser/autocomplete/autocomplete_controller.h" #include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/autocomplete/autocomplete_match.h" +#include "chrome/browser/autocomplete/autocomplete_provider.h" #include "chrome/browser/autocomplete/autocomplete_result.h" -#include "chrome/browser/autocomplete/extension_app_provider.h" #include "chrome/browser/event_disposition.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/image_loading_tracker.h" @@ -188,47 +189,29 @@ SearchBuilder::SearchBuilder( search_box_->SetIcon(*ui::ResourceBundle::GetSharedInstance(). GetImageSkiaNamed(IDR_OMNIBOX_SEARCH)); - if (CommandLine::ForCurrentProcess()->HasSwitch( - app_list::switches::kAppListShowAppsOnly)) { - // ExtensionAppProvider is a synchronous provider and does not really need a - // listener. - apps_provider_ = new ExtensionAppProvider(NULL, profile); - } else { - controller_.reset(new AutocompleteController(profile, this)); - } + // TODO(xiyuan): Consider requesting fewer providers in the non-apps-only + // case. + int providers = + CommandLine::ForCurrentProcess()->HasSwitch( + app_list::switches::kAppListShowAppsOnly) ? + AutocompleteProvider::TYPE_EXTENSION_APP : + AutocompleteClassifier::kDefaultOmniboxProviders; + controller_.reset(new AutocompleteController(profile, this, providers)); } SearchBuilder::~SearchBuilder() { } void SearchBuilder::StartSearch() { - const string16& user_text = search_box_->text(); - - if (controller_.get()) { - // Omnibox features such as keyword selection/accepting and instant query - // are not implemented. - // TODO(xiyuan): Figure out the features that need to support here. - controller_->Start(user_text, string16(), false, false, true, - AutocompleteInput::ALL_MATCHES); - } else { - AutocompleteInput input(user_text, string16(), false, false, true, - AutocompleteInput::ALL_MATCHES); - apps_provider_->Start(input, false); - - // ExtensionAppProvider is a synchronous provider and results are ready - // after returning from Start. - AutocompleteResult ac_result; - ac_result.AppendMatches(apps_provider_->matches()); - ac_result.SortAndCull(input); - PopulateFromACResult(ac_result); - } + // Omnibox features such as keyword selection/accepting and instant query + // are not implemented. + // TODO(xiyuan): Figure out the features that need to support here. + controller_->Start(search_box_->text(), string16(), false, false, true, + AutocompleteInput::ALL_MATCHES); } void SearchBuilder::StopSearch() { - if (controller_.get()) - controller_->Stop(true); - else - apps_provider_->Stop(true); + controller_->Stop(true); } void SearchBuilder::OpenResult(const app_list::SearchResult& result, diff --git a/chrome/browser/ui/app_list/search_builder.h b/chrome/browser/ui/app_list/search_builder.h index f5f2d26..314cc28 100644 --- a/chrome/browser/ui/app_list/search_builder.h +++ b/chrome/browser/ui/app_list/search_builder.h @@ -19,7 +19,6 @@ class SearchResult; class AppListController; class AutocompleteController; class AutocompleteResult; -class ExtensionAppProvider; class Profile; // SearchBuilder creates app list search results via AutoCompleteController. @@ -63,10 +62,6 @@ class SearchBuilder : public AutocompleteControllerDelegate { // The controller of the app list. Owned by the app list delegate. AppListController* list_controller_; - // ExtensionAppProvider used for apps only mode. If apps only mode becomes the - // only mode, remove the AutocompleteController above. Otherwise, remove this. - scoped_refptr<ExtensionAppProvider> apps_provider_; - DISALLOW_COPY_AND_ASSIGN(SearchBuilder); }; diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc index 7eb7f86..4113dca 100644 --- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc +++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc @@ -16,6 +16,7 @@ #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" #include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/autocomplete/autocomplete_log.h" +#include "chrome/browser/autocomplete/autocomplete_provider.h" #include "chrome/browser/autocomplete/extension_app_provider.h" #include "chrome/browser/autocomplete/keyword_provider.h" #include "chrome/browser/autocomplete/search_provider.h" @@ -84,7 +85,8 @@ OmniboxEditModel::OmniboxEditModel(OmniboxView* view, OmniboxEditController* controller, Profile* profile) : ALLOW_THIS_IN_INITIALIZER_LIST( - autocomplete_controller_(new AutocompleteController(profile, this))), + autocomplete_controller_(new AutocompleteController(profile, this, + AutocompleteClassifier::kDefaultOmniboxProviders))), view_(view), popup_(NULL), controller_(controller), @@ -526,10 +528,11 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match, base::TimeTicks::Now() - time_user_first_modified_omnibox_, 0, // inline autocomplete length; possibly set later result()); - DCHECK(user_input_in_progress_ || match.provider->name() == "ZeroSuggest") + DCHECK(user_input_in_progress_ || + match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST) << "We didn't get here through the expected series of calls. " << "time_user_first_modified_omnibox_ is not set correctly and other " - << "things may be wrong. Match provider: " << match.provider->name(); + << "things may be wrong. Match provider: " << match.provider->GetName(); if (index != OmniboxPopupModel::kNoMatch) log.selected_index = index; else if (!has_temporary_text_) diff --git a/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.cc b/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.cc index 651e98d..ec4a3af 100644 --- a/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.cc +++ b/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.cc @@ -11,6 +11,7 @@ #include "base/stringprintf.h" #include "base/time.h" #include "base/values.h" +#include "chrome/browser/autocomplete/autocomplete_classifier.h" #include "chrome/browser/autocomplete/autocomplete_controller.h" #include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/autocomplete/autocomplete_match.h" @@ -19,7 +20,8 @@ #include "content/public/browser/web_ui.h" OmniboxUIHandler::OmniboxUIHandler(Profile* profile ) { - controller_.reset(new AutocompleteController(profile, this)); + controller_.reset(new AutocompleteController(profile, this, + AutocompleteClassifier::kDefaultOmniboxProviders)); } OmniboxUIHandler::~OmniboxUIHandler() {} @@ -77,7 +79,8 @@ void OmniboxUIHandler::OnResultChanged(bool default_match_changed) { // Fill results from each individual provider as well. for (ACProviders::const_iterator it(controller_->providers()->begin()); it != controller_->providers()->end(); ++it) { - AddResultToDictionary(std::string("results_by_provider.") + (*it)->name(), + AddResultToDictionary( + std::string("results_by_provider.") + (*it)->GetName(), (*it)->matches().begin(), (*it)->matches().end(), &result_to_output); } // Add done; send the results. @@ -95,7 +98,8 @@ void OmniboxUIHandler::AddResultToDictionary(const std::string& prefix, for (; it != end; ++it, ++i) { std::string item_prefix(prefix + StringPrintf(".item_%d", i)); if (it->provider != NULL) { - output->SetString(item_prefix + ".provider_name", it->provider->name()); + output->SetString(item_prefix + ".provider_name", + it->provider->GetName()); output->SetBoolean(item_prefix + ".provider_done", it->provider->done()); } output->SetInteger(item_prefix + ".relevance", it->relevance); diff --git a/chrome/browser/ui/webui/options/home_page_overlay_handler.cc b/chrome/browser/ui/webui/options/home_page_overlay_handler.cc index 5c9c736..a0d36c2 100644 --- a/chrome/browser/ui/webui/options/home_page_overlay_handler.cc +++ b/chrome/browser/ui/webui/options/home_page_overlay_handler.cc @@ -7,6 +7,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/values.h" +#include "chrome/browser/autocomplete/autocomplete_classifier.h" #include "chrome/browser/autocomplete/autocomplete_controller.h" #include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/autocomplete/autocomplete_result.h" @@ -32,7 +33,8 @@ void HomePageOverlayHandler::RegisterMessages() { void HomePageOverlayHandler::InitializeHandler() { Profile* profile = Profile::FromWebUI(web_ui()); - autocomplete_controller_.reset(new AutocompleteController(profile, this)); + autocomplete_controller_.reset(new AutocompleteController(profile, this, + AutocompleteClassifier::kDefaultOmniboxProviders)); } void HomePageOverlayHandler::GetLocalizedValues( diff --git a/chrome/browser/ui/webui/options/startup_pages_handler.cc b/chrome/browser/ui/webui/options/startup_pages_handler.cc index 29892b0..7699e58 100644 --- a/chrome/browser/ui/webui/options/startup_pages_handler.cc +++ b/chrome/browser/ui/webui/options/startup_pages_handler.cc @@ -7,6 +7,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/string_number_conversions.h" +#include "chrome/browser/autocomplete/autocomplete_classifier.h" #include "chrome/browser/autocomplete/autocomplete_controller.h" #include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/autocomplete/autocomplete_result.h" @@ -91,7 +92,8 @@ void StartupPagesHandler::InitializeHandler() { pref_change_registrar_.Init(profile->GetPrefs()); pref_change_registrar_.Add(prefs::kURLsToRestoreOnStartup, this); - autocomplete_controller_.reset(new AutocompleteController(profile, this)); + autocomplete_controller_.reset(new AutocompleteController(profile, this, + AutocompleteClassifier::kDefaultOmniboxProviders)); } void StartupPagesHandler::InitializePage() { |