diff options
author | kelvinp <kelvinp@chromium.org> | 2015-05-27 19:24:32 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-28 02:25:45 +0000 |
commit | 5dfb78ebc1bd050fcac1fa2fd4f72ef06f8bc8c8 (patch) | |
tree | d5afc3c6d22f74c85fce987a0ddee045fa3ca40f | |
parent | c5f6bd9750900f8baae0e23c7d273f5f08316ad2 (diff) | |
download | chromium_src-5dfb78ebc1bd050fcac1fa2fd4f72ef06f8bc8c8.zip chromium_src-5dfb78ebc1bd050fcac1fa2fd4f72ef06f8bc8c8.tar.gz chromium_src-5dfb78ebc1bd050fcac1fa2fd4f72ef06f8bc8c8.tar.bz2 |
[Chromoting] Use chrome_extension.js from third_party/closure_compiler/externs.
Closure compiler ships with externs for chrome extensions.
This CL re-annotates our source code to be compliant with the chrome_extensions externs
defined in closure_compiler. This will prevent us from getting broken by future closure
compiler version updates.
Since third_party/closure_compiler/externs/chrome_extensions.js is maintained in a
separate GitHub repository, a private copy of chrome_proto.js is still necessary to
bridge the gap between the discrepancies in type annotations.
BUG=491299
Review URL: https://codereview.chromium.org/1143113004
Cr-Commit-Position: refs/heads/master@{#331722}
30 files changed, 118 insertions, 646 deletions
diff --git a/remoting/app_remoting_webapp.gyp b/remoting/app_remoting_webapp.gyp index 7373778..fad6f42 100644 --- a/remoting/app_remoting_webapp.gyp +++ b/remoting/app_remoting_webapp.gyp @@ -11,6 +11,12 @@ 'target_defaults': { 'variables': { 'ar_internal': 0, + 'compiler_flags': [ + '--strict', + '--no-single-file', + '--externs', + '../third_party/closure_compiler/externs/chrome_extensions.js', + ], }, 'conditions': [ @@ -32,8 +38,7 @@ ], 'action': [ 'python', '../third_party/closure_compiler/compile.py', - '--strict', - '--no-single-file', + '<@(compiler_flags)', '--success-stamp', '<(success_stamp)', '<@(ar_main_js_files)', '<@(remoting_webapp_js_proto_files)', @@ -55,8 +60,7 @@ ], 'action': [ 'python', '../third_party/closure_compiler/compile.py', - '--strict', - '--no-single-file', + '<@(compiler_flags)', '--success-stamp', '<(success_stamp)', '<@(ar_background_js_files)', '<@(remoting_webapp_js_proto_files)', @@ -78,8 +82,7 @@ ], 'action': [ 'python', '../third_party/closure_compiler/compile.py', - '--strict', - '--no-single-file', + '<@(compiler_flags)', '--success-stamp', '<(success_stamp)', '<@(ar_feedback_consent_html_all_js_files)', '<@(remoting_webapp_js_proto_files)', diff --git a/remoting/remoting_webapp_compile.gypi b/remoting/remoting_webapp_compile.gypi index 3b5038e..f30195c 100644 --- a/remoting/remoting_webapp_compile.gypi +++ b/remoting/remoting_webapp_compile.gypi @@ -12,6 +12,8 @@ 'compiler_flags': [ '--strict', '--no-single-file', + '--externs', + '<(DEPTH)/third_party/closure_compiler/externs/chrome_extensions.js', ], }, 'actions': [ diff --git a/remoting/remoting_webapp_files.gypi b/remoting/remoting_webapp_files.gypi index b0d9f7e..675c3d1 100644 --- a/remoting/remoting_webapp_files.gypi +++ b/remoting/remoting_webapp_files.gypi @@ -20,7 +20,6 @@ 'remoting_webapp_js_proto_files': [ 'webapp/js_proto/chrome_proto.js', 'webapp/js_proto/chrome_cast_proto.js', - 'webapp/js_proto/chrome_event_proto.js', 'webapp/js_proto/dom_proto.js', 'webapp/js_proto/remoting_proto.js', ], diff --git a/remoting/webapp/app_remoting/js/application_context_menu.js b/remoting/webapp/app_remoting/js/application_context_menu.js index e607814..4dbb0ad 100644 --- a/remoting/webapp/app_remoting/js/application_context_menu.js +++ b/remoting/webapp/app_remoting/js/application_context_menu.js @@ -79,13 +79,16 @@ remoting.ApplicationContextMenu.prototype.updateConnectionRTT = /** @param {OnClickData=} info */ remoting.ApplicationContextMenu.prototype.onClicked_ = function(info) { - switch (info.menuItemId) { + var menuId = /** @type {string} */ (info.menuItemId.toString()); + switch (menuId) { case remoting.ApplicationContextMenu.kSendFeedbackId: var windowAttributes = { bounds: { width: 400, - height: 100 + height: 100, + left: undefined, + top: undefined }, resizable: false }; @@ -93,7 +96,7 @@ remoting.ApplicationContextMenu.prototype.onClicked_ = function(info) { /** @type {remoting.ApplicationContextMenu} */ var that = this; - /** @param {AppWindow} consentWindow */ + /** @param {chrome.app.window.AppWindow} consentWindow */ var onCreate = function(consentWindow) { var onLoad = function() { var message = { diff --git a/remoting/webapp/app_remoting/js/ar_background.js b/remoting/webapp/app_remoting/js/ar_background.js index 908f3f3..4ee2507 100644 --- a/remoting/webapp/app_remoting/js/ar_background.js +++ b/remoting/webapp/app_remoting/js/ar_background.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -/** @type {AppWindow} */ +/** @type {chrome.app.window.AppWindow} */ var mainWindow = null; /** @@ -15,7 +15,7 @@ var mainWindow = null; */ var contextMenuIds = {}; -/** @param {LaunchData=} opt_launchData */ +/** @param {chrome.app.runtime.LaunchData=} opt_launchData */ function createWindow(opt_launchData) { // If there is already a window, give it focus. if (mainWindow) { @@ -31,7 +31,9 @@ function createWindow(opt_launchData) { frame: remoting.platformIsMac() ? 'chrome' : 'none', bounds: { width: typed_screen.availWidth, - height: typed_screen.availHeight + height: typed_screen.availHeight, + left: undefined, + top: undefined } }; @@ -44,7 +46,7 @@ function createWindow(opt_launchData) { contextMenuIds = {}; }; - /** @param {AppWindow} appWindow */ + /** @param {chrome.app.window.AppWindow} appWindow */ function onCreate(appWindow) { // Set the global window. mainWindow = appWindow; diff --git a/remoting/webapp/app_remoting/js/context_menu_chrome.js b/remoting/webapp/app_remoting/js/context_menu_chrome.js index 337be59..285eb0c 100644 --- a/remoting/webapp/app_remoting/js/context_menu_chrome.js +++ b/remoting/webapp/app_remoting/js/context_menu_chrome.js @@ -82,12 +82,13 @@ remoting.ContextMenuChrome.prototype.remove = function(id) { * @param {function(OnClickData):void} listener */ remoting.ContextMenuChrome.prototype.addListener = function(listener) { - chrome.contextMenus.onClicked.addListener(listener); + chrome.contextMenus.onClicked.addListener( + /** @type {function(Object, Tab=)} */ (listener)); }; /** * @param {*} message - * @param {Window} backgroundPage + * @param {Window=} backgroundPage */ remoting.ContextMenuChrome.prototype.postMessage_ = function( message, backgroundPage) { diff --git a/remoting/webapp/app_remoting/js/feedback_consent.js b/remoting/webapp/app_remoting/js/feedback_consent.js index 7d81521..9dce238 100644 --- a/remoting/webapp/app_remoting/js/feedback_consent.js +++ b/remoting/webapp/app_remoting/js/feedback_consent.js @@ -121,13 +121,15 @@ function generateId() { } /** - * @param {string} token + * @param {string=} token */ function onToken(token) { var getUserInfo = function() { + base.debug.assert(Boolean(token), 'token is undefined.'); var oauth2Api = new remoting.OAuth2ApiImpl(); oauth2Api.getUserInfo( - onUserInfo, onUserInfo.bind(null, 'unknown', 'unknown'), token); + onUserInfo, onUserInfo.bind(null, 'unknown', 'unknown'), + /** @type {string} */(token)); }; if (!token) { onUserInfo('unknown', 'unknown'); diff --git a/remoting/webapp/app_remoting/js/keyboard_layouts_menu.js b/remoting/webapp/app_remoting/js/keyboard_layouts_menu.js index 4b47cfe..1650634 100644 --- a/remoting/webapp/app_remoting/js/keyboard_layouts_menu.js +++ b/remoting/webapp/app_remoting/js/keyboard_layouts_menu.js @@ -169,10 +169,10 @@ remoting.KeyboardLayoutsMenu.prototype.makeMenuId_ = function(layout) { * @private */ remoting.KeyboardLayoutsMenu.prototype.onContextMenu_ = function(info) { - /** @type {Array<string>} */ - var components = info.menuItemId.split('@'); + var menuItemId = info.menuItemId.toString(); + var components = menuItemId.split('@'); if (components.length == 2 && - this.makeMenuId_(components[1]) == info.menuItemId) { + this.makeMenuId_(components[1]) === menuItemId) { this.setLayout_(true, components[1]); } }; diff --git a/remoting/webapp/app_remoting/js/window_activation_menu.js b/remoting/webapp/app_remoting/js/window_activation_menu.js index 80fbb4f..72039b7 100644 --- a/remoting/webapp/app_remoting/js/window_activation_menu.js +++ b/remoting/webapp/app_remoting/js/window_activation_menu.js @@ -75,10 +75,10 @@ remoting.WindowActivationMenu.prototype.setExtensionMessageSender = * @private */ remoting.WindowActivationMenu.prototype.onContextMenu_ = function(info) { - /** @type {Array<string>} */ - var components = info.menuItemId.split('-'); + var menuId = info.menuItemId.toString(); + var components = menuId.split('-'); if (components.length == 2 && - this.makeMenuId_(parseInt(components[1], 10)) == info.menuItemId) { + this.makeMenuId_(parseInt(components[1], 10)) == menuId) { this.sendExtensionMessage_( 'activateWindow', JSON.stringify({ id: parseInt(components[1], 0) })); diff --git a/remoting/webapp/base/js/base.js b/remoting/webapp/base/js/base.js index c10c8cf..b2993da 100644 --- a/remoting/webapp/base/js/base.js +++ b/remoting/webapp/base/js/base.js @@ -641,8 +641,8 @@ base.DomEventHook.prototype.dispose = function() { /** * An event hook implementation for Chrome Events. * - * @param {chrome.Event} src - * @param {Function} listener + * @param {ChromeEvent} src + * @param {!Function} listener * * @constructor * @implements {base.Disposable} diff --git a/remoting/webapp/base/js/identity.js b/remoting/webapp/base/js/identity.js index 2db3f03..40fa8b1 100644 --- a/remoting/webapp/base/js/identity.js +++ b/remoting/webapp/base/js/identity.js @@ -108,7 +108,7 @@ remoting.Identity.prototype.getNewToken = function(opt_scopes) { */ remoting.Identity.prototype.removeCachedAuthToken = function() { return new Promise(function(resolve, reject) { - /** @param {string} token */ + /** @param {string=} token */ var onToken = function(token) { if (token) { chrome.identity.removeCachedAuthToken( @@ -180,7 +180,7 @@ remoting.Identity.prototype.getEmail = function() { * * @param {Array<string>|undefined} scopes The explicit scopes passed to * getToken, or undefined if no scopes were specified. - * @param {?string} token The auth token, or null if the request failed. + * @param {string=} token The auth token, or null if the request failed. * @private */ remoting.Identity.prototype.onAuthComplete_ = function(scopes, token) { diff --git a/remoting/webapp/base/js/ipc.js b/remoting/webapp/base/js/ipc.js index 11b65c1..a83ef87 100644 --- a/remoting/webapp/base/js/ipc.js +++ b/remoting/webapp/base/js/ipc.js @@ -51,7 +51,9 @@ base.Ipc = function() { base.debug.assert(instance_ === null); /** @private {!Object<Function>} */ this.handlers_ = {}; - this.onMessageHandler_ = this.onMessage_.bind(this); + this.onMessageHandler_ = + /** @type {function(*, MessageSender, function (*))} */ ( + this.onMessage_.bind(this)); chrome.runtime.onMessage.addListener(this.onMessageHandler_); }; @@ -109,7 +111,7 @@ base.Ipc.prototype.unregister = function(methodName) { /** * @param {base.Ipc.Request_} message - * @param {chrome.runtime.MessageSender} sender + * @param {!MessageSender} sender * @param {function(*): void} sendResponse */ base.Ipc.prototype.onMessage_ = function(message, sender, sendResponse) { diff --git a/remoting/webapp/base/js/message_window_helper.js b/remoting/webapp/base/js/message_window_helper.js index f665757..d608a03 100644 --- a/remoting/webapp/base/js/message_window_helper.js +++ b/remoting/webapp/base/js/message_window_helper.js @@ -100,7 +100,9 @@ remoting.MessageWindow = function(options) { var windowAttributes = { bounds: { width: options.minimumWidth || 400, - height: 100 + height: 100, + top: undefined, + left: undefined }, resizable: false, frame: options.frame || 'chrome' @@ -109,7 +111,7 @@ remoting.MessageWindow = function(options) { /** @type {remoting.MessageWindow} */ var that = this; - /** @param {AppWindow} appWindow */ + /** @param {chrome.app.window.AppWindow} appWindow */ var onCreate = function(appWindow) { that.setWindow_(/** @type {Window} */(appWindow.contentWindow)); var onLoad = function() { diff --git a/remoting/webapp/base/js/signal_strategy.js b/remoting/webapp/base/js/signal_strategy.js index 89b18f4..8cd6c9b 100644 --- a/remoting/webapp/base/js/signal_strategy.js +++ b/remoting/webapp/base/js/signal_strategy.js @@ -106,7 +106,7 @@ remoting.SignalStrategy.create = function() { // Only use XMPP when TCP API is available and TLS support is enabled. That's // not the case for V1 app (socket API is available only to platform apps) // and for Chrome releases before 38. - if (chrome.socket && chrome.socket.secure) { + if (chrome.sockets && chrome.sockets.tcp && chrome.sockets.tcp.secure) { /** * @param {remoting.FallbackSignalStrategy.Progress} progress */ diff --git a/remoting/webapp/base/js/tcp_socket.js b/remoting/webapp/base/js/tcp_socket.js index f364410..4919bed 100644 --- a/remoting/webapp/base/js/tcp_socket.js +++ b/remoting/webapp/base/js/tcp_socket.js @@ -21,7 +21,7 @@ function addReceiveListeners() { receiveListenersAdded = true; chrome.sockets.tcp.onReceive.addListener(function( - /** chrome.sockets.tcp.ReceiveInfo */ info) { + /** chrome.sockets.tcp.ReceiveEventData */ info) { var socket = sockets[info.socketId]; if (socket === undefined) { console.warn("Received data for unknown socket " + info.socketId); @@ -35,7 +35,7 @@ function addReceiveListeners() { }); chrome.sockets.tcp.onReceiveError.addListener(function( - /** chrome.sockets.tcp.ReceiveErrorInfo */ info) { + /** chrome.sockets.tcp.ReceiveErrorEventData */ info) { var socket = sockets[info.socketId]; if (socket === undefined) { console.warn("Received error for unknown socket " + info.socketId); @@ -78,10 +78,10 @@ remoting.TcpSocket.prototype.connect = function(/** string */ host, var that = this; return new Promise(function(resolve, reject) { - chrome.sockets.tcp.create({}, onCreated); + chrome.sockets.tcp.create({}, /** @type {function(Object)} */ (onCreated)); - function onCreated(/** chrome.sockets.tcp.CreateInfo */ createInfo) { + function onCreated(/** chrome.socket.CreateInfo */ createInfo) { // Check if the socket was destroyed. if (that.destroyed_) { chrome.sockets.tcp.close(createInfo.socketId); @@ -140,11 +140,12 @@ remoting.TcpSocket.prototype.startReceiving = function( * * @returns {Promise} */ -remoting.TcpSocket.prototype.send = function(/** ArrayBuffer */ data) { +remoting.TcpSocket.prototype.send = function(/** !ArrayBuffer */ data) { var that = this; return new Promise(function(resolve, reject) { - chrome.sockets.tcp.send(that.socketId_, data, function(sendInfo) { + chrome.sockets.tcp.send(that.socketId_, data, + function(/** chrome.socket.SendInfo */ sendInfo) { if (sendInfo.resultCode < 0) { reject(sendInfo.resultCode); } else { diff --git a/remoting/webapp/base/js/xmpp_connection.js b/remoting/webapp/base/js/xmpp_connection.js index f613778..7cdd42e 100644 --- a/remoting/webapp/base/js/xmpp_connection.js +++ b/remoting/webapp/base/js/xmpp_connection.js @@ -30,7 +30,7 @@ remoting.XmppConnection = function() { this.sendPending_ = false; /** @private */ this.startTlsPending_ = false; - /** @private {Array<ArrayBuffer>} */ + /** @private {Array<!ArrayBuffer>} */ this.sendQueue_ = []; /** @private {remoting.XmppLoginHandler} */ this.loginHandler_ = null; diff --git a/remoting/webapp/build_template.gni b/remoting/webapp/build_template.gni index 1b9795b..c47eae7 100644 --- a/remoting/webapp/build_template.gni +++ b/remoting/webapp/build_template.gni @@ -61,6 +61,8 @@ template("build_webapp_html") { args = [ "--strict", "--no-single-file", + "--externs", + "../../third_party/closure_compiler/externs/chrome_extensions.js", "--success-stamp", rebase_path(target_jscompile_stamp, root_build_dir), ] + rebase_path(js_files, root_build_dir) diff --git a/remoting/webapp/crd/js/activation_handler.js b/remoting/webapp/crd/js/activation_handler.js index ce68a10..5e2f6bd 100644 --- a/remoting/webapp/crd/js/activation_handler.js +++ b/remoting/webapp/crd/js/activation_handler.js @@ -29,7 +29,8 @@ remoting.ActivationHandler = function (ipc, appLauncher) { title: chrome.i18n.getMessage(/*i18n-content*/'NEW_WINDOW') }); - chrome.contextMenus.onClicked.addListener(this.onContextMenu_.bind(this)); + chrome.contextMenus.onClicked.addListener( + /** @type {function (Object, Tab=)} */ (this.onContextMenu_.bind(this))); chrome.app.runtime.onLaunched.addListener(this.onLaunched_.bind(this)); ipc.register(remoting.ActivationHandler.Ipc.RELAUNCH, appLauncher.restart.bind(appLauncher)); diff --git a/remoting/webapp/crd/js/app_launcher.js b/remoting/webapp/crd/js/app_launcher.js index d4a838c..25b39ac 100644 --- a/remoting/webapp/crd/js/app_launcher.js +++ b/remoting/webapp/crd/js/app_launcher.js @@ -52,41 +52,27 @@ remoting.V1AppLauncher = function() {}; remoting.V1AppLauncher.prototype.launch = function(opt_launchArgs) { var url = base.urlJoin('main.html', opt_launchArgs); - return new Promise( - /** - * @param {function(*=):void} resolve - * @param {function(*=):void} reject - */ - function(resolve, reject) { - chrome.tabs.create({ url: url, selected: true }, - /** @param {chrome.Tab} tab The created tab. */ - function(tab) { - if (!tab) { - reject(new Error(chrome.runtime.lastError.message)); - } else { - resolve(String(tab.id)); - } - }); - }); + return new Promise(function(resolve, reject) { + chrome.tabs.create({ url: url, selected: true }, function(/**Tab*/ tab){ + if (!tab) { + reject(new Error(chrome.runtime.lastError.message)); + } else { + resolve(String(tab.id)); + } + }); + }); }; remoting.V1AppLauncher.prototype.close = function(id) { - return new Promise( - /** - * @param {function(*=):void} resolve - * @param {function(*=):void} reject - */ - function(resolve, reject) { - chrome.tabs.get(id, - /** @param {chrome.Tab} tab The retrieved tab. */ - function(tab) { - if (!tab) { - reject(new Error(chrome.runtime.lastError.message)); - } else { - chrome.tabs.remove(tab.id, /** function(*=):void */ (resolve)); - } - }); - }); + return new Promise(function(resolve, reject) { + chrome.tabs.get(parseInt(id, 10), function(/** Tab */ tab) { + if (!tab) { + reject(new Error(chrome.runtime.lastError.message)); + } else { + chrome.tabs.remove(tab.id, resolve); + } + }); + }); }; @@ -106,7 +92,7 @@ remoting.V2AppLauncher.prototype.restart = function(id) { // Not using the launch() method because we want to launch a new window with // the same id, such that the size and positioning of the original window // can be preserved. - return chrome.app.window.create(APP_MAIN_URL, {'id' : id, 'frame': 'none'}); + chrome.app.window.create(APP_MAIN_URL, {'id' : id, 'frame': 'none'}); }); }; @@ -131,8 +117,7 @@ remoting.V2AppLauncher.prototype.launch = function(opt_launchArgs) { 'id': String(getNextWindowId()), 'state': state }, - /** @param {AppWindow=} appWindow */ - function(appWindow) { + function(/** chrome.app.window.AppWindow= */ appWindow) { if (!appWindow) { reject(new Error(chrome.runtime.lastError.message)); } else { diff --git a/remoting/webapp/crd/js/desktop_remoting.js b/remoting/webapp/crd/js/desktop_remoting.js index efdf1eb..965dc93 100644 --- a/remoting/webapp/crd/js/desktop_remoting.js +++ b/remoting/webapp/crd/js/desktop_remoting.js @@ -163,11 +163,10 @@ remoting.DesktopRemoting.prototype.exitApplication_ = function() { * @private */ remoting.DesktopRemoting.prototype.isWindowed_ = function(callback) { - /** @param {chrome.Window} win The current window. */ - var windowCallback = function(win) { + var windowCallback = function(/** ChromeWindow */ win) { callback(win.type == 'popup'); }; - /** @param {chrome.Tab} tab The current tab. */ + /** @param {Tab=} tab */ var tabCallback = function(tab) { if (tab.pinned) { callback(false); diff --git a/remoting/webapp/crd/js/host_daemon_facade.js b/remoting/webapp/crd/js/host_daemon_facade.js index 7da4a91..544abd3 100644 --- a/remoting/webapp/crd/js/host_daemon_facade.js +++ b/remoting/webapp/crd/js/host_daemon_facade.js @@ -22,7 +22,7 @@ remoting.HostDaemonFacade = function() { /** @private {Object<number, remoting.HostDaemonFacade.PendingReply>} */ this.pendingReplies_ = {}; - /** @private {?chrome.runtime.Port} */ + /** @private {?Port} */ this.port_ = null; /** @private {string} */ diff --git a/remoting/webapp/crd/js/host_installer.js b/remoting/webapp/crd/js/host_installer.js index c8a15a3..e214904 100644 --- a/remoting/webapp/crd/js/host_installer.js +++ b/remoting/webapp/crd/js/host_installer.js @@ -52,7 +52,7 @@ remoting.HostInstaller.isInstalled = function() { function(resolve) { // TODO(kelvinp): Use different native messaging ports for the Me2me // host vs It2MeHost. - /** @type {chrome.runtime.Port} */ + /** @type {Port} */ var port = chrome.runtime.connectNative('com.google.chrome.remote_assistance'); diff --git a/remoting/webapp/crd/js/it2me_host_facade.js b/remoting/webapp/crd/js/it2me_host_facade.js index 99800f3..23a70ac 100644 --- a/remoting/webapp/crd/js/it2me_host_facade.js +++ b/remoting/webapp/crd/js/it2me_host_facade.js @@ -22,7 +22,7 @@ remoting.It2MeHostFacade = function() { /** @private {number} */ this.nextId_ = 0; - /** @private {?chrome.runtime.Port} */ + /** @private {?Port} */ this.port_ = null; /** @private {string} */ diff --git a/remoting/webapp/crd/js/mock_identity.js b/remoting/webapp/crd/js/mock_identity.js index 66db46d..7bdb446 100644 --- a/remoting/webapp/crd/js/mock_identity.js +++ b/remoting/webapp/crd/js/mock_identity.js @@ -100,8 +100,8 @@ remoting.MockIdentity.prototype.validateTokenAndCall = * @param {boolean} active */ remoting.MockIdentity.setActive = function(active) { - chrome.identity = active ? remoting.mockIdentity - : remoting.savedIdentityApi; + chrome['identity'] = + active ? remoting.mockIdentity : remoting.savedIdentityApi; }; /** @type {Object} */ diff --git a/remoting/webapp/crd/js/third_party_token_fetcher.js b/remoting/webapp/crd/js/third_party_token_fetcher.js index 66189e9..5767b79 100644 --- a/remoting/webapp/crd/js/third_party_token_fetcher.js +++ b/remoting/webapp/crd/js/third_party_token_fetcher.js @@ -85,7 +85,7 @@ remoting.ThirdPartyTokenFetcher.prototype.fetchToken = function() { /** * Parse the access token from the URL to which we were redirected. * - * @param {string} responseUrl The URL to which we were redirected. + * @param {string=} responseUrl The URL to which we were redirected. * @private */ remoting.ThirdPartyTokenFetcher.prototype.parseRedirectUrl_ = diff --git a/remoting/webapp/crd/js/video_frame_recorder.js b/remoting/webapp/crd/js/video_frame_recorder.js index e73c832..0012242 100644 --- a/remoting/webapp/crd/js/video_frame_recorder.js +++ b/remoting/webapp/crd/js/video_frame_recorder.js @@ -141,9 +141,10 @@ remoting.VideoFrameRecorder.prototype.isRecording = function() { } /** - * @param {Entry} entry The single file entry if multiple files are not allowed. - * @param {Array<FileEntry>} fileEntries List of file entries if multiple files - * are allowed. + * @param {Entry=} entry The single file entry if multiple files are not + * allowed. + * @param {Array<!FileEntry>=} fileEntries List of file entries if multiple + * files are allowed. */ remoting.VideoFrameRecorder.prototype.onFileChosen_ = function( entry, fileEntries) { diff --git a/remoting/webapp/files.gni b/remoting/webapp/files.gni index 50b16c5..62a29ab 100644 --- a/remoting/webapp/files.gni +++ b/remoting/webapp/files.gni @@ -18,7 +18,6 @@ remoting_webapp_js_proto_files = [ "js_proto/chrome_proto.js", "js_proto/chrome_cast_proto.js", - "js_proto/chrome_event_proto.js", "js_proto/dom_proto.js", "js_proto/remoting_proto.js", ] diff --git a/remoting/webapp/js_proto/chrome_event_proto.js b/remoting/webapp/js_proto/chrome_event_proto.js deleted file mode 100644 index 317f711..0000000 --- a/remoting/webapp/js_proto/chrome_event_proto.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2015 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. - -/** @constructor */ -chrome.Event = function() {}; - -/** @param {Function} callback */ -chrome.Event.prototype.addListener = function(callback) {}; - -/** @param {Function} callback */ -chrome.Event.prototype.removeListener = function(callback) {}; diff --git a/remoting/webapp/js_proto/chrome_mocks.js b/remoting/webapp/js_proto/chrome_mocks.js index 7d76d3c..0a06982 100644 --- a/remoting/webapp/js_proto/chrome_mocks.js +++ b/remoting/webapp/js_proto/chrome_mocks.js @@ -7,23 +7,13 @@ var chromeMocks = {}; -/** @constructor */ -chrome.Event = function() {}; - -/** @param {Function} callback */ -chrome.Event.prototype.addListener = function(callback) {}; - -/** @param {Function} callback */ -chrome.Event.prototype.removeListener = function(callback) {}; - - (function(){ 'use strict' /** * @constructor - * @extends {chrome.Event} + * @extends {ChromeEvent} */ chromeMocks.Event = function() { this.listeners_ = []; @@ -71,7 +61,7 @@ chromeMocks.runtime.Port = function() { /** @type {string} */ this.name = ''; - /** @type {chrome.runtime.MessageSender} */ + /** @type {MessageSender} */ this.sender = null; }; @@ -284,7 +274,7 @@ chromeMocks.activate = function() { chrome[component] = chromeMocks[component]; }); - chrome.app.window = new chromeMocks.WindowManager(); + chrome.app['window'] = new chromeMocks.WindowManager(); }; chromeMocks.restore = function() { diff --git a/remoting/webapp/js_proto/chrome_proto.js b/remoting/webapp/js_proto/chrome_proto.js index 6156a50..8a34617 100644 --- a/remoting/webapp/js_proto/chrome_proto.js +++ b/remoting/webapp/js_proto/chrome_proto.js @@ -2,553 +2,43 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// This file contains various hacks needed to inform JSCompiler of various -// WebKit- and Chrome-specific properties and methods. It is used only with -// JSCompiler to verify the type-correctness of our code. +// This file contains various hacks needed to inform the closure compiler of +// various Chrome-specific properties and methods that is not specified in +// /third_part/closure_compiler/externs/chrome_externsions.js. It is used only +// with the closure compiler to verify the type-correctness of our code. -/** @type {Object} */ -chrome.app.runtime = { - /** @type {chrome.Event} */ - onLaunched: null -}; +console.error('Proto file should not be executed.'); +/** @type {{background: Object}} */ +chrome.runtime.Manifest.prototype.app; -/** @type {Object} */ -chrome.app.window = { - /** - * @param {string} name - * @param {Object} parameters - * @param {function(AppWindow)=} opt_callback - */ - create: function(name, parameters, opt_callback) {}, - /** - * @return {AppWindow} - */ - current: function() {}, - /** - * @param {string} id - * @return {AppWindow} - */ - get: function(id) {}, - /** - * @return {Array<AppWindow>} - */ - getAll: function() {} -}; +/** @type {chrome.app.window.Bounds} */ +chrome.app.window.AppWindow.prototype.outerBounds; +/** @type {chrome.app.window.Bounds} */ +chrome.app.window.AppWindow.prototype.innerBounds; /** @type {string} */ -chrome.runtime.id; - -/** @return {{name: string, version: string, app: {background: Object}}} */ -chrome.runtime.getManifest = function() {}; - -/** @param {function(Window):void} callback */ -chrome.runtime.getBackgroundPage = function(callback) {}; - -/** @type {chrome.Event} */ -chrome.runtime.onSuspend; - -/** @type {chrome.Event} */ -chrome.runtime.onSuspendCanceled; - -/** @type {chrome.Event} */ -chrome.runtime.onConnect; - -/** @type {chrome.Event} */ -chrome.runtime.onConnectExternal; - -/** @type {chrome.Event} */ -chrome.runtime.onMessage; - -/** @type {chrome.Event} */ -chrome.runtime.onMessageExternal; - -/** - * @type {?function(string):chrome.runtime.Port} - */ -chrome.runtime.connectNative = function(name) {}; - -/** @constructor */ -chrome.runtime.MessageSender = function(){ - /** @type {chrome.Tab} */ - this.tab = null; - /** @type {string} */ - this.id = ''; - /** @type {string} */ - this.url = ''; -}; - -/** @constructor */ -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.runtime.Port.prototype.onMessage = null; - -/** @type {chrome.Event} */ -chrome.runtime.Port.prototype.onDisconnect = null; - -chrome.runtime.Port.prototype.disconnect = function() {}; - -/** - * @param {Object} message - */ -chrome.runtime.Port.prototype.postMessage = function(message) {}; - - -/** @type {Object} */ -chrome.extension = {}; - -/** - * @param {*} message - * @param {function(*)=} opt_callback - */ -chrome.extension.sendMessage = function(message, opt_callback) {}; - -/** @type {chrome.Event} */ -chrome.extension.onMessage; - - -/** @type {Object} */ -chrome.i18n = {}; - -/** - * @param {string} messageName - * @param {(string|Array<string>)=} opt_args - * @return {string} - */ -chrome.i18n.getMessage = function(messageName, opt_args) {}; - -/** - * @return {string} - */ -chrome.i18n.getUILanguage = function() {}; - - -/** @type {Object} */ -chrome.storage = {}; - -/** @type {chrome.Storage} */ -chrome.storage.local; - -/** @type {chrome.Storage} */ -chrome.storage.sync; - -/** @constructor */ -chrome.Storage = function() {}; +chrome.app.window.AppWindow.prototype.id; /** - * @param {string|Array<string>|Object<string>} items - * @param {function(Object<string>):void} callback - * @return {void} - */ -chrome.Storage.prototype.get = function(items, callback) {}; - -/** - * @param {Object<string>} items - * @param {function():void=} opt_callback - * @return {void} - */ -chrome.Storage.prototype.set = function(items, opt_callback) {}; - -/** - * @param {string|Array<string>} items - * @param {function():void=} opt_callback - * @return {void} - */ -chrome.Storage.prototype.remove = function(items, opt_callback) {}; - -/** - * @param {function():void=} opt_callback - * @return {void} - */ -chrome.Storage.prototype.clear = function(opt_callback) {}; - - -/** - * @type {Object} - * src/chrome/common/extensions/api/context_menus.json - */ -chrome.contextMenus = {}; -/** @type {chrome.Event} */ -chrome.contextMenus.onClicked; -/** - * @param {!Object} createProperties - * @param {function()=} opt_callback - */ -chrome.contextMenus.create = function(createProperties, opt_callback) {}; -/** - * @param {string|number} id - * @param {!Object} updateProperties - * @param {function()=} opt_callback - */ -chrome.contextMenus.update = function(id, updateProperties, opt_callback) {}; -/** - * @param {string|number} menuItemId - * @param {function()=} opt_callback - */ -chrome.contextMenus.remove = function(menuItemId, opt_callback) {}; -/** - * @param {function()=} opt_callback + * @param {{rects: Array<ClientRect>}} rects */ -chrome.contextMenus.removeAll = function(opt_callback) {}; +chrome.app.window.AppWindow.prototype.setShape = function(rects) {}; -/** @constructor */ -function OnClickData() {}; -/** @type {string|number} */ -OnClickData.prototype.menuItemId; -/** @type {string|number} */ -OnClickData.prototype.parentMenuItemId; -/** @type {string} */ -OnClickData.prototype.mediaType; -/** @type {string} */ -OnClickData.prototype.linkUrl; -/** @type {string} */ -OnClickData.prototype.srcUrl; -/** @type {string} */ -OnClickData.prototype.pageUrl; -/** @type {string} */ -OnClickData.prototype.frameUrl; -/** @type {string} */ -OnClickData.prototype.selectionText; -/** @type {boolean} */ -OnClickData.prototype.editable; -/** @type {boolean} */ -OnClickData.prototype.wasChecked; /** @type {boolean} */ OnClickData.prototype.checked; - -/** @type {Object} */ -chrome.fileSystem = { - /** - * @param {Object<string>?} options - * @param {function(Entry, Array<FileEntry>):void} callback - */ - chooseEntry: function(options, callback) {}, - /** - * @param {Entry} entry - * @param {function(string):void} callback - */ - getDisplayPath: function(entry, callback) {} -}; - -/** @param {function(FileWriter):void} callback */ -Entry.prototype.createWriter = function(callback) {}; - -/** @type {Object} */ -chrome.identity = { - /** - * @param {Object<string>} parameters - * @param {function(string):void} callback - */ - getAuthToken: function(parameters, callback) {}, - /** - * @param {Object<string>} parameters - * @param {function():void} callback - */ - removeCachedAuthToken: function(parameters, callback) {}, - /** - * @param {Object<string>} parameters - * @param {function(string):void} callback - */ - launchWebAuthFlow: function(parameters, callback) {} -}; - - -/** @type {Object} */ -chrome.permissions = { - /** - * @param {Object<string>} permissions - * @param {function(boolean):void} callback - */ - contains: function(permissions, callback) {}, - /** - * @param {Object<string>} permissions - * @param {function(boolean):void} callback - */ - request: function(permissions, callback) {} -}; - - -/** @type {Object} */ -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(*=):void=} 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 = ''; -}; - - -/** @type {Object} */ -chrome.windows = {}; - -/** @param {number} id - * @param {Object?} getInfo - * @param {function(chrome.Window):void} callback */ -chrome.windows.get = function(id, getInfo, callback) {}; - -/** @constructor */ -chrome.Window = function() { - /** @type {string} */ - this.state = ''; - /** @type {string} */ - this.type = ''; -}; - -/** @constructor */ -var AppWindow = function() { - /** @type {Window} */ - this.contentWindow = null; - /** @type {chrome.Event} */ - this.onClosed = null; - /** @type {chrome.Event} */ - this.onRestored = null; - /** @type {chrome.Event} */ - this.onMaximized = null; - /** @type {chrome.Event} */ - this.onMinimized = null; - /** @type {chrome.Event} */ - this.onFullscreened = null; - /** @type {string} */ - this.id = ''; - /** @type {Bounds} */ - this.outerBounds = null; - /** @type {Bounds} */ - this.innerBounds = null; -}; - -AppWindow.prototype.close = function() {}; -AppWindow.prototype.drawAttention = function() {}; -AppWindow.prototype.focus = function() {}; -AppWindow.prototype.maximize = function() {}; -AppWindow.prototype.minimize = function() {}; -AppWindow.prototype.restore = function() {}; -AppWindow.prototype.show = function() {}; -/** @return {boolean} */ -AppWindow.prototype.isMinimized = function() {}; -AppWindow.prototype.fullscreen = function() {}; -/** @return {boolean} */ -AppWindow.prototype.isFullscreen = function() {}; -/** @return {boolean} */ -AppWindow.prototype.isMaximized = function() {}; - -/** - * @param {{rects: Array<ClientRect>}} rects - */ -AppWindow.prototype.setShape = function(rects) {}; - -/** - * @param {{rects: Array<ClientRect>}} rects - */ -AppWindow.prototype.setInputRegion = function(rects) {}; - -/** @constructor */ -var LaunchData = function() { - /** @type {string} */ - this.id = ''; - /** @type {Array<{type: string, entry: FileEntry}>} */ - this.items = []; -}; - -/** @constructor */ -function Bounds() { - /** @type {number} */ - this.left = 0; - /** @type {number} */ - this.top = 0; - /** @type {number} */ - this.width = 0; - /** @type {number} */ - this.height = 0; -} - -/** @type {Object} */ -chrome.sockets = {}; - -/** @type {Object} */ -chrome.sockets.tcp = {}; - -/** @constructor */ -chrome.sockets.tcp.CreateInfo = function() { - /** @type {number} */ - this.socketId = 0; -} - -/** - * @param {Object} properties - * @param {function(chrome.sockets.tcp.CreateInfo):void} callback - */ -chrome.sockets.tcp.create = function(properties, callback) {}; - - -/** - * @param {number} socketId - * @param {string} peerAddress - * @param {number} peerPort - * @param {function(number):void} callback - */ -chrome.sockets.tcp.connect = - function(socketId, peerAddress, peerPort, callback) {}; - - -/** @constructor */ -chrome.sockets.tcp.SendInfo = function() { - /** @type {number} */ - this.resultCode = 0; - - /** @type {number} */ - this.bytesSent = 0; -} - -/** - * @param {number} socketId - * @param {ArrayBuffer} data - * @param {function(chrome.sockets.tcp.SendInfo):void} callback - */ -chrome.sockets.tcp.send = function(socketId, data, callback) {}; - - -/** - * @param {number} socketId - */ -chrome.sockets.tcp.close = function(socketId) {}; - -/** - * @param {number} socketId - * @param {boolean} paused - * @param {function(number):void=} callback - */ -chrome.sockets.tcp.setPaused = function(socketId, paused, callback) {}; - /** - * @param {number} socketId - * @param {Object} options - * @param {function(number):void} callback + * @constructor */ -chrome.sockets.tcp.secure = function(socketId, options, callback) {}; - -/** @constructor */ -chrome.sockets.tcp.ReceiveInfo = function() { - /** @type {number} */ - this.socketId = 0; - - /** @type {ArrayBuffer} */ - this.data = null; -} - -/** @type {chrome.Event} */ -chrome.sockets.tcp.onReceive = null; +chrome.socket.SendInfo = function() {}; -/** @constructor */ -chrome.sockets.tcp.ReceiveErrorInfo = function() { - /** @type {number} */ - this.socketId = 0; +/** @type {number} */ +chrome.socket.SendInfo.prototype.resultCode; - /** @type {number} */ - this.resultCode = 0; -} +/** @type {number} */ +chrome.socket.SendInfo.prototype.bytesSent; -/** @type {chrome.Event} */ -chrome.sockets.tcp.onReceiveError = null; - -/** @type {Object} */ -chrome.socket = {}; - -/** @constructor */ -chrome.socket.CreateInfo = function() { - /** @type {number} */ - this.socketId = 0; -} - -/** - * @param {string} socketType - * @param {Object} options - * @param {function(chrome.socket.CreateInfo):void} callback - */ -chrome.socket.create = function(socketType, options, callback) {}; - -/** - * @param {number} socketId - * @param {string} hostname - * @param {number} port - * @param {function(number):void} callback - */ -chrome.socket.connect = - function(socketId, hostname, port, callback) {}; - -/** @constructor */ -chrome.socket.WriteInfo = function() { - /** @type {number} */ - this.bytesWritten = 0; -} - -/** - * @param {number} socketId - * @param {ArrayBuffer} data - * @param {function(chrome.socket.WriteInfo):void} callback - */ -chrome.socket.write = function(socketId, data, callback) {}; - -/** @constructor */ -chrome.socket.ReadInfo = function() { - /** @type {number} */ - this.resultCode = 0; - - /** @type {ArrayBuffer} */ - this.data = null; -} - -/** - * @param {number} socketId - * @param {function(chrome.socket.ReadInfo):void} callback - */ -chrome.socket.read = function(socketId, callback) {}; - -/** - * @param {number} socketId - */ -chrome.socket.destroy = function(socketId) {}; - -/** - * @param {number} socketId - * @param {Object} options - * @param {function(number):void} callback - */ -chrome.socket.secure = function(socketId, options, callback) {}; +/** @param {function(FileWriter):void} callback */ +Entry.prototype.createWriter = function(callback) {};
\ No newline at end of file |