Chromium Code Reviews| 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 78548d843f1770c1da2402e30cb077b8a1116dac..fa78dbc7b833f3fbaab3321d1b560cc2243d24da 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() { |
|
benwells
2013/03/04 01:27:39
Can this run on any thread? It is currently on UI,
tbarzic
2013/03/06 01:45:10
It _must_ run on UI thread, added DCHECK.
|
| + 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, |
|
benwells
2013/03/04 01:27:39
Same question here about threads. This file is pre
tbarzic
2013/03/06 01:45:10
Done.
|
| + 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_, ®istered_name); |
| + file_system_type_, file_path_, ®istered_name); |
|
benwells
2013/03/04 01:27:39
There will need to be a similar type of addition t
tbarzic
2013/03/06 01:45:10
yes, I know.. or fileapi layer should be changed s
kinaba
2013/03/06 02:00:42
I feel it a little strange that the client code of
tbarzic
2013/03/06 02:13:00
yeah, I agree, that's the biggest issue I have wit
|
| // 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_; |