Chromium Code Reviews| Index: chrome/browser/extensions/api/runtime/runtime_api.cc |
| diff --git a/chrome/browser/extensions/api/runtime/runtime_api.cc b/chrome/browser/extensions/api/runtime/runtime_api.cc |
| index fd3a34311fc1e859cffea56dbc4f6497de9be92a..c0aa4cff2ecb0918f04ee3dcee94e4bad89853eb 100644 |
| --- a/chrome/browser/extensions/api/runtime/runtime_api.cc |
| +++ b/chrome/browser/extensions/api/runtime/runtime_api.cc |
| @@ -22,8 +22,12 @@ |
| #include "chrome/common/extensions/background_info.h" |
| #include "chrome/common/extensions/extension.h" |
| #include "chrome/common/omaha_query_params/omaha_query_params.h" |
| +#include "content/public/browser/child_process_security_policy.h" |
| +#include "content/public/browser/render_process_host.h" |
| +#include "content/public/browser/render_view_host.h" |
| #include "extensions/common/error_utils.h" |
| #include "googleurl/src/gurl.h" |
| +#include "webkit/browser/fileapi/isolated_context.h" |
| namespace GetPlatformInfo = extensions::api::runtime::GetPlatformInfo; |
| @@ -52,6 +56,9 @@ const char kUpdateThrottled[] = "throttled"; |
| // A preference key storing the url loaded when an extension is uninstalled. |
| const char kUninstallUrl[] = "uninstall_url"; |
| +// The name of the directory to be returned by getPackageDirectoryEntry. |
| +const char kPackageDirectoryPath[] = "crxfs"; |
|
benwells
2013/06/11 03:14:51
If I'm reading this correctly, this could be anyth
Sam McNally
2013/06/11 06:00:29
Done.
|
| + |
| static void DispatchOnStartupEventImpl( |
| Profile* profile, |
| const std::string& extension_id, |
| @@ -380,4 +387,29 @@ bool RuntimeGetPlatformInfoFunction::RunImpl() { |
| return true; |
| } |
| +bool RuntimeGetPackageDirectoryEntryFunction::RunImpl() { |
| + fileapi::IsolatedContext* isolated_context = |
| + fileapi::IsolatedContext::GetInstance(); |
| + DCHECK(isolated_context); |
| + |
| + std::string relative_path = kPackageDirectoryPath; |
| + base::FilePath path = extension_->path(); |
| + std::string filesystem_id = isolated_context->RegisterFileSystemForPath( |
| + fileapi::kFileSystemTypeNativeLocal, path, &relative_path); |
| + |
| + int renderer_id = render_view_host_->GetProcess()->GetID(); |
| + content::ChildProcessSecurityPolicy* policy = |
| + content::ChildProcessSecurityPolicy::GetInstance(); |
| + policy->GrantReadFileSystem(renderer_id, filesystem_id); |
| + |
| + if (!policy->CanReadFile(renderer_id, path)) |
| + policy->GrantReadFile(renderer_id, path); |
| + |
| + DictionaryValue* dict = new DictionaryValue(); |
| + SetResult(dict); |
| + dict->SetString("fileSystemId", filesystem_id); |
| + dict->SetString("baseName", relative_path); |
| + return true; |
| +} |
| + |
| } // namespace extensions |