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

Unified Diff: chrome/browser/extensions/api/file_system/file_system_api.cc

Issue 13473016: Whitelist the fileSystem.write API for an internally developed extension (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge from trunk Created 7 years, 8 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
« no previous file with comments | « no previous file | chrome/common/extensions/api/_permission_features.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/file_system/file_system_api.cc
diff --git a/chrome/browser/extensions/api/file_system/file_system_api.cc b/chrome/browser/extensions/api/file_system/file_system_api.cc
index 7e2a29a5a72e9f8fd45f7f290f0910ce455231ef..3bb588ae564d0d71af24d7dfb7a37850594c7dda 100644
--- a/chrome/browser/extensions/api/file_system/file_system_api.cc
+++ b/chrome/browser/extensions/api/file_system/file_system_api.cc
@@ -485,21 +485,31 @@ bool FileSystemChooseEntryFunction::ShowPicker(
const ui::SelectFileDialog::FileTypeInfo& file_type_info,
ui::SelectFileDialog::Type picker_type,
EntryType entry_type) {
- ShellWindowRegistry* registry = ShellWindowRegistry::Get(profile());
- DCHECK(registry);
- ShellWindow* shell_window = registry->GetShellWindowForRenderViewHost(
- render_view_host());
- if (!shell_window) {
- error_ = kInvalidCallingPage;
- return false;
+ // TODO(asargent/benwells) - As a short term remediation for crbug.com/179010
+ // we're adding the ability for a whitelisted extension to use this API since
+ // chrome.fileBrowserHandler.selectFile is ChromeOS-only. Eventually we'd
+ // like a better solution and likely this code will go back to being
+ // platform-app only.
+ content::WebContents* web_contents = NULL;
+ 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
// 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
// will delete itself, which will also free the function instance.
- new FilePicker(this, shell_window->web_contents(), suggested_name,
- file_type_info, picker_type, entry_type);
+ new FilePicker(this, web_contents, suggested_name, file_type_info,
+ picker_type, entry_type);
return true;
}
« no previous file with comments | « no previous file | chrome/common/extensions/api/_permission_features.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698