Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(693)

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc

Issue 1965963003: Use new API to download blobs from Google Drive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 if (!entry_proto.has_file_specific_info()) 91 if (!entry_proto.has_file_specific_info())
92 return; 92 return;
93 93
94 const drive::FileSpecificInfo& file_specific_info = 94 const drive::FileSpecificInfo& file_specific_info =
95 entry_proto.file_specific_info(); 95 entry_proto.file_specific_info();
96 96
97 if (!entry_proto.resource_id().empty()) { 97 if (!entry_proto.resource_id().empty()) {
98 DriveApiUrlGenerator url_generator( 98 DriveApiUrlGenerator url_generator(
99 (GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction)), 99 (GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction)),
100 (GURL(
101 google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction)),
102 (GURL(google_apis::DriveApiUrlGenerator:: 100 (GURL(google_apis::DriveApiUrlGenerator::
103 kBaseThumbnailUrlForProduction))); 101 kBaseThumbnailUrlForProduction)));
104 properties->thumbnail_url.reset(new std::string( 102 properties->thumbnail_url.reset(new std::string(
105 url_generator.GetThumbnailUrl(entry_proto.resource_id(), 103 url_generator.GetThumbnailUrl(entry_proto.resource_id(),
106 500 /* width */, 500 /* height */, 104 500 /* width */, 500 /* height */,
107 false /* not cropped */).spec())); 105 false /* not cropped */).spec()));
108 properties->cropped_thumbnail_url.reset(new std::string( 106 properties->cropped_thumbnail_url.reset(new std::string(
109 url_generator.GetThumbnailUrl( 107 url_generator.GetThumbnailUrl(
110 entry_proto.resource_id(), 108 entry_proto.resource_id(),
111 kFileManagerMaximumThumbnailDimension /* width */, 109 kFileManagerMaximumThumbnailDimension /* width */,
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 1096
1099 if (error != drive::FILE_ERROR_OK) { 1097 if (error != drive::FILE_ERROR_OK) {
1100 SetError("Download Url for this item is not available."); 1098 SetError("Download Url for this item is not available.");
1101 SetResult(new base::StringValue("")); // Intentionally returns a blank. 1099 SetResult(new base::StringValue("")); // Intentionally returns a blank.
1102 SendResponse(false); 1100 SendResponse(false);
1103 return; 1101 return;
1104 } 1102 }
1105 1103
1106 DriveApiUrlGenerator url_generator( 1104 DriveApiUrlGenerator url_generator(
1107 (GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction)), 1105 (GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction)),
1108 (GURL(google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction)),
1109 (GURL( 1106 (GURL(
1110 google_apis::DriveApiUrlGenerator::kBaseThumbnailUrlForProduction))); 1107 google_apis::DriveApiUrlGenerator::kBaseThumbnailUrlForProduction)));
1111 download_url_ = url_generator.GenerateDownloadFileUrl(entry->resource_id()); 1108 download_url_ = url_generator.GenerateDownloadFileUrl(entry->resource_id());
1112 1109
1113 ProfileOAuth2TokenService* oauth2_token_service = 1110 ProfileOAuth2TokenService* oauth2_token_service =
1114 ProfileOAuth2TokenServiceFactory::GetForProfile(GetProfile()); 1111 ProfileOAuth2TokenServiceFactory::GetForProfile(GetProfile());
1115 SigninManagerBase* signin_manager = 1112 SigninManagerBase* signin_manager =
1116 SigninManagerFactory::GetForProfile(GetProfile()); 1113 SigninManagerFactory::GetForProfile(GetProfile());
1117 const std::string& account_id = signin_manager->GetAuthenticatedAccountId(); 1114 const std::string& account_id = signin_manager->GetAuthenticatedAccountId();
1118 std::vector<std::string> scopes; 1115 std::vector<std::string> scopes;
(...skipping 12 matching lines...) Expand all
1131 google_apis::DriveApiErrorCode code, 1128 google_apis::DriveApiErrorCode code,
1132 const std::string& access_token) { 1129 const std::string& access_token) {
1133 if (code != google_apis::HTTP_SUCCESS) { 1130 if (code != google_apis::HTTP_SUCCESS) {
1134 SetError("Not able to fetch the token."); 1131 SetError("Not able to fetch the token.");
1135 SetResult(new base::StringValue("")); // Intentionally returns a blank. 1132 SetResult(new base::StringValue("")); // Intentionally returns a blank.
1136 SendResponse(false); 1133 SendResponse(false);
1137 return; 1134 return;
1138 } 1135 }
1139 1136
1140 const std::string url = 1137 const std::string url =
1141 download_url_.Resolve("?access_token=" + access_token).spec(); 1138 download_url_.Resolve("?alt=media&access_token=" + access_token).spec();
1142 SetResult(new base::StringValue(url)); 1139 SetResult(new base::StringValue(url));
1143 1140
1144 SendResponse(true); 1141 SendResponse(true);
1145 } 1142 }
1146 1143
1147 } // namespace extensions 1144 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698