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

Unified Diff: chrome/browser/extensions/platform_app_launcher.cc

Issue 12258021: Fix filesystem API file_handlers to work for drive on ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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/extensions/platform_app_launcher.cc
diff --git a/chrome/browser/extensions/platform_app_launcher.cc b/chrome/browser/extensions/platform_app_launcher.cc
index 0d376098286f04c772a77002469e11c72bc0e94a..728a5d69651b08b96cb09ca471ba749497453866 100644
--- a/chrome/browser/extensions/platform_app_launcher.cc
+++ b/chrome/browser/extensions/platform_app_launcher.cc
@@ -32,6 +32,13 @@
#include "webkit/fileapi/file_system_types.h"
#include "webkit/fileapi/isolated_context.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/drive/drive_file_error.h"
+#include "chrome/browser/chromeos/drive/drive_file_system_interface.h"
+#include "chrome/browser/chromeos/drive/drive_file_system_util.h"
+#include "chrome/browser/chromeos/drive/drive_system_service.h"
+#endif
+
using content::BrowserThread;
using extensions::app_file_handler_util::FileHandlerForId;
using extensions::app_file_handler_util::FileHandlerCanHandleFileWithMimeType;
@@ -108,6 +115,14 @@ class PlatformAppPathLauncher
}
DCHECK(file_path_.IsAbsolute());
+
+#if defined(OS_CHROMEOS)
+ if (drive::util::IsUnderDriveMountPoint(file_path_)) {
+ GetMimeTypeAndLaunchForDriveFile();
+ return;
+ }
+#endif
+
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind(
&PlatformAppPathLauncher::GetMimeTypeAndLaunch, this));
}
@@ -148,6 +163,38 @@ class PlatformAppPathLauncher
&PlatformAppPathLauncher::LaunchWithMimeType, this, mime_type));
}
+#if defined(OS_CHROMEOS)
+ void GetMimeTypeAndLaunchForDriveFile() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ drive::DriveSystemService* service =
+ drive::DriveSystemServiceFactory::FindForProfile(profile_);
+ if (!service) {
+ LaunchWithNoLaunchData();
+ return;
+ }
+
+ service->file_system()->GetFileByPath(
+ drive::util::ExtractDrivePath(file_path_),
+ base::Bind(&PlatformAppPathLauncher::OnGotDriveFile, this));
+ }
+
+ void OnGotDriveFile(drive::DriveFileError error,
+ const base::FilePath& file_path,
+ const std::string& mime_type,
+ drive::DriveFileType file_type) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (error != drive::DRIVE_FILE_OK || mime_type.empty() ||
+ file_type != drive::REGULAR_FILE) {
+ LaunchWithNoLaunchData();
+ return;
+ }
+
+ LaunchWithMimeType(mime_type);
+ }
+#endif // defined(OS_CHROMEOS)
+
void LaunchWithNoLaunchData() {
// This method is required as an entry point on the UI thread.
LaunchPlatformAppWithNoData(profile_, extension_);
@@ -223,7 +270,7 @@ class PlatformAppPathLauncher
fileapi::IsolatedContext::GetInstance();
DCHECK(isolated_context);
std::string filesystem_id = isolated_context->RegisterFileSystemForPath(
- fileapi::kFileSystemTypeNativeLocal, file_path_, &registered_name);
+ fileapi::kFileSystemTypeExternalFullPath, file_path_, &registered_name);
// Granting read file system permission as well to allow file-system
// read operations.
policy->GrantReadFileSystem(renderer_id, filesystem_id);

Powered by Google App Engine
This is Rietveld 408576698