diff options
author | benwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-11 00:25:13 +0000 |
---|---|---|
committer | benwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-11 00:25:13 +0000 |
commit | 82d853071581f40c48f22c99e5819ab2cfae05c0 (patch) | |
tree | f2d68b2f331491c0195a6fe2512560cdcb3b73a6 | |
parent | 175dedc6a4a0f1bf7a6447dfb4acd38bf2777cad (diff) | |
download | chromium_src-82d853071581f40c48f22c99e5819ab2cfae05c0.zip chromium_src-82d853071581f40c48f22c99e5819ab2cfae05c0.tar.gz chromium_src-82d853071581f40c48f22c99e5819ab2cfae05c0.tar.bz2 |
Merge 203556 "Fix a crash when loading the fileSystem API from a..."
> Fix a crash when loading the fileSystem API from an extension.
>
> This works around an issue where there is no background page by treating
> the current page as the background page if no background page is loaded,
> which only occurs some of the time with extensions and never with apps.
> It also postpones requiring entryIdManager until the background page's
> fileSystem API is loaded so it can always safely requireNative the
> background page's file_system_natives.
>
> BUG=243709,242157
>
> Review URL: https://chromiumcodereview.appspot.com/16253002
TBR=sammc@chromium.org
Review URL: https://codereview.chromium.org/16663004
git-svn-id: svn://svn.chromium.org/chrome/branches/1500/src@205357 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/renderer/resources/extensions/file_system_custom_bindings.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/chrome/renderer/resources/extensions/file_system_custom_bindings.js b/chrome/renderer/resources/extensions/file_system_custom_bindings.js index 8df8200..9424027 100644 --- a/chrome/renderer/resources/extensions/file_system_custom_bindings.js +++ b/chrome/renderer/resources/extensions/file_system_custom_bindings.js @@ -14,9 +14,9 @@ var GetModuleSystem = requireNative('v8_context').GetModuleSystem; // TODO(sammc): Don't require extension. See http://crbug.com/235689. var GetExtensionViews = requireNative('extension').GetExtensionViews; -var backgroundPage = GetExtensionViews(-1, 'BACKGROUND')[0]; +// Fallback to using the current window if no background page is running. +var backgroundPage = GetExtensionViews(-1, 'BACKGROUND')[0] || window; var backgroundPageModuleSystem = GetModuleSystem(backgroundPage); -var entryIdManager = backgroundPageModuleSystem.require('entryIdManager'); // All windows use the bindFileEntryCallback from the background page so their // FileEntry objects have the background page's context as their own. This @@ -57,6 +57,7 @@ if (window == backgroundPage) { } }); }; + var entryIdManager = require('entryIdManager'); } else { // Force the fileSystem API to be loaded in the background page. Using // backgroundPageModuleSystem.require('fileSystem') is insufficient as @@ -64,6 +65,7 @@ if (window == backgroundPage) { backgroundPage.chrome.fileSystem; var bindFileEntryCallback = backgroundPageModuleSystem.require( 'fileSystem').bindFileEntryCallback; + var entryIdManager = backgroundPageModuleSystem.require('entryIdManager'); } binding.registerCustomHook(function(bindingsAPI) { |