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" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 if (sender_.get()) | 303 if (sender_.get()) |
304 sender_->auth_service()->RemoveObserver(this); | 304 sender_->auth_service()->RemoveObserver(this); |
305 } | 305 } |
306 | 306 |
307 void DriveAPIService::Initialize(const std::string& account_id) { | 307 void DriveAPIService::Initialize(const std::string& account_id) { |
308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
309 | 309 |
310 std::vector<std::string> scopes; | 310 std::vector<std::string> scopes; |
311 scopes.push_back(kDriveScope); | 311 scopes.push_back(kDriveScope); |
312 scopes.push_back(kDriveAppsReadonlyScope); | 312 scopes.push_back(kDriveAppsReadonlyScope); |
| 313 scopes.push_back(util::kDriveAppsScope); |
313 | 314 |
314 // GData WAPI token. These are for GetShareUrl(). | 315 // GData WAPI token for GetShareUrl() and GetResourceListInDirectoryByWapi(). |
315 scopes.push_back(util::kDocsListScope); | 316 scopes.push_back(util::kDocsListScope); |
316 scopes.push_back(util::kDriveAppsScope); | |
317 | 317 |
318 sender_.reset(new RequestSender( | 318 sender_.reset(new RequestSender( |
319 new google_apis::AuthService(oauth2_token_service_, | 319 new google_apis::AuthService(oauth2_token_service_, |
320 account_id, | 320 account_id, |
321 url_request_context_getter_.get(), | 321 url_request_context_getter_.get(), |
322 scopes), | 322 scopes), |
323 url_request_context_getter_.get(), | 323 url_request_context_getter_.get(), |
324 blocking_task_runner_.get(), | 324 blocking_task_runner_.get(), |
325 custom_user_agent_)); | 325 custom_user_agent_)); |
326 sender_->auth_service()->AddObserver(this); | 326 sender_->auth_service()->AddObserver(this); |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 request->set_fields(kFileResourceOpenWithLinksFields); | 791 request->set_fields(kFileResourceOpenWithLinksFields); |
792 return sender_->StartRequestWithRetry(request); | 792 return sender_->StartRequestWithRetry(request); |
793 } | 793 } |
794 | 794 |
795 CancelCallback DriveAPIService::UninstallApp( | 795 CancelCallback DriveAPIService::UninstallApp( |
796 const std::string& app_id, | 796 const std::string& app_id, |
797 const google_apis::EntryActionCallback& callback) { | 797 const google_apis::EntryActionCallback& callback) { |
798 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 798 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
799 DCHECK(!callback.is_null()); | 799 DCHECK(!callback.is_null()); |
800 | 800 |
801 // TODO(kinaba) implement. | 801 google_apis::drive::AppsDeleteRequest* request = |
802 NOTREACHED(); | 802 new google_apis::drive::AppsDeleteRequest(sender_.get(), url_generator_, |
803 return CancelCallback(); | 803 callback); |
| 804 request->set_app_id(app_id); |
| 805 return sender_->StartRequestWithRetry(request); |
804 } | 806 } |
805 | 807 |
806 CancelCallback DriveAPIService::GetResourceListInDirectoryByWapi( | 808 CancelCallback DriveAPIService::GetResourceListInDirectoryByWapi( |
807 const std::string& directory_resource_id, | 809 const std::string& directory_resource_id, |
808 const google_apis::GetResourceListCallback& callback) { | 810 const google_apis::GetResourceListCallback& callback) { |
809 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 811 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
810 DCHECK(!directory_resource_id.empty()); | 812 DCHECK(!directory_resource_id.empty()); |
811 DCHECK(!callback.is_null()); | 813 DCHECK(!callback.is_null()); |
812 | 814 |
813 return sender_->StartRequestWithRetry( | 815 return sender_->StartRequestWithRetry( |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 if (CanSendRequest()) { | 878 if (CanSendRequest()) { |
877 FOR_EACH_OBSERVER( | 879 FOR_EACH_OBSERVER( |
878 DriveServiceObserver, observers_, OnReadyToSendRequests()); | 880 DriveServiceObserver, observers_, OnReadyToSendRequests()); |
879 } else if (!HasRefreshToken()) { | 881 } else if (!HasRefreshToken()) { |
880 FOR_EACH_OBSERVER( | 882 FOR_EACH_OBSERVER( |
881 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); | 883 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); |
882 } | 884 } |
883 } | 885 } |
884 | 886 |
885 } // namespace drive | 887 } // namespace drive |
OLD | NEW |