Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 using google_apis::AuthorizeAppCallback; | 24 using google_apis::AuthorizeAppCallback; |
| 25 using google_apis::CancelCallback; | 25 using google_apis::CancelCallback; |
| 26 using google_apis::ChangeList; | 26 using google_apis::ChangeList; |
| 27 using google_apis::ChangeListCallback; | 27 using google_apis::ChangeListCallback; |
| 28 using google_apis::DownloadActionCallback; | 28 using google_apis::DownloadActionCallback; |
| 29 using google_apis::EntryActionCallback; | 29 using google_apis::EntryActionCallback; |
| 30 using google_apis::FileList; | 30 using google_apis::FileList; |
| 31 using google_apis::FileListCallback; | 31 using google_apis::FileListCallback; |
| 32 using google_apis::FileResource; | 32 using google_apis::FileResource; |
| 33 using google_apis::FileResourceCallback; | 33 using google_apis::FileResourceCallback; |
| 34 using google_apis::GDATA_OTHER_ERROR; | 34 using google_apis::DRIVE_OTHER_ERROR; |
|
mtomasz
2015/01/29 06:18:01
nit: Alpha order.
| |
| 35 using google_apis::GDATA_PARSE_ERROR; | 35 using google_apis::DRIVE_PARSE_ERROR; |
| 36 using google_apis::GDataErrorCode; | 36 using google_apis::DriveApiErrorCode; |
| 37 using google_apis::GetContentCallback; | 37 using google_apis::GetContentCallback; |
| 38 using google_apis::GetShareUrlCallback; | 38 using google_apis::GetShareUrlCallback; |
| 39 using google_apis::HTTP_NOT_IMPLEMENTED; | 39 using google_apis::HTTP_NOT_IMPLEMENTED; |
| 40 using google_apis::HTTP_SUCCESS; | 40 using google_apis::HTTP_SUCCESS; |
| 41 using google_apis::InitiateUploadCallback; | 41 using google_apis::InitiateUploadCallback; |
| 42 using google_apis::ProgressCallback; | 42 using google_apis::ProgressCallback; |
| 43 using google_apis::RequestSender; | 43 using google_apis::RequestSender; |
| 44 using google_apis::UploadRangeResponse; | 44 using google_apis::UploadRangeResponse; |
| 45 using google_apis::drive::AboutGetRequest; | 45 using google_apis::drive::AboutGetRequest; |
| 46 using google_apis::drive::AppsListRequest; | 46 using google_apis::drive::AppsListRequest; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 const char kChangeListFields[] = | 111 const char kChangeListFields[] = |
| 112 "kind,items(file(kind,id,title,createdDate,sharedWithMeDate," | 112 "kind,items(file(kind,id,title,createdDate,sharedWithMeDate," |
| 113 "mimeType,md5Checksum,fileSize,labels/trashed,imageMediaMetadata/width," | 113 "mimeType,md5Checksum,fileSize,labels/trashed,imageMediaMetadata/width," |
| 114 "imageMediaMetadata/height,imageMediaMetadata/rotation,etag," | 114 "imageMediaMetadata/height,imageMediaMetadata/rotation,etag," |
| 115 "parents(id,parentLink),alternateLink,modifiedDate," | 115 "parents(id,parentLink),alternateLink,modifiedDate," |
| 116 "lastViewedByMeDate,shared),deleted,id,fileId,modificationDate),nextLink," | 116 "lastViewedByMeDate,shared),deleted,id,fileId,modificationDate),nextLink," |
| 117 "largestChangeId"; | 117 "largestChangeId"; |
| 118 | 118 |
| 119 void ExtractOpenUrlAndRun(const std::string& app_id, | 119 void ExtractOpenUrlAndRun(const std::string& app_id, |
| 120 const AuthorizeAppCallback& callback, | 120 const AuthorizeAppCallback& callback, |
| 121 GDataErrorCode error, | 121 DriveApiErrorCode error, |
| 122 scoped_ptr<FileResource> value) { | 122 scoped_ptr<FileResource> value) { |
| 123 DCHECK(!callback.is_null()); | 123 DCHECK(!callback.is_null()); |
| 124 | 124 |
| 125 if (!value) { | 125 if (!value) { |
| 126 callback.Run(error, GURL()); | 126 callback.Run(error, GURL()); |
| 127 return; | 127 return; |
| 128 } | 128 } |
| 129 | 129 |
| 130 const std::vector<FileResource::OpenWithLink>& open_with_links = | 130 const std::vector<FileResource::OpenWithLink>& open_with_links = |
| 131 value->open_with_links(); | 131 value->open_with_links(); |
| 132 for (size_t i = 0; i < open_with_links.size(); ++i) { | 132 for (size_t i = 0; i < open_with_links.size(); ++i) { |
| 133 if (open_with_links[i].app_id == app_id) { | 133 if (open_with_links[i].app_id == app_id) { |
| 134 callback.Run(HTTP_SUCCESS, open_with_links[i].open_url); | 134 callback.Run(HTTP_SUCCESS, open_with_links[i].open_url); |
| 135 return; | 135 return; |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 // Not found. | 139 // Not found. |
| 140 callback.Run(GDATA_OTHER_ERROR, GURL()); | 140 callback.Run(DRIVE_OTHER_ERROR, GURL()); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void ExtractShareUrlAndRun(const GetShareUrlCallback& callback, | 143 void ExtractShareUrlAndRun(const GetShareUrlCallback& callback, |
| 144 GDataErrorCode error, | 144 DriveApiErrorCode error, |
| 145 scoped_ptr<FileResource> value) { | 145 scoped_ptr<FileResource> value) { |
| 146 callback.Run(error, value ? value->share_link() : GURL()); | 146 callback.Run(error, value ? value->share_link() : GURL()); |
| 147 } | 147 } |
| 148 | 148 |
| 149 // Ignores the |entry|, and runs the |callback|. | 149 // Ignores the |entry|, and runs the |callback|. |
| 150 void EntryActionCallbackAdapter( | 150 void EntryActionCallbackAdapter( |
| 151 const EntryActionCallback& callback, | 151 const EntryActionCallback& callback, |
| 152 GDataErrorCode error, scoped_ptr<FileResource> entry) { | 152 DriveApiErrorCode error, scoped_ptr<FileResource> entry) { |
| 153 callback.Run(error); | 153 callback.Run(error); |
| 154 } | 154 } |
| 155 | 155 |
| 156 // The resource ID for the root directory for Drive API is defined in the spec: | 156 // The resource ID for the root directory for Drive API is defined in the spec: |
| 157 // https://developers.google.com/drive/folder | 157 // https://developers.google.com/drive/folder |
| 158 const char kDriveApiRootDirectoryResourceId[] = "root"; | 158 const char kDriveApiRootDirectoryResourceId[] = "root"; |
| 159 | 159 |
| 160 } // namespace | 160 } // namespace |
| 161 | 161 |
| 162 DriveAPIService::DriveAPIService( | 162 DriveAPIService::DriveAPIService( |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 768 if (CanSendRequest()) { | 768 if (CanSendRequest()) { |
| 769 FOR_EACH_OBSERVER( | 769 FOR_EACH_OBSERVER( |
| 770 DriveServiceObserver, observers_, OnReadyToSendRequests()); | 770 DriveServiceObserver, observers_, OnReadyToSendRequests()); |
| 771 } else if (!HasRefreshToken()) { | 771 } else if (!HasRefreshToken()) { |
| 772 FOR_EACH_OBSERVER( | 772 FOR_EACH_OBSERVER( |
| 773 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); | 773 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); |
| 774 } | 774 } |
| 775 } | 775 } |
| 776 | 776 |
| 777 } // namespace drive | 777 } // namespace drive |
| OLD | NEW |