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

Side by Side Diff: chrome/browser/chromeos/extensions/file_browser_private_api.cc

Issue 10905142: Rename GData to Drive in drive_file_system_util (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
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/chromeos/extensions/file_browser_private_api.h" 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h"
6 6
7 #include <sys/statvfs.h> 7 #include <sys/statvfs.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 void AddGDataMountPoint( 174 void AddGDataMountPoint(
175 Profile* profile, 175 Profile* profile,
176 const std::string& extension_id, 176 const std::string& extension_id,
177 content::RenderViewHost* render_view_host) { 177 content::RenderViewHost* render_view_host) {
178 fileapi::ExternalFileSystemMountPointProvider* provider = 178 fileapi::ExternalFileSystemMountPointProvider* provider =
179 BrowserContext::GetFileSystemContext(profile)->external_provider(); 179 BrowserContext::GetFileSystemContext(profile)->external_provider();
180 if (!provider) 180 if (!provider)
181 return; 181 return;
182 182
183 const FilePath mount_point = gdata::util::GetGDataMountPointPath(); 183 const FilePath mount_point = gdata::util::GetDriveMountPointPath();
184 if (!render_view_host || !render_view_host->GetProcess()) 184 if (!render_view_host || !render_view_host->GetProcess())
185 return; 185 return;
186 186
187 // Grant R/W permissions to gdata 'folder'. File API layer still 187 // Grant R/W permissions to gdata 'folder'. File API layer still
188 // expects this to be satisfied. 188 // expects this to be satisfied.
189 GrantFilePermissionsToHost(render_view_host, 189 GrantFilePermissionsToHost(render_view_host,
190 mount_point, 190 mount_point,
191 file_handler_util::GetReadWritePermissions()); 191 file_handler_util::GetReadWritePermissions());
192 192
193 // Grant R/W permission for tmp and pinned cache folder. 193 // Grant R/W permission for tmp and pinned cache folder.
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 switch (mount_type) { 1202 switch (mount_type) {
1203 case chromeos::MOUNT_TYPE_INVALID: { 1203 case chromeos::MOUNT_TYPE_INVALID: {
1204 error_ = "Invalid mount type"; 1204 error_ = "Invalid mount type";
1205 SendResponse(false); 1205 SendResponse(false);
1206 break; 1206 break;
1207 } 1207 }
1208 case chromeos::MOUNT_TYPE_GDATA: { 1208 case chromeos::MOUNT_TYPE_GDATA: {
1209 const bool success = true; 1209 const bool success = true;
1210 // Pass back the gdata mount point path as source path. 1210 // Pass back the gdata mount point path as source path.
1211 const std::string& gdata_path = 1211 const std::string& gdata_path =
1212 gdata::util::GetGDataMountPointPathAsString(); 1212 gdata::util::GetDriveMountPointPathAsString();
1213 SetResult(Value::CreateStringValue(gdata_path)); 1213 SetResult(Value::CreateStringValue(gdata_path));
1214 FileBrowserEventRouterFactory::GetForProfile(profile_)-> 1214 FileBrowserEventRouterFactory::GetForProfile(profile_)->
1215 MountDrive(base::Bind(&AddMountFunction::SendResponse, 1215 MountDrive(base::Bind(&AddMountFunction::SendResponse,
1216 this, 1216 this,
1217 success)); 1217 success));
1218 break; 1218 break;
1219 } 1219 }
1220 default: { 1220 default: {
1221 UrlList file_paths; 1221 UrlList file_paths;
1222 file_paths.push_back(GURL(file_url)); 1222 file_paths.push_back(GURL(file_url));
(...skipping 15 matching lines...) Expand all
1238 const SelectedFileInfoList& files) { 1238 const SelectedFileInfoList& files) {
1239 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1239 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1240 1240
1241 if (!files.size()) { 1241 if (!files.size()) {
1242 SendResponse(false); 1242 SendResponse(false);
1243 return; 1243 return;
1244 } 1244 }
1245 1245
1246 const FilePath& source_path = files[0].local_path; 1246 const FilePath& source_path = files[0].local_path;
1247 const FilePath::StringType& display_name = files[0].display_name; 1247 const FilePath::StringType& display_name = files[0].display_name;
1248 // Check if the source path is under GData cache directory. 1248 // Check if the source path is under Drive cache directory.
1249 gdata::DriveSystemService* system_service = 1249 gdata::DriveSystemService* system_service =
1250 gdata::DriveSystemServiceFactory::GetForProfile(profile_); 1250 gdata::DriveSystemServiceFactory::GetForProfile(profile_);
1251 gdata::DriveCache* cache = system_service ? system_service->cache() : NULL; 1251 gdata::DriveCache* cache = system_service ? system_service->cache() : NULL;
1252 if (cache && cache->IsUnderDriveCacheDirectory(source_path)) { 1252 if (cache && cache->IsUnderDriveCacheDirectory(source_path)) {
1253 cache->SetMountedStateOnUIThread( 1253 cache->SetMountedStateOnUIThread(
1254 source_path, 1254 source_path,
1255 true, 1255 true,
1256 base::Bind(&AddMountFunction::OnMountedStateSet, this, mount_type_str, 1256 base::Bind(&AddMountFunction::OnMountedStateSet, this, mount_type_str,
1257 display_name)); 1257 display_name));
1258 } else { 1258 } else {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 1368
1369 void GetSizeStatsFunction::GetLocalPathsResponseOnUIThread( 1369 void GetSizeStatsFunction::GetLocalPathsResponseOnUIThread(
1370 const SelectedFileInfoList& files) { 1370 const SelectedFileInfoList& files) {
1371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1372 1372
1373 if (files.size() != 1) { 1373 if (files.size() != 1) {
1374 SendResponse(false); 1374 SendResponse(false);
1375 return; 1375 return;
1376 } 1376 }
1377 1377
1378 if (files[0].file_path == gdata::util::GetGDataMountPointPath()) { 1378 if (files[0].file_path == gdata::util::GetDriveMountPointPath()) {
1379 gdata::DriveSystemService* system_service = 1379 gdata::DriveSystemService* system_service =
1380 gdata::DriveSystemServiceFactory::GetForProfile(profile_); 1380 gdata::DriveSystemServiceFactory::GetForProfile(profile_);
1381 1381
1382 gdata::DriveFileSystemInterface* file_system = 1382 gdata::DriveFileSystemInterface* file_system =
1383 system_service->file_system(); 1383 system_service->file_system();
1384 1384
1385 file_system->GetAvailableSpace( 1385 file_system->GetAvailableSpace(
1386 base::Bind(&GetSizeStatsFunction::GetGDataAvailableSpaceCallback, 1386 base::Bind(&GetSizeStatsFunction::GetGDataAvailableSpaceCallback,
1387 this)); 1387 this));
1388 1388
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
2141 this)); 2141 this));
2142 return true; 2142 return true;
2143 } 2143 }
2144 2144
2145 void GetFileLocationsFunction::GetLocalPathsResponseOnUIThread( 2145 void GetFileLocationsFunction::GetLocalPathsResponseOnUIThread(
2146 const SelectedFileInfoList& files) { 2146 const SelectedFileInfoList& files) {
2147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2148 2148
2149 ListValue* locations = new ListValue; 2149 ListValue* locations = new ListValue;
2150 for (size_t i = 0; i < files.size(); ++i) { 2150 for (size_t i = 0; i < files.size(); ++i) {
2151 if (gdata::util::IsUnderGDataMountPoint(files[i].file_path)) { 2151 if (gdata::util::IsUnderDriveMountPoint(files[i].file_path)) {
2152 locations->Append(Value::CreateStringValue("drive")); 2152 locations->Append(Value::CreateStringValue("drive"));
2153 } else { 2153 } else {
2154 locations->Append(Value::CreateStringValue("local")); 2154 locations->Append(Value::CreateStringValue("local"));
2155 } 2155 }
2156 } 2156 }
2157 2157
2158 SetResult(locations); 2158 SetResult(locations);
2159 SendResponse(true); 2159 SendResponse(true);
2160 } 2160 }
2161 2161
(...skipping 23 matching lines...) Expand all
2185 base::Bind(&GetGDataFilesFunction::GetLocalPathsResponseOnUIThread, 2185 base::Bind(&GetGDataFilesFunction::GetLocalPathsResponseOnUIThread,
2186 this)); 2186 this));
2187 return true; 2187 return true;
2188 } 2188 }
2189 2189
2190 void GetGDataFilesFunction::GetLocalPathsResponseOnUIThread( 2190 void GetGDataFilesFunction::GetLocalPathsResponseOnUIThread(
2191 const SelectedFileInfoList& files) { 2191 const SelectedFileInfoList& files) {
2192 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2192 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2193 2193
2194 for (size_t i = 0; i < files.size(); ++i) { 2194 for (size_t i = 0; i < files.size(); ++i) {
2195 DCHECK(gdata::util::IsUnderGDataMountPoint(files[i].file_path)); 2195 DCHECK(gdata::util::IsUnderDriveMountPoint(files[i].file_path));
2196 FilePath gdata_path = gdata::util::ExtractGDataPath(files[i].file_path); 2196 FilePath gdata_path = gdata::util::ExtractDrivePath(files[i].file_path);
2197 remaining_gdata_paths_.push(gdata_path); 2197 remaining_gdata_paths_.push(gdata_path);
2198 } 2198 }
2199 2199
2200 local_paths_ = new ListValue; 2200 local_paths_ = new ListValue;
2201 GetFileOrSendResponse(); 2201 GetFileOrSendResponse();
2202 } 2202 }
2203 2203
2204 void GetGDataFilesFunction::GetFileOrSendResponse() { 2204 void GetGDataFilesFunction::GetFileOrSendResponse() {
2205 // Send the response if all files are obtained. 2205 // Send the response if all files are obtained.
2206 if (remaining_gdata_paths_.empty()) { 2206 if (remaining_gdata_paths_.empty()) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 if (!system_service) { 2315 if (!system_service) {
2316 SendResponse(false); 2316 SendResponse(false);
2317 return; 2317 return;
2318 } 2318 }
2319 2319
2320 gdata::OperationRegistry* operation_registry = 2320 gdata::OperationRegistry* operation_registry =
2321 system_service->drive_service()->operation_registry(); 2321 system_service->drive_service()->operation_registry();
2322 2322
2323 scoped_ptr<ListValue> responses(new ListValue()); 2323 scoped_ptr<ListValue> responses(new ListValue());
2324 for (size_t i = 0; i < files.size(); ++i) { 2324 for (size_t i = 0; i < files.size(); ++i) {
2325 DCHECK(gdata::util::IsUnderGDataMountPoint(files[i].file_path)); 2325 DCHECK(gdata::util::IsUnderDriveMountPoint(files[i].file_path));
2326 FilePath file_path = gdata::util::ExtractGDataPath(files[i].file_path); 2326 FilePath file_path = gdata::util::ExtractDrivePath(files[i].file_path);
2327 scoped_ptr<DictionaryValue> result(new DictionaryValue()); 2327 scoped_ptr<DictionaryValue> result(new DictionaryValue());
2328 result->SetBoolean( 2328 result->SetBoolean(
2329 "canceled", 2329 "canceled",
2330 operation_registry->CancelForFilePath(file_path)); 2330 operation_registry->CancelForFilePath(file_path));
2331 GURL file_url; 2331 GURL file_url;
2332 if (file_manager_util::ConvertFileToFileSystemUrl(profile_, 2332 if (file_manager_util::ConvertFileToFileSystemUrl(profile_,
2333 gdata::util::GetSpecialRemoteRootPath().Append(file_path), 2333 gdata::util::GetSpecialRemoteRootPath().Append(file_path),
2334 source_url_.GetOrigin(), 2334 source_url_.GetOrigin(),
2335 &file_url)) { 2335 &file_url)) {
2336 result->SetString("fileUrl", file_url.spec()); 2336 result->SetString("fileUrl", file_url.spec());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 gdata::DriveSystemServiceFactory::GetForProfile(profile_); 2377 gdata::DriveSystemServiceFactory::GetForProfile(profile_);
2378 if (!system_service) { 2378 if (!system_service) {
2379 SendResponse(false); 2379 SendResponse(false);
2380 return; 2380 return;
2381 } 2381 }
2382 2382
2383 FilePath source_file = files[0].file_path; 2383 FilePath source_file = files[0].file_path;
2384 FilePath destination_file = files[1].file_path; 2384 FilePath destination_file = files[1].file_path;
2385 2385
2386 bool source_file_under_gdata = 2386 bool source_file_under_gdata =
2387 gdata::util::IsUnderGDataMountPoint(source_file); 2387 gdata::util::IsUnderDriveMountPoint(source_file);
2388 bool destination_file_under_gdata = 2388 bool destination_file_under_gdata =
2389 gdata::util::IsUnderGDataMountPoint(destination_file); 2389 gdata::util::IsUnderDriveMountPoint(destination_file);
2390 2390
2391 if (source_file_under_gdata && !destination_file_under_gdata) { 2391 if (source_file_under_gdata && !destination_file_under_gdata) {
2392 // Transfer a file from gdata to local file system. 2392 // Transfer a file from gdata to local file system.
2393 source_file = gdata::util::ExtractGDataPath(source_file); 2393 source_file = gdata::util::ExtractDrivePath(source_file);
2394 system_service->file_system()->TransferFileFromRemoteToLocal( 2394 system_service->file_system()->TransferFileFromRemoteToLocal(
2395 source_file, 2395 source_file,
2396 destination_file, 2396 destination_file,
2397 base::Bind(&TransferFileFunction::OnTransferCompleted, this)); 2397 base::Bind(&TransferFileFunction::OnTransferCompleted, this));
2398 } else if (!source_file_under_gdata && destination_file_under_gdata) { 2398 } else if (!source_file_under_gdata && destination_file_under_gdata) {
2399 // Transfer a file from local to Drive file system 2399 // Transfer a file from local to Drive file system
2400 destination_file = gdata::util::ExtractGDataPath(destination_file); 2400 destination_file = gdata::util::ExtractDrivePath(destination_file);
2401 system_service->file_system()->TransferFileFromLocalToRemote( 2401 system_service->file_system()->TransferFileFromLocalToRemote(
2402 source_file, 2402 source_file,
2403 destination_file, 2403 destination_file,
2404 base::Bind(&TransferFileFunction::OnTransferCompleted, this)); 2404 base::Bind(&TransferFileFunction::OnTransferCompleted, this));
2405 } else { 2405 } else {
2406 // Local-to-local or Drive-to-Drive file transfers should be done via 2406 // Local-to-local or Drive-to-Drive file transfers should be done via
2407 // FileEntry.copyTo in the File API and are thus not supported here. 2407 // FileEntry.copyTo in the File API and are thus not supported here.
2408 NOTREACHED(); 2408 NOTREACHED();
2409 SendResponse(false); 2409 SendResponse(false);
2410 } 2410 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2586 gdata::DriveSystemService* system_service = 2586 gdata::DriveSystemService* system_service =
2587 gdata::DriveSystemServiceFactory::GetForProfile(profile_); 2587 gdata::DriveSystemServiceFactory::GetForProfile(profile_);
2588 if (!system_service || !system_service->file_system()) 2588 if (!system_service || !system_service->file_system())
2589 return false; 2589 return false;
2590 2590
2591 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); 2591 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string));
2592 system_service->file_system()->RequestDirectoryRefresh(directory_path); 2592 system_service->file_system()->RequestDirectoryRefresh(directory_path);
2593 2593
2594 return true; 2594 return true;
2595 } 2595 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698