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..b4064bf9addfce9fe184ce3260289979c43e17bd 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,8 @@ class PlatformAppPathLauncher |
fileapi::IsolatedContext::GetInstance(); |
DCHECK(isolated_context); |
std::string filesystem_id = isolated_context->RegisterFileSystemForPath( |
- fileapi::kFileSystemTypeNativeLocal, file_path_, ®istered_name); |
+ fileapi::kFileSystemTypeNativeForPlatformApp, file_path_, |
+ ®istered_name); |
// Granting read file system permission as well to allow file-system |
// read operations. |
policy->GrantReadFileSystem(renderer_id, filesystem_id); |