| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/app_list/search/people/people_provider.h" | 5 #include "chrome/browser/ui/app_list/search/people/people_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 const char kQueryField[] = "query"; | 35 const char kQueryField[] = "query"; |
| 36 const char kPeopleSearchUrl[] = | 36 const char kPeopleSearchUrl[] = |
| 37 "https://www.googleapis.com/plus/v2whitelisted/people/autocomplete"; | 37 "https://www.googleapis.com/plus/v2whitelisted/people/autocomplete"; |
| 38 | 38 |
| 39 // OAuth2 scope for access to the Google+ People Search API. | 39 // OAuth2 scope for access to the Google+ People Search API. |
| 40 const char kPeopleSearchOAuth2Scope[] = | 40 const char kPeopleSearchOAuth2Scope[] = |
| 41 "https://www.googleapis.com/auth/plus.peopleapi.readwrite"; | 41 "https://www.googleapis.com/auth/plus.peopleapi.readwrite"; |
| 42 | 42 |
| 43 } // namespace | 43 } // namespace |
| 44 | 44 |
| 45 PeopleProvider::PeopleProvider(Profile* profile) | 45 PeopleProvider::PeopleProvider(Profile* profile, |
| 46 : WebserviceSearchProvider(profile), | 46 AppListControllerDelegate* controller) |
| 47 OAuth2TokenService::Consumer("people_provider"), | 47 : WebserviceSearchProvider(profile), |
| 48 people_search_url_(kPeopleSearchUrl), | 48 OAuth2TokenService::Consumer("people_provider"), |
| 49 skip_request_token_for_test_(false) { | 49 controller_(controller), |
| 50 people_search_url_(kPeopleSearchUrl), |
| 51 skip_request_token_for_test_(false) { |
| 50 oauth2_scope_.insert(kPeopleSearchOAuth2Scope); | 52 oauth2_scope_.insert(kPeopleSearchOAuth2Scope); |
| 51 } | 53 } |
| 52 | 54 |
| 53 PeopleProvider::~PeopleProvider() {} | 55 PeopleProvider::~PeopleProvider() {} |
| 54 | 56 |
| 55 void PeopleProvider::Start(const base::string16& query) { | 57 void PeopleProvider::Start(const base::string16& query) { |
| 56 ClearResults(); | 58 ClearResults(); |
| 57 if (!IsValidQuery(query)) { | 59 if (!IsValidQuery(query)) { |
| 58 query_.clear(); | 60 query_.clear(); |
| 59 return; | 61 return; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 185 } |
| 184 | 186 |
| 185 scoped_ptr<SearchResult> PeopleProvider::CreateResult( | 187 scoped_ptr<SearchResult> PeopleProvider::CreateResult( |
| 186 const base::DictionaryValue& dict) { | 188 const base::DictionaryValue& dict) { |
| 187 scoped_ptr<SearchResult> result; | 189 scoped_ptr<SearchResult> result; |
| 188 | 190 |
| 189 scoped_ptr<Person> person = Person::Create(dict); | 191 scoped_ptr<Person> person = Person::Create(dict); |
| 190 if (!person) | 192 if (!person) |
| 191 return result.Pass(); | 193 return result.Pass(); |
| 192 | 194 |
| 193 result.reset(new PeopleResult(profile_, person.Pass())); | 195 result.reset(new PeopleResult(profile_, controller_, person.Pass())); |
| 194 return result.Pass(); | 196 return result.Pass(); |
| 195 } | 197 } |
| 196 | 198 |
| 197 void PeopleProvider::SetupForTest( | 199 void PeopleProvider::SetupForTest( |
| 198 const base::Closure& people_search_fetched_callback, | 200 const base::Closure& people_search_fetched_callback, |
| 199 const GURL& people_search_url) { | 201 const GURL& people_search_url) { |
| 200 people_search_fetched_callback_ = people_search_fetched_callback; | 202 people_search_fetched_callback_ = people_search_fetched_callback; |
| 201 people_search_url_ = people_search_url; | 203 people_search_url_ = people_search_url; |
| 202 skip_request_token_for_test_ = true; | 204 skip_request_token_for_test_ = true; |
| 203 } | 205 } |
| 204 | 206 |
| 205 } // namespace app_list | 207 } // namespace app_list |
| OLD | NEW |