| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/drive/drive_api_service.h" | 5 #include "chrome/browser/drive/drive_api_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "chrome/browser/drive/drive_api_util.h" | 12 #include "chrome/browser/drive/drive_api_util.h" |
| 13 #include "components/user_manager/user_id.h" |
| 13 #include "google_apis/drive/auth_service.h" | 14 #include "google_apis/drive/auth_service.h" |
| 14 #include "google_apis/drive/drive_api_parser.h" | 15 #include "google_apis/drive/drive_api_parser.h" |
| 15 #include "google_apis/drive/drive_api_requests.h" | 16 #include "google_apis/drive/drive_api_requests.h" |
| 16 #include "google_apis/drive/request_sender.h" | 17 #include "google_apis/drive/request_sender.h" |
| 17 #include "google_apis/google_api_keys.h" | 18 #include "google_apis/google_api_keys.h" |
| 18 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
| 19 | 20 |
| 20 using google_apis::AboutResourceCallback; | 21 using google_apis::AboutResourceCallback; |
| 21 using google_apis::AppList; | 22 using google_apis::AppList; |
| 22 using google_apis::AppListCallback; | 23 using google_apis::AppListCallback; |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 | 784 |
| 784 google_apis::drive::AppsDeleteRequest* request = | 785 google_apis::drive::AppsDeleteRequest* request = |
| 785 new google_apis::drive::AppsDeleteRequest(sender_.get(), url_generator_, | 786 new google_apis::drive::AppsDeleteRequest(sender_.get(), url_generator_, |
| 786 callback); | 787 callback); |
| 787 request->set_app_id(app_id); | 788 request->set_app_id(app_id); |
| 788 return sender_->StartRequestWithRetry(request); | 789 return sender_->StartRequestWithRetry(request); |
| 789 } | 790 } |
| 790 | 791 |
| 791 google_apis::CancelCallback DriveAPIService::AddPermission( | 792 google_apis::CancelCallback DriveAPIService::AddPermission( |
| 792 const std::string& resource_id, | 793 const std::string& resource_id, |
| 793 const std::string& email, | 794 const user_manager::UserID& user_id, |
| 794 google_apis::drive::PermissionRole role, | 795 google_apis::drive::PermissionRole role, |
| 795 const google_apis::EntryActionCallback& callback) { | 796 const google_apis::EntryActionCallback& callback) { |
| 796 DCHECK(thread_checker_.CalledOnValidThread()); | 797 DCHECK(thread_checker_.CalledOnValidThread()); |
| 797 DCHECK(!callback.is_null()); | 798 DCHECK(!callback.is_null()); |
| 798 | 799 |
| 799 google_apis::drive::PermissionsInsertRequest* request = | 800 google_apis::drive::PermissionsInsertRequest* request = |
| 800 new google_apis::drive::PermissionsInsertRequest(sender_.get(), | 801 new google_apis::drive::PermissionsInsertRequest(sender_.get(), |
| 801 url_generator_, | 802 url_generator_, |
| 802 callback); | 803 callback); |
| 803 request->set_id(resource_id); | 804 request->set_id(resource_id); |
| 804 request->set_role(role); | 805 request->set_role(role); |
| 805 request->set_type(google_apis::drive::PERMISSION_TYPE_USER); | 806 request->set_type(google_apis::drive::PERMISSION_TYPE_USER); |
| 806 request->set_value(email); | 807 request->set_value(user_id.GetUserEmail()); |
| 807 return sender_->StartRequestWithRetry(request); | 808 return sender_->StartRequestWithRetry(request); |
| 808 } | 809 } |
| 809 | 810 |
| 810 bool DriveAPIService::HasAccessToken() const { | 811 bool DriveAPIService::HasAccessToken() const { |
| 811 DCHECK(thread_checker_.CalledOnValidThread()); | 812 DCHECK(thread_checker_.CalledOnValidThread()); |
| 812 return sender_->auth_service()->HasAccessToken(); | 813 return sender_->auth_service()->HasAccessToken(); |
| 813 } | 814 } |
| 814 | 815 |
| 815 void DriveAPIService::RequestAccessToken(const AuthStatusCallback& callback) { | 816 void DriveAPIService::RequestAccessToken(const AuthStatusCallback& callback) { |
| 816 DCHECK(thread_checker_.CalledOnValidThread()); | 817 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 // RequestSender before the request is committed because the request has a | 865 // RequestSender before the request is committed because the request has a |
| 865 // reference to RequestSender and we should ensure to delete the request when | 866 // reference to RequestSender and we should ensure to delete the request when |
| 866 // the sender is deleted. Resolve the circulating dependency and fix it. | 867 // the sender is deleted. Resolve the circulating dependency and fix it. |
| 867 const google_apis::CancelCallback callback = | 868 const google_apis::CancelCallback callback = |
| 868 sender_->StartRequestWithRetry(request.release()); | 869 sender_->StartRequestWithRetry(request.release()); |
| 869 return make_scoped_ptr<BatchRequestConfiguratorInterface>( | 870 return make_scoped_ptr<BatchRequestConfiguratorInterface>( |
| 870 new BatchRequestConfigurator(weak_ref, callback)); | 871 new BatchRequestConfigurator(weak_ref, callback)); |
| 871 } | 872 } |
| 872 | 873 |
| 873 } // namespace drive | 874 } // namespace drive |
| OLD | NEW |