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 3af7454a25ab3221dd2d1fa85cb3c01c7a13e6af..2902bfc29069b2b82d85ff41c08fe49d3b853da4 100644 |
| --- a/chrome/browser/extensions/platform_app_launcher.cc |
| +++ b/chrome/browser/extensions/platform_app_launcher.cc |
| @@ -231,12 +231,12 @@ class PlatformAppCommandLineLauncher |
| // instances is managed by reference counted pointers. As long as an instance |
| // has outstanding tasks on a message queue it will be retained; once all |
| // outstanding tasks are completed it will be deleted. |
| -class PlatformAppBlobIntentLauncher |
| - : public base::RefCountedThreadSafe<PlatformAppBlobIntentLauncher> { |
| +class PlatformAppGrantIntentLauncher |
|
James Hawkins
2012/08/29 22:46:51
I don't understand the name of this class, specifi
thorogood
2012/08/30 01:36:28
After some discussion here in Sydney, we've change
|
| + : public base::RefCountedThreadSafe<PlatformAppGrantIntentLauncher> { |
| public: |
| - PlatformAppBlobIntentLauncher(Profile* profile, |
| - const Extension* extension, |
| - const webkit_glue::WebIntentData& data) |
| + PlatformAppGrantIntentLauncher(Profile* profile, |
| + const Extension* extension, |
| + const webkit_glue::WebIntentData& data) |
| : profile_(profile), |
| extension_(extension), |
| data_(data) {} |
| @@ -253,7 +253,7 @@ class PlatformAppBlobIntentLauncher |
| ExtensionSystem::Get(profile_)->lazy_background_task_queue(); |
| if (queue->ShouldEnqueueTask(profile_, extension_)) { |
| queue->AddPendingTask(profile_, extension_->id(), base::Bind( |
| - &PlatformAppBlobIntentLauncher::GrantAccessToFileAndLaunch, |
| + &PlatformAppGrantIntentLauncher::GrantAccessToFileAndLaunch, |
| this)); |
| return; |
| } |
| @@ -267,9 +267,9 @@ class PlatformAppBlobIntentLauncher |
| } |
| private: |
| - friend class base::RefCountedThreadSafe<PlatformAppBlobIntentLauncher>; |
| + friend class base::RefCountedThreadSafe<PlatformAppGrantIntentLauncher>; |
| - virtual ~PlatformAppBlobIntentLauncher() {} |
| + virtual ~PlatformAppGrantIntentLauncher() {} |
| void GrantAccessToFileAndLaunch(extensions::ExtensionHost* host) { |
| // If there was an error loading the app page, |host| will be NULL. |
| @@ -282,12 +282,27 @@ class PlatformAppBlobIntentLauncher |
| content::ChildProcessSecurityPolicy::GetInstance(); |
| int renderer_id = host->render_process_host()->GetID(); |
| - // Granting read file permission to allow reading file content. |
| - // If the renderer already has permission to read these paths, it is not |
| - // regranted, as this would overwrite any other permissions which the |
| - // renderer may already have. |
| - if (!policy->CanReadFile(renderer_id, data_.blob_file)) |
| - policy->GrantReadFile(renderer_id, data_.blob_file); |
| + if (data_.data_type == webkit_glue::WebIntentData::BLOB) { |
| + // Granting read file permission to allow reading file content. |
| + // If the renderer already has permission to read these paths, it is not |
| + // regranted, as this would overwrite any other permissions which the |
| + // renderer may already have. |
| + if (!policy->CanReadFile(renderer_id, data_.blob_file)) |
| + policy->GrantReadFile(renderer_id, data_.blob_file); |
| + } else if (data_.data_type == webkit_glue::WebIntentData::FILESYSTEM) { |
| + // Grant read filesystem and read directory permission to allow reading |
| + // any part of the specified filesystem. |
| + FilePath path; |
| + const bool valid = |
| + fileapi::IsolatedContext::GetInstance()->GetRegisteredPath( |
| + data_.filesystem_id, &path); |
| + DCHECK(valid); |
| + if (!policy->CanReadFile(renderer_id, path)) |
| + policy->GrantReadFile(renderer_id, path); |
| + policy->GrantReadFileSystem(renderer_id, data_.filesystem_id); |
| + } else { |
| + NOTREACHED(); |
| + } |
| extensions::AppEventRouter::DispatchOnLaunchedEventWithWebIntent( |
| profile_, extension_, data_); |
| @@ -300,7 +315,7 @@ class PlatformAppBlobIntentLauncher |
| // The WebIntent data to be passed through to the app. |
| const webkit_glue::WebIntentData data_; |
| - DISALLOW_COPY_AND_ASSIGN(PlatformAppBlobIntentLauncher); |
| + DISALLOW_COPY_AND_ASSIGN(PlatformAppGrantIntentLauncher); |
| }; |
| } // namespace |
| @@ -322,9 +337,10 @@ void LaunchPlatformAppWithWebIntent( |
| Profile* profile, |
| const Extension* extension, |
| const webkit_glue::WebIntentData& web_intent_data) { |
| - if (web_intent_data.data_type == webkit_glue::WebIntentData::BLOB) { |
| - scoped_refptr<PlatformAppBlobIntentLauncher> launcher = |
| - new PlatformAppBlobIntentLauncher(profile, extension, web_intent_data); |
| + if (web_intent_data.data_type == webkit_glue::WebIntentData::BLOB || |
| + web_intent_data.data_type == webkit_glue::WebIntentData::FILESYSTEM) { |
| + scoped_refptr<PlatformAppGrantIntentLauncher> launcher = |
| + new PlatformAppGrantIntentLauncher(profile, extension, web_intent_data); |
| launcher->Launch(); |
| return; |
| } |