| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 const GoogleServiceAuthError& error) { | 111 const GoogleServiceAuthError& error) { |
| 112 DCHECK_EQ(access_token_request_, request); | 112 DCHECK_EQ(access_token_request_, request); |
| 113 access_token_request_.reset(); | 113 access_token_request_.reset(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void PeopleProvider::RequestAccessToken() { | 116 void PeopleProvider::RequestAccessToken() { |
| 117 // Only one active request at a time. | 117 // Only one active request at a time. |
| 118 if (access_token_request_ != NULL) | 118 if (access_token_request_ != NULL) |
| 119 return; | 119 return; |
| 120 | 120 |
| 121 ProfileOAuth2TokenService* token_service = | |
| 122 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | |
| 123 SigninManagerBase* signin_manager = | 121 SigninManagerBase* signin_manager = |
| 124 SigninManagerFactory::GetInstance()->GetForProfile(profile_); | 122 SigninManagerFactory::GetInstance()->GetForProfile(profile_); |
| 125 access_token_request_ = token_service->StartRequest( | 123 if (signin_manager->IsAuthenticated()) { |
| 126 signin_manager->GetAuthenticatedAccountId(), oauth2_scope_, this); | 124 ProfileOAuth2TokenService* token_service = |
| 125 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
| 126 access_token_request_ = token_service->StartRequest( |
| 127 signin_manager->GetAuthenticatedAccountId(), oauth2_scope_, this); |
| 128 } |
| 127 } | 129 } |
| 128 | 130 |
| 129 GURL PeopleProvider::GetQueryUrl(const std::string& query) { | 131 GURL PeopleProvider::GetQueryUrl(const std::string& query) { |
| 130 GURL people_search_url = people_search_url_; | 132 GURL people_search_url = people_search_url_; |
| 131 people_search_url = net::AppendQueryParameter(people_search_url, | 133 people_search_url = net::AppendQueryParameter(people_search_url, |
| 132 kAccessTokenField, | 134 kAccessTokenField, |
| 133 access_token_); | 135 access_token_); |
| 134 people_search_url = net::AppendQueryParameter(people_search_url, | 136 people_search_url = net::AppendQueryParameter(people_search_url, |
| 135 kQueryField, | 137 kQueryField, |
| 136 query); | 138 query); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |