diff options
author | sammc@chromium.org <sammc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-29 10:02:25 +0000 |
---|---|---|
committer | sammc@chromium.org <sammc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-29 10:02:25 +0000 |
commit | ffb8706267743f92faa5314e1e61c7c76c65e0dd (patch) | |
tree | 4aa4841c888e7fb0a518850d9b383506a693b75e /apps/launcher.cc | |
parent | a39dcb42c9cc46fa6598744d043f3461c542d967 (diff) | |
download | chromium_src-ffb8706267743f92faa5314e1e61c7c76c65e0dd.zip chromium_src-ffb8706267743f92faa5314e1e61c7c76c65e0dd.tar.gz chromium_src-ffb8706267743f92faa5314e1e61c7c76c65e0dd.tar.bz2 |
Use only app permissions to decide if file entries should be writable.
Previously, apps with the fileSystem.write permission could choose to
obtain read-only files and file entries provided as launch data were
always read-only.
With this change, all file entries obtained using the chrome.fileSystem
API or provided as launch data are writable, for apps with the
fileSystem.write permission.
This makes getWritableEntry unnecessary, other than for files obtained
through other means (e.g., drag and drop).
BUG=148486
Review URL: https://chromiumcodereview.appspot.com/23202006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220254 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps/launcher.cc')
-rw-r--r-- | apps/launcher.cc | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/apps/launcher.cc b/apps/launcher.cc index e5990a5..d3bc43c 100644 --- a/apps/launcher.cc +++ b/apps/launcher.cc @@ -46,11 +46,13 @@ namespace app_runtime = extensions::api::app_runtime; using content::BrowserThread; +using extensions::app_file_handler_util::CheckWritableFiles; using extensions::app_file_handler_util::FileHandlerForId; using extensions::app_file_handler_util::FileHandlerCanHandleFile; using extensions::app_file_handler_util::FirstFileHandlerForFile; using extensions::app_file_handler_util::CreateFileEntry; using extensions::app_file_handler_util::GrantedFileEntry; +using extensions::app_file_handler_util::HasFileSystemWritePermission; using extensions::Extension; using extensions::ExtensionHost; using extensions::ExtensionSystem; @@ -125,15 +127,18 @@ class PlatformAppPathLauncher DCHECK(file_path_.IsAbsolute()); -#if defined(OS_CHROMEOS) - if (drive::util::IsUnderDriveMountPoint(file_path_)) { - GetMimeTypeAndLaunchForDriveFile(); + if (HasFileSystemWritePermission(extension_)) { + std::vector<base::FilePath> paths; + paths.push_back(file_path_); + CheckWritableFiles( + paths, + profile_, + base::Bind(&PlatformAppPathLauncher::OnFileValid, this), + base::Bind(&PlatformAppPathLauncher::OnFileInvalid, this)); return; } -#endif - BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind( - &PlatformAppPathLauncher::GetMimeTypeAndLaunch, this)); + OnFileValid(); } void LaunchWithHandler(const std::string& handler_id) { @@ -146,6 +151,24 @@ class PlatformAppPathLauncher virtual ~PlatformAppPathLauncher() {} + void OnFileValid() { +#if defined(OS_CHROMEOS) + if (drive::util::IsUnderDriveMountPoint(file_path_)) { + PlatformAppPathLauncher::GetMimeTypeAndLaunchForDriveFile(); + return; + } +#endif + + BrowserThread::PostTask( + BrowserThread::FILE, + FROM_HERE, + base::Bind(&PlatformAppPathLauncher::GetMimeTypeAndLaunch, this)); + } + + void OnFileInvalid(const base::FilePath& /* error_path */) { + LaunchWithNoLaunchData(); + } + void GetMimeTypeAndLaunch() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); @@ -261,11 +284,7 @@ class PlatformAppPathLauncher } GrantedFileEntry file_entry = CreateFileEntry( - profile_, - extension_->id(), - host->render_process_host()->GetID(), - file_path_, - false); + profile_, extension_, host->render_process_host()->GetID(), file_path_); extensions::AppEventRouter::DispatchOnLaunchedEventWithFileEntry( profile_, extension_, handler_id_, mime_type, file_entry); } |