| 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_drive.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_drive.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 9 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| 10 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" | 10 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 } | 996 } |
| 997 | 997 |
| 998 download_url_ = | 998 download_url_ = |
| 999 google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction + | 999 google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction + |
| 1000 entry->resource_id(); | 1000 entry->resource_id(); |
| 1001 | 1001 |
| 1002 ProfileOAuth2TokenService* oauth2_token_service = | 1002 ProfileOAuth2TokenService* oauth2_token_service = |
| 1003 ProfileOAuth2TokenServiceFactory::GetForProfile(GetProfile()); | 1003 ProfileOAuth2TokenServiceFactory::GetForProfile(GetProfile()); |
| 1004 SigninManagerBase* signin_manager = | 1004 SigninManagerBase* signin_manager = |
| 1005 SigninManagerFactory::GetForProfile(GetProfile()); | 1005 SigninManagerFactory::GetForProfile(GetProfile()); |
| 1006 const std::string& account_id = signin_manager->GetAuthenticatedAccountId(); | 1006 std::string account_id = signin_manager->GetAuthenticatedAccountId(); |
| 1007 std::vector<std::string> scopes; | 1007 std::vector<std::string> scopes; |
| 1008 scopes.push_back("https://www.googleapis.com/auth/drive.readonly"); | 1008 scopes.push_back("https://www.googleapis.com/auth/drive.readonly"); |
| 1009 | 1009 |
| 1010 auth_service_.reset( | 1010 auth_service_.reset( |
| 1011 new google_apis::AuthService(oauth2_token_service, | 1011 new google_apis::AuthService(oauth2_token_service, |
| 1012 account_id, | 1012 account_id, |
| 1013 GetProfile()->GetRequestContext(), | 1013 GetProfile()->GetRequestContext(), |
| 1014 scopes)); | 1014 scopes)); |
| 1015 auth_service_->StartAuthentication(base::Bind( | 1015 auth_service_->StartAuthentication(base::Bind( |
| 1016 &FileManagerPrivateGetDownloadUrlFunction::OnTokenFetched, this)); | 1016 &FileManagerPrivateGetDownloadUrlFunction::OnTokenFetched, this)); |
| 1017 } | 1017 } |
| 1018 | 1018 |
| 1019 void FileManagerPrivateGetDownloadUrlFunction::OnTokenFetched( | 1019 void FileManagerPrivateGetDownloadUrlFunction::OnTokenFetched( |
| 1020 google_apis::GDataErrorCode code, | 1020 google_apis::GDataErrorCode code, |
| 1021 const std::string& access_token) { | 1021 const std::string& access_token) { |
| 1022 if (code != google_apis::HTTP_SUCCESS) { | 1022 if (code != google_apis::HTTP_SUCCESS) { |
| 1023 SetError("Not able to fetch the token."); | 1023 SetError("Not able to fetch the token."); |
| 1024 SetResult(new base::StringValue("")); // Intentionally returns a blank. | 1024 SetResult(new base::StringValue("")); // Intentionally returns a blank. |
| 1025 SendResponse(false); | 1025 SendResponse(false); |
| 1026 return; | 1026 return; |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 const std::string url = download_url_ + "?access_token=" + access_token; | 1029 const std::string url = download_url_ + "?access_token=" + access_token; |
| 1030 SetResult(new base::StringValue(url)); | 1030 SetResult(new base::StringValue(url)); |
| 1031 | 1031 |
| 1032 SendResponse(true); | 1032 SendResponse(true); |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 } // namespace extensions | 1035 } // namespace extensions |
| OLD | NEW |