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

Unified Diff: remoting/webapp/js_proto/chrome_proto.js

Issue 450383003: Hangout remote desktop part II - background.html and AppLauncher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
Index: remoting/webapp/js_proto/chrome_proto.js
diff --git a/remoting/webapp/js_proto/chrome_proto.js b/remoting/webapp/js_proto/chrome_proto.js
index f7b9a6f738590dbbfe5856bb1445b5b87f9c95b2..25c2455ab4eaa1b187189afc26ca8dd4d180af59 100644
--- a/remoting/webapp/js_proto/chrome_proto.js
+++ b/remoting/webapp/js_proto/chrome_proto.js
@@ -9,6 +9,33 @@
/** @type {Object} */
var chrome = {};
+/** @constructor */
+chrome.Event = function() {
+ this.listeners_ = [];
+};
+
+/** @param {Function} callback */
+chrome.Event.prototype.addListener = function(callback) {
+ this.listeners_.push(callback);
kelvinp 2014/08/11 18:37:56 I provide a simple implementation of chrome.events
Jamie 2014/08/12 02:24:59 Yes, please do that. Files under js_proto/ should
+};
+
+/** @param {Function} callback */
+chrome.Event.prototype.removeListener = function(callback) {
+ for (var i = 0; i < this.listeners_.length; i++) {
+ if (this.listeners_[i] === callback) {
+ this.listeners_.splice(i, 1);
+ break;
+ }
+ }
+};
+
+ /** @param {*=} data */
+chrome.Event.prototype.mock$fire = function(data) {
+ /** @param {Function} listener */
+ this.listeners_.forEach(function(listener){
+ listener(data);
+ });
+};
/** @type {Object} */
chrome.app = {};
@@ -31,7 +58,12 @@ chrome.app.window = {
/**
* @return {AppWindow}
*/
- current: function() {}
+ current: function() {},
+ /**
+ * @param {string} id
+ * @param {function()=} opt_callback
+ */
+ get: function(id, opt_callback) {}
};
@@ -43,19 +75,29 @@ chrome.runtime = {
message: ''
},
/** @return {{version: string, app: {background: Object}}} */
- getManifest: function() {}
+ getManifest: function() {},
+ /** @type {chrome.Event} */
+ onSuspend: null,
+ /** @type {chrome.Event} */
+ onConnect: null,
+ /** @type {chrome.Event} */
+ onConnectExternal: null,
+ /** @type {chrome.Event} */
+ onMessage: null,
+ /** @type {chrome.Event} */
+ onMessageExternal: null
};
/**
- * @type {?function(string):chrome.extension.Port}
+ * @type {?function(string):chrome.runtime.Port}
*/
chrome.runtime.connectNative = function(name) {};
/**
- * @param {{name:string}} connectInfo
- * @return {chrome.extension.Port}
+ * @param {{ name: string}} config
+ * @return {chrome.runtime.Port}
*/
-chrome.runtime.connect = function(connectInfo) {};
+chrome.runtime.connect = function(config) {};
/**
* @param {string} extensionId
@@ -66,22 +108,42 @@ chrome.runtime.connect = function(connectInfo) {};
chrome.runtime.sendMessage = function(
extensionId, message, opt_options, opt_callback) {};
-/** @type {Object} */
-chrome.extension = {};
+/** @constructor */
+chrome.runtime.MessageSender = function () {
+ /** @type {chrome.Tab} */
+ this.tab = null;
+ /** @type {AppWindow} */
+ this.window = null;
+};
/** @constructor */
-chrome.extension.Port = function() {};
+chrome.runtime.Port = function() {
+ this.onMessage = new chrome.Event();
+ this.onDisconnect = new chrome.Event();
+
+ /** @type {string} */
+ this.name = '';
+
+ /** @type {chrome.runtime.MessageSender} */
+ this.sender = null;
+};
/** @type {chrome.Event} */
-chrome.extension.Port.prototype.onMessage;
+chrome.runtime.Port.prototype.onMessage = null;
/** @type {chrome.Event} */
-chrome.extension.Port.prototype.onDisconnect;
+chrome.runtime.Port.prototype.onDisconnect = null;
+
+chrome.runtime.Port.prototype.disconnect = function() {};
/**
* @param {Object} message
*/
-chrome.extension.Port.prototype.postMessage = function(message) {};
+chrome.runtime.Port.prototype.postMessage = function(message) {};
+
+
+/** @type {Object} */
+chrome.extension = {};
/**
* @param {*} message
@@ -148,7 +210,7 @@ chrome.Storage.prototype.clear = function(opt_callback) {};
* src/chrome/common/extensions/api/context_menus.json
*/
chrome.contextMenus = {};
-/** @type {ChromeEvent} */
+/** @type {chrome.Event} */
chrome.contextMenus.onClicked;
/**
* @param {!Object} createProperties
@@ -216,27 +278,6 @@ chrome.identity = {
launchWebAuthFlow: function(parameters, callback) {}
};
-// TODO(garykac): Combine chrome.Event and ChromeEvent
-/** @constructor */
-function ChromeEvent() {}
-/** @param {Function} callback */
-ChromeEvent.prototype.addListener = function(callback) {};
-/** @param {Function} callback */
-ChromeEvent.prototype.removeListener = function(callback) {};
-/** @param {Function} callback */
-ChromeEvent.prototype.hasListener = function(callback) {};
-/** @param {Function} callback */
-ChromeEvent.prototype.hasListeners = function(callback) {};
-
-/** @constructor */
-chrome.Event = function() {};
-
-/** @param {function():void} callback */
-chrome.Event.prototype.addListener = function(callback) {};
-
-/** @param {function():void} callback */
-chrome.Event.prototype.removeListener = function(callback) {};
-
/** @type {Object} */
chrome.permissions = {
@@ -259,12 +300,33 @@ chrome.tabs = {};
/** @param {function(chrome.Tab):void} callback */
chrome.tabs.getCurrent = function(callback) {};
+/**
+ * @param {Object?} options
+ * @param {function(chrome.Tab)=} opt_callback
+ */
+chrome.tabs.create = function(options, opt_callback) {};
+
+/**
+ * @param {string} id
+ * @param {function(chrome.Tab)} callback
+ */
+chrome.tabs.get = function(id, callback) {};
+
+/**
+ * @param {string} id
+ * @param {function()=} opt_callback
+ */
+chrome.tabs.remove = function(id, opt_callback) {};
+
+
/** @constructor */
chrome.Tab = function() {
/** @type {boolean} */
this.pinned = false;
/** @type {number} */
this.windowId = 0;
+ /** @type {string} */
+ this.id = '';
};
@@ -294,6 +356,8 @@ var AppWindow = function() {
this.onMaximized = null;
/** @type {chrome.Event} */
this.onFullscreened = null;
+ /** @type {string} */
+ this.id = "";
};
AppWindow.prototype.close = function() {};

Powered by Google App Engine
This is Rietveld 408576698