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

Unified Diff: chrome/browser/extensions/platform_app_launcher.cc

Issue 10869067: Deliver attach intent to packaged apps (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixes build error -- oops Created 8 years, 4 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 e28f6be277eaa99fb63e5739daac758200587bd6..a208d89945370d6baa86b61764c860adbf9f9396 100644
--- a/chrome/browser/extensions/platform_app_launcher.cc
+++ b/chrome/browser/extensions/platform_app_launcher.cc
@@ -225,39 +225,42 @@ class PlatformAppCommandLineLauncher
DISALLOW_COPY_AND_ASSIGN(PlatformAppCommandLineLauncher);
};
-// Class to handle launching of platform apps with WebIntent data that is being
-// passed in a a blob.
+// Class to handle launching of platform apps with WebIntent data.
// An instance of this class is created for each launch. The lifetime of these
// 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 PlatformAppWebIntentLauncher
+ : public base::RefCountedThreadSafe<PlatformAppWebIntentLauncher> {
public:
- PlatformAppBlobIntentLauncher(Profile* profile,
- const Extension* extension,
- const webkit_glue::WebIntentData& data)
+ PlatformAppWebIntentLauncher(Profile* profile,
+ const Extension* extension,
+ const webkit_glue::WebIntentData& data)
: profile_(profile),
extension_(extension),
data_(data) {}
void Launch() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (data_.data_type != webkit_glue::WebIntentData::BLOB &&
+ data_.data_type != webkit_glue::WebIntentData::FILESYSTEM) {
+ InternalLaunch();
+ return;
+ }
- // Access needs to be granted to the file for the process associated with
- // the extension. To do this the ExtensionHost is needed. This might not be
- // available, or it might be in the process of being unloaded, in which case
- // the lazy background task queue is used to load the extension and then
- // call back to us.
+ // Access needs to be granted to the file or filesystem for the process
+ // associated with the extension. To do this the ExtensionHost is needed.
+ // This might not be available, or it might be in the process of being
+ // unloaded, in which case the lazy background task queue is used to load
+ // he extension and then call back to us.
extensions::LazyBackgroundTaskQueue* queue =
ExtensionSystem::Get(profile_)->lazy_background_task_queue();
if (queue->ShouldEnqueueTask(profile_, extension_)) {
queue->AddPendingTask(profile_, extension_->id(), base::Bind(
- &PlatformAppBlobIntentLauncher::GrantAccessToFileAndLaunch,
+ &PlatformAppWebIntentLauncher::GrantAccessToFileAndLaunch,
this));
return;
}
-
ExtensionProcessManager* process_manager =
ExtensionSystem::Get(profile_)->process_manager();
extensions::ExtensionHost* host =
@@ -267,9 +270,9 @@ class PlatformAppBlobIntentLauncher
}
private:
- friend class base::RefCountedThreadSafe<PlatformAppBlobIntentLauncher>;
+ friend class base::RefCountedThreadSafe<PlatformAppWebIntentLauncher>;
- virtual ~PlatformAppBlobIntentLauncher() {}
+ virtual ~PlatformAppWebIntentLauncher() {}
void GrantAccessToFileAndLaunch(extensions::ExtensionHost* host) {
// If there was an error loading the app page, |host| will be NULL.
@@ -282,13 +285,31 @@ 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();
+ }
+ InternalLaunch();
+ }
+ void InternalLaunch() {
extensions::AppEventRouter::DispatchOnLaunchedEventWithWebIntent(
profile_, extension_, data_);
}
@@ -300,7 +321,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(PlatformAppWebIntentLauncher);
};
} // namespace
@@ -322,15 +343,9 @@ 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);
- launcher->Launch();
- return;
- }
-
- extensions::AppEventRouter::DispatchOnLaunchedEventWithWebIntent(
- profile, extension, web_intent_data);
+ scoped_refptr<PlatformAppWebIntentLauncher> launcher =
+ new PlatformAppWebIntentLauncher(profile, extension, web_intent_data);
+ launcher->Launch();
}
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/api/app_runtime/app_runtime_api.cc ('k') | chrome/renderer/extensions/file_system_natives.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698