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

Unified Diff: chrome/browser/chromeos/file_manager/filesystem_api_util.cc

Issue 304373004: Implement IsNonNativeLocalPathDirectory for supporting non-local non-Drive directory access in apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added comment. Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/file_manager/filesystem_api_util.cc
diff --git a/chrome/browser/chromeos/file_manager/filesystem_api_util.cc b/chrome/browser/chromeos/file_manager/filesystem_api_util.cc
index 04dc1d5febe6aefae7fb5a84e25449f8ab380ac9..f53c6b147d0a8168472e862c875db1fc074e443a 100644
--- a/chrome/browser/chromeos/file_manager/filesystem_api_util.cc
+++ b/chrome/browser/chromeos/file_manager/filesystem_api_util.cc
@@ -36,11 +36,14 @@ void GetMimeTypeAfterGetResourceEntry(
callback.Run(true, entry->file_specific_info().content_mime_type());
}
-void CheckDirectoryAfterDriveCheck(const base::Callback<void(bool)>& callback,
- drive::FileError error) {
+// Helper function to converts a callback that takes boolean value to that takes
+// File::Error, by regarding FILE_OK as the only successful value.
+void BoolCallbackAsFileErrorCallback(
+ const base::Callback<void(bool)>& callback,
+ base::File::Error error) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- return callback.Run(error == drive::FILE_ERROR_OK);
+ return callback.Run(error == base::File::FILE_OK);
}
void CheckWritableAfterDriveCheck(const base::Callback<void(bool)>& callback,
@@ -65,13 +68,9 @@ bool IsUnderNonNativeLocalPath(Profile* profile,
return false;
}
- content::StoragePartition* partition =
- content::BrowserContext::GetStoragePartitionForSite(
- profile,
- extensions::util::GetSiteForExtensionId(kFileManagerAppId, profile));
- fileapi::FileSystemContext* context = partition->GetFileSystemContext();
-
- fileapi::FileSystemURL filesystem_url = context->CrackURL(url);
+ fileapi::FileSystemURL filesystem_url =
+ GetFileSystemContextForExtensionId(profile,
+ kFileManagerAppId)->CrackURL(url);
if (!filesystem_url.is_valid())
return false;
@@ -123,12 +122,23 @@ void IsNonNativeLocalPathDirectory(
const base::FilePath& path,
const base::Callback<void(bool)>& callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ DCHECK(IsUnderNonNativeLocalPath(profile, path));
- // TODO(kinaba): support other types of volumes besides Drive.
- drive::util::CheckDirectoryExists(
- profile,
- path,
- base::Bind(&CheckDirectoryAfterDriveCheck, callback));
+ GURL url;
+ if (!util::ConvertAbsoluteFilePathToFileSystemUrl(
+ profile, path, kFileManagerAppId, &url)) {
+ // Posting to the current thread, so that we always call back asynchronously
+ // independent from whether or not the operation succeeeds.
+ content::BrowserThread::PostTask(content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(callback, false));
+ return;
+ }
+
+ util::CheckIfDirectoryExists(
+ GetFileSystemContextForExtensionId(profile, kFileManagerAppId),
+ url,
+ base::Bind(&BoolCallbackAsFileErrorCallback, callback));
}
void PrepareNonNativeLocalPathWritableFile(
« no previous file with comments | « chrome/browser/chromeos/file_manager/fileapi_util.cc ('k') | chrome/browser/chromeos/file_manager/open_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698