#ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_PEOPLE_PEOPLE_PROVIDER_H_
#define CHROME_BROWSER_UI_APP_LIST_SEARCH_PEOPLE_PEOPLE_PROVIDER_H_
#include "base/basictypes.h"
#include "base/callback_forward.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/app_list/search/common/webservice_search_provider.h"
#include "google_apis/gaia/oauth2_token_service.h"
#include "url/gurl.h"
class AppListControllerDelegate;
namespace base {
class DictionaryValue;
}
namespace app_list {
namespace test {
class PeopleProviderTest;
}
class ChromeSearchResult;
class JSONResponseFetcher;
class PeopleProvider : public WebserviceSearchProvider,
public OAuth2TokenService::Consumer {
public:
explicit PeopleProvider(Profile* profile);
virtual ~PeopleProvider();
virtual void Start(const base::string16& query) OVERRIDE;
virtual void Stop() OVERRIDE;
virtual void OnGetTokenSuccess(
const OAuth2TokenService::Request* request,
const std::string& access_token,
const base::Time& expiration_time) OVERRIDE;
virtual void OnGetTokenFailure(
const OAuth2TokenService::Request* request,
const GoogleServiceAuthError& error) OVERRIDE;
private:
friend class app_list::test::PeopleProviderTest;
void RequestAccessToken();
void InvalidateToken();
GURL GetQueryUrl(const std::string& query);
void StartQuery();
void OnPeopleSearchFetched(scoped_ptr<base::DictionaryValue> json);
void ProcessPeopleSearchResults(const base::DictionaryValue* json);
scoped_ptr<ChromeSearchResult> CreateResult(
const base::DictionaryValue& dict);
void SetupForTest(const base::Closure& people_search_fetched_callback,
const GURL& people_search_url);
scoped_ptr<JSONResponseFetcher> people_search_;
base::Closure people_search_fetched_callback_;
std::string access_token_;
scoped_ptr<OAuth2TokenService::Request> access_token_request_;
OAuth2TokenService::ScopeSet oauth2_scope_;
std::string query_;
GURL people_search_url_;
bool skip_request_token_for_test_;
DISALLOW_COPY_AND_ASSIGN(PeopleProvider);
};
}
#endif