| 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/chromeos/extensions/file_manager/private_api_misc.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_misc.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } | 222 } |
| 223 | 223 |
| 224 FileBrowserPrivateRequestWebStoreAccessTokenFunction:: | 224 FileBrowserPrivateRequestWebStoreAccessTokenFunction:: |
| 225 ~FileBrowserPrivateRequestWebStoreAccessTokenFunction() { | 225 ~FileBrowserPrivateRequestWebStoreAccessTokenFunction() { |
| 226 } | 226 } |
| 227 | 227 |
| 228 bool FileBrowserPrivateRequestWebStoreAccessTokenFunction::RunImpl() { | 228 bool FileBrowserPrivateRequestWebStoreAccessTokenFunction::RunImpl() { |
| 229 std::vector<std::string> scopes; | 229 std::vector<std::string> scopes; |
| 230 scopes.push_back(kCWSScope); | 230 scopes.push_back(kCWSScope); |
| 231 | 231 |
| 232 OAuth2TokenService* oauth_service = | 232 ProfileOAuth2TokenService* oauth_service = |
| 233 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); | 233 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); |
| 234 net::URLRequestContextGetter* url_request_context_getter = | 234 net::URLRequestContextGetter* url_request_context_getter = |
| 235 g_browser_process->system_request_context(); | 235 g_browser_process->system_request_context(); |
| 236 | 236 |
| 237 if (!oauth_service) { | 237 if (!oauth_service) { |
| 238 drive::util::Log(logging::LOG_ERROR, | 238 drive::util::Log(logging::LOG_ERROR, |
| 239 "CWS OAuth token fetch failed. OAuth2TokenService can't " | 239 "CWS OAuth token fetch failed. OAuth2TokenService can't " |
| 240 "be retrived."); | 240 "be retrived."); |
| 241 SetResult(base::Value::CreateNullValue()); | 241 SetResult(base::Value::CreateNullValue()); |
| 242 return false; | 242 return false; |
| 243 } | 243 } |
| 244 | 244 |
| 245 auth_service_.reset(new google_apis::AuthService( | 245 auth_service_.reset(new google_apis::AuthService( |
| 246 oauth_service, | 246 oauth_service, |
| 247 oauth_service->GetPrimaryAccountId(), |
| 247 url_request_context_getter, | 248 url_request_context_getter, |
| 248 scopes)); | 249 scopes)); |
| 249 auth_service_->StartAuthentication(base::Bind( | 250 auth_service_->StartAuthentication(base::Bind( |
| 250 &FileBrowserPrivateRequestWebStoreAccessTokenFunction:: | 251 &FileBrowserPrivateRequestWebStoreAccessTokenFunction:: |
| 251 OnAccessTokenFetched, | 252 OnAccessTokenFetched, |
| 252 this)); | 253 this)); |
| 253 | 254 |
| 254 return true; | 255 return true; |
| 255 } | 256 } |
| 256 | 257 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 268 } else { | 269 } else { |
| 269 drive::util::Log(logging::LOG_ERROR, | 270 drive::util::Log(logging::LOG_ERROR, |
| 270 "CWS OAuth token fetch failed. (GDataErrorCode: %s)", | 271 "CWS OAuth token fetch failed. (GDataErrorCode: %s)", |
| 271 google_apis::GDataErrorCodeToString(code).c_str()); | 272 google_apis::GDataErrorCodeToString(code).c_str()); |
| 272 SetResult(base::Value::CreateNullValue()); | 273 SetResult(base::Value::CreateNullValue()); |
| 273 SendResponse(false); | 274 SendResponse(false); |
| 274 } | 275 } |
| 275 } | 276 } |
| 276 | 277 |
| 277 } // namespace extensions | 278 } // namespace extensions |
| OLD | NEW |