Commit 8e432c7f authored by asargent@chromium.org's avatar asargent@chromium.org

Whitelist the fileSystem.write API for an internally developed extension

BUG=179010

Review URL: https://chromiumcodereview.appspot.com/13473016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192867 0039d316-1c4b-4281-b951-d872f2087c98
parent 1c5499cd
...@@ -485,21 +485,31 @@ bool FileSystemChooseEntryFunction::ShowPicker( ...@@ -485,21 +485,31 @@ bool FileSystemChooseEntryFunction::ShowPicker(
const ui::SelectFileDialog::FileTypeInfo& file_type_info, const ui::SelectFileDialog::FileTypeInfo& file_type_info,
ui::SelectFileDialog::Type picker_type, ui::SelectFileDialog::Type picker_type,
EntryType entry_type) { EntryType entry_type) {
ShellWindowRegistry* registry = ShellWindowRegistry::Get(profile()); // TODO(asargent/benwells) - As a short term remediation for crbug.com/179010
DCHECK(registry); // we're adding the ability for a whitelisted extension to use this API since
ShellWindow* shell_window = registry->GetShellWindowForRenderViewHost( // chrome.fileBrowserHandler.selectFile is ChromeOS-only. Eventually we'd
render_view_host()); // like a better solution and likely this code will go back to being
if (!shell_window) { // platform-app only.
error_ = kInvalidCallingPage; content::WebContents* web_contents = NULL;
return false; if (extension_->is_platform_app()) {
ShellWindowRegistry* registry = ShellWindowRegistry::Get(profile());
DCHECK(registry);
ShellWindow* shell_window = registry->GetShellWindowForRenderViewHost(
render_view_host());
if (!shell_window) {
error_ = kInvalidCallingPage;
return false;
}
web_contents = shell_window->web_contents();
} else {
web_contents = GetAssociatedWebContents();
} }
// The file picker will hold a reference to this function instance, preventing // The file picker will hold a reference to this function instance, preventing
// its destruction (and subsequent sending of the function response) until the // its destruction (and subsequent sending of the function response) until the
// user has selected a file or cancelled the picker. At that point, the picker // user has selected a file or cancelled the picker. At that point, the picker
// will delete itself, which will also free the function instance. // will delete itself, which will also free the function instance.
new FilePicker(this, shell_window->web_contents(), suggested_name, new FilePicker(this, web_contents, suggested_name, file_type_info,
file_type_info, picker_type, entry_type); picker_type, entry_type);
return true; return true;
} }
......
...@@ -167,14 +167,22 @@ ...@@ -167,14 +167,22 @@
"extension_types": ["extension", "packaged_app"], "extension_types": ["extension", "packaged_app"],
"location": "component" "location": "component"
}, },
"fileSystem": { "fileSystem": [{
"channel": "stable", "channel": "stable",
"extension_types": ["platform_app"] "extension_types": ["platform_app"]
}, },{
"fileSystem.write": { "channel": "stable",
"extension_types": ["extension"],
"whitelist": [ "2FC374607C2DF285634B67C64A2E356C607091C3" ]
}],
"fileSystem.write": [{
"channel": "stable", "channel": "stable",
"extension_types": ["platform_app"] "extension_types": ["platform_app"]
}, },{
"channel": "stable",
"extension_types": ["extension"],
"whitelist": [ "2FC374607C2DF285634B67C64A2E356C607091C3" ]
}],
"fontSettings": { "fontSettings": {
"channel": "stable", "channel": "stable",
"extension_types": ["extension", "packaged_app"] "extension_types": ["extension", "packaged_app"]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment