Chromium Code Reviews| Index: chrome/renderer/resources/extensions/experimental.app_custom_bindings.js |
| diff --git a/chrome/renderer/resources/extensions/experimental.app_custom_bindings.js b/chrome/renderer/resources/extensions/experimental.app_custom_bindings.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2f9b4b1ac20d03ab964625aa33477afb997cac2a |
| --- /dev/null |
| +++ b/chrome/renderer/resources/extensions/experimental.app_custom_bindings.js |
| @@ -0,0 +1,34 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// Custom bindings for the experimental.app API. |
| + |
| +var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
| +var experimentalAppNatives = requireNative('experimental_app'); |
| +var GetIsolatedFileSystem = experimentalAppNatives.GetIsolatedFileSystem; |
| + |
| +chromeHidden.registerCustomHook('experimental.app', function(bindingsAPI) { |
| + chrome.experimental.app.onLaunched.dispatch = |
| + function(launchData, file_system_id, base_name) { |
|
Mihai Parparita -not on Chrome
2012/05/18 04:26:04
Nit: JS naming style is to use camelCase for varia
benwells
2012/05/22 13:15:03
Done.
|
| + if (launchData) { |
| + event = this; |
| + fs = GetIsolatedFileSystem(file_system_id); |
| + try { |
| + fs.root.getFile(base_name, {}, function(fileEntry) { |
| + launchData.intent.data = fileEntry; |
| + launchData.intent.postResult = function() {}; |
| + chrome.Event.prototype.dispatch.apply(event, [launchData]); |
|
Mihai Parparita -not on Chrome
2012/05/18 04:26:04
Nit: if you use .call(), you can pass the argument
benwells
2012/05/22 13:15:03
Done.
|
| + }, function(fileError) { |
| + console.error('Error getting fileEntry, code: ' + fileError.code); |
| + chrome.Event.prototype.dispatch.apply(event, []); |
| + }); |
| + } catch (e) { |
| + console.error('Error in event handler for onLaunched: ' + e.stack); |
| + chrome.Event.prototype.dispatch.apply(event, []); |
| + } |
| + } else { |
| + chrome.Event.prototype.dispatch.apply(this, []); |
| + } |
| + }; |
| +}); |