Add search suggestions fetched from the server

Fix athena::AppListViewDelegate to show multiple results.
Use SearchSuggestionParser in UrlSearchProvider

BUG=399561

Review URL: https://codereview.chromium.org/438023002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287504 0039d316-1c4b-4281-b951-d872f2087c98
parent e99871ce
...@@ -51,9 +51,12 @@ void AppListViewDelegate::SearchResultChanged() { ...@@ -51,9 +51,12 @@ void AppListViewDelegate::SearchResultChanged() {
app_list::SearchProvider* search_provider = search_providers_[0]; app_list::SearchProvider* search_provider = search_providers_[0];
std::vector<app_list::SearchResult*> results; std::vector<app_list::SearchResult*> results;
search_provider->ReleaseResult(&results); search_provider->ReleaseResult(&results);
model_->results()->DeleteAll(); if (results.empty()) {
for (size_t i = 0; i < results.size(); ++i) model_->results()->DeleteAll();
model_->results()->Add(results[i]); } else {
for (size_t i = 0; i < results.size(); ++i)
model_->results()->Add(results[i]);
}
} }
bool AppListViewDelegate::ForceNativeDesktop() const { bool AppListViewDelegate::ForceNativeDesktop() const {
......
This diff is collapsed.
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#define ATHENA_MAIN_URL_SEARCH_PROVIDER_H_ #define ATHENA_MAIN_URL_SEARCH_PROVIDER_H_
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "components/autocomplete/autocomplete_input.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "ui/app_list/search_provider.h" #include "ui/app_list/search_provider.h"
class TemplateURLService; class TemplateURLService;
...@@ -17,7 +19,8 @@ class BrowserContext; ...@@ -17,7 +19,8 @@ class BrowserContext;
namespace athena { namespace athena {
// A sample search provider. // A sample search provider.
class UrlSearchProvider : public app_list::SearchProvider { class UrlSearchProvider : public app_list::SearchProvider,
public net::URLFetcherDelegate {
public: public:
UrlSearchProvider(content::BrowserContext* browser_context); UrlSearchProvider(content::BrowserContext* browser_context);
virtual ~UrlSearchProvider(); virtual ~UrlSearchProvider();
...@@ -26,12 +29,21 @@ class UrlSearchProvider : public app_list::SearchProvider { ...@@ -26,12 +29,21 @@ class UrlSearchProvider : public app_list::SearchProvider {
virtual void Start(const base::string16& query) OVERRIDE; virtual void Start(const base::string16& query) OVERRIDE;
virtual void Stop() OVERRIDE; virtual void Stop() OVERRIDE;
// Overridden from net::URLFetcherDelegate.
virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
private: private:
void StartFetchingSuggestions();
content::BrowserContext* browser_context_; content::BrowserContext* browser_context_;
// TODO(mukai): This should be provided through BrowserContextKeyedService. // TODO(mukai): This should be provided through BrowserContextKeyedService.
scoped_ptr<TemplateURLService> template_url_service_; scoped_ptr<TemplateURLService> template_url_service_;
AutocompleteInput input_;
scoped_ptr<net::URLFetcher> suggestion_fetcher_;
bool should_fetch_suggestions_again_;
DISALLOW_COPY_AND_ASSIGN(UrlSearchProvider); DISALLOW_COPY_AND_ASSIGN(UrlSearchProvider);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment