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

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, 10 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 85274764a9b7ada6f5001b59678ba8a98cfde2f0..d60559341e935e1ee919bef5179d2619f9caa7d2 100644
--- a/chrome/browser/extensions/platform_app_launcher.cc
+++ b/chrome/browser/extensions/platform_app_launcher.cc
@@ -29,6 +29,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;
@@ -92,6 +99,7 @@ class PlatformAppPathLauncher
: profile_(profile),
extension_(extension),
file_path_(file_path),
+ file_system_type_(fileapi::kFileSystemTypeUnknown),
handler_id_("") {}
void Launch() {
@@ -102,6 +110,14 @@ class PlatformAppPathLauncher
}
DCHECK(file_path_.IsAbsolute());
+#if defined(OS_CHROMEOS)
+ if (drive::util::IsUnderDriveMountPoint(file_path_)) {
+ file_system_type_ = fileapi::kFileSystemTypeDrive;
+ GetMimeTypeAndLaunchForDriveFile();
+ return;
+ }
+#endif
+ file_system_type_ = fileapi::kFileSystemTypeNativeLocal;
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind(
&PlatformAppPathLauncher::GetMimeTypeAndLaunch, this));
}
@@ -141,6 +157,33 @@ class PlatformAppPathLauncher
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
&PlatformAppPathLauncher::LaunchWithMimeType, this, mime_type));
}
+#if defined(OS_CHROMEOS)
+ void GetMimeTypeAndLaunchForDriveFile() {
+ 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) {
+ 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.
@@ -217,7 +260,7 @@ class PlatformAppPathLauncher
fileapi::IsolatedContext::GetInstance();
DCHECK(isolated_context);
std::string filesystem_id = isolated_context->RegisterFileSystemForPath(
- fileapi::kFileSystemTypeNativeLocal, file_path_, &registered_name);
+ file_system_type_, file_path_, &registered_name);
// Granting read file system permission as well to allow file-system
// read operations.
policy->GrantReadFileSystem(renderer_id, filesystem_id);
@@ -233,6 +276,8 @@ class PlatformAppPathLauncher
const Extension* extension_;
// The path to be passed through to the app.
const base::FilePath file_path_;
+ // The file system type for the path passed through to the app.
+ fileapi::FileSystemType file_system_type_;
// The ID of the file handler used to launch the app.
std::string handler_id_;

Powered by Google App Engine
This is Rietveld 408576698