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

Side by Side Diff: chrome/renderer/resources/extensions/app_custom_bindings.js

Issue 15855010: Make ExtensionMsg_MessageInvoke run a module system function rather than a (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test compile Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Custom binding for the app API. 5 // Custom binding for the app API.
6 6
7 var GetAvailability = requireNative('v8_context').GetAvailability; 7 var GetAvailability = requireNative('v8_context').GetAvailability;
8 if (!GetAvailability('app').is_available) { 8 if (!GetAvailability('app').is_available) {
9 exports.chromeApp = {}; 9 exports.chromeApp = {};
10 exports.chromeHiddenApp = {}; 10 exports.onInstallStateResponse = function(){};
11 return; 11 return;
12 } 12 }
13 13
14 var appNatives = requireNative('app'); 14 var appNatives = requireNative('app');
15 var chrome = requireNative('chrome').GetChrome(); 15 var chrome = requireNative('chrome').GetChrome();
16 var process = requireNative('process'); 16 var process = requireNative('process');
17 var extensionId = process.GetExtensionId(); 17 var extensionId = process.GetExtensionId();
18 var logActivity = requireNative('activityLogger'); 18 var logActivity = requireNative('activityLogger');
19 19
20 function wrapForLogging(fun) { 20 function wrapForLogging(fun) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // 52 //
53 // So, define it manually, and let the getIsInstalled function act as its 53 // So, define it manually, and let the getIsInstalled function act as its
54 // documentation. 54 // documentation.
55 if (!extensionId) 55 if (!extensionId)
56 app.__defineGetter__('isInstalled', appNatives.GetIsInstalled); 56 app.__defineGetter__('isInstalled', appNatives.GetIsInstalled);
57 else 57 else
58 app.__defineGetter__('isInstalled', 58 app.__defineGetter__('isInstalled',
59 wrapForLogging(appNatives.GetIsInstalled)); 59 wrapForLogging(appNatives.GetIsInstalled));
60 60
61 // Called by app_bindings.cc. 61 // Called by app_bindings.cc.
62 // This becomes chromeHidden.app 62 function onInstallStateResponse(state, callbackId) {
63 var chromeHiddenApp = { 63 var callback = callbacks[callbackId];
64 onInstallStateResponse: function(state, callbackId) { 64 delete callbacks[callbackId];
65 if (callbackId) { 65 if (typeof(callback) == 'function')
66 callbacks[callbackId](state); 66 callback(state);
67 delete callbacks[callbackId]; 67 }
68 }
69 }
70 };
71 68
72 // TODO(kalman): move this stuff to its own custom bindings. 69 // TODO(kalman): move this stuff to its own custom bindings.
73 var callbacks = {}; 70 var callbacks = {};
74 var nextCallbackId = 1; 71 var nextCallbackId = 1;
75 72
76 app.installState = function getInstallState(callback) { 73 app.installState = function getInstallState(callback) {
77 var callbackId = nextCallbackId++; 74 var callbackId = nextCallbackId++;
78 callbacks[callbackId] = callback; 75 callbacks[callbackId] = callback;
79 appNatives.GetInstallState(callbackId); 76 appNatives.GetInstallState(callbackId);
80 }; 77 };
81 if (extensionId) 78 if (extensionId)
82 app.installState = wrapForLogging(app.installState); 79 app.installState = wrapForLogging(app.installState);
83 80
84 // These must match the names in InstallAppbinding() in 81 // This must match InstallAppBindings() in
85 // chrome/renderer/extensions/dispatcher.cc. 82 // chrome/renderer/extensions/dispatcher.cc.
86 exports.chromeApp = app; 83 exports.chromeApp = app;
87 exports.chromeHiddenApp = chromeHiddenApp; 84 exports.onInstallStateResponse = onInstallStateResponse;
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/webstore_bindings.cc ('k') | chrome/renderer/resources/extensions/app_window_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698