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

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: go 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // 54 //
55 // So, define it manually, and let the getIsInstalled function act as its 55 // So, define it manually, and let the getIsInstalled function act as its
56 // documentation. 56 // documentation.
57 if (!extensionId) 57 if (!extensionId)
58 app.__defineGetter__('isInstalled', appNatives.GetIsInstalled); 58 app.__defineGetter__('isInstalled', appNatives.GetIsInstalled);
59 else 59 else
60 app.__defineGetter__('isInstalled', 60 app.__defineGetter__('isInstalled',
61 wrapForLogging(appNatives.GetIsInstalled)); 61 wrapForLogging(appNatives.GetIsInstalled));
62 62
63 // Called by app_bindings.cc. 63 // Called by app_bindings.cc.
64 // This becomes chromeHidden.app 64 function onInstallStateResponse(state, callbackId) {
65 var chromeHiddenApp = { 65 var callback = callbacks[callbackId];
66 onInstallStateResponse: function(state, callbackId) { 66 delete callbacks[callbackId];
67 if (callbackId) { 67 if (callback)
68 callbacks[callbackId](state); 68 callback(state);
69 delete callbacks[callbackId]; 69 }
70 }
71 }
72 };
73 70
74 // TODO(kalman): move this stuff to its own custom bindings. 71 // TODO(kalman): move this stuff to its own custom bindings.
75 var callbacks = {}; 72 var callbacks = {};
76 var nextCallbackId = 1; 73 var nextCallbackId = 1;
77 74
78 app.installState = function getInstallState(callback) { 75 app.installState = function getInstallState(callback) {
79 var callbackId = nextCallbackId++; 76 var callbackId = nextCallbackId++;
80 callbacks[callbackId] = callback; 77 callbacks[callbackId] = callback;
81 appNatives.GetInstallState(callbackId); 78 appNatives.GetInstallState(callbackId);
82 }; 79 };
83 if (extensionId) 80 if (extensionId)
84 app.installState = wrapForLogging(app.installState); 81 app.installState = wrapForLogging(app.installState);
85 82
86 // These must match the names in InstallAppbinding() in 83 // This must match InstallAppBindings() in
87 // chrome/renderer/extensions/dispatcher.cc. 84 // chrome/renderer/extensions/dispatcher.cc.
88 exports.chromeApp = app; 85 exports.chromeApp = app;
89 exports.chromeHiddenApp = chromeHiddenApp; 86 exports.onInstallStateResponse = onInstallStateResponse;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698