Chromium Code Reviews| Index: chrome/browser/resources/chromeos/network_menu.js |
| diff --git a/chrome/browser/resources/chromeos/network_menu.js b/chrome/browser/resources/chromeos/network_menu.js |
| index d1396dde40367954f78311117d38ee04134f0ae5..cd019b849a12a662cca7e5aac18f0e7deac725fe 100644 |
| --- a/chrome/browser/resources/chromeos/network_menu.js |
| +++ b/chrome/browser/resources/chromeos/network_menu.js |
| @@ -1,15 +1,15 @@ |
| -// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// 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. |
| // Network status constants. |
| -const StatusConnected = 'connected'; |
| -const StatusDisconnected = 'disconnected'; |
| -const StatusConnecting = 'connecting'; |
| -const StatusError = 'error'; |
| +var statusConnected = 'connected'; |
|
Dan Beam
2012/05/07 17:43:53
/** @const */ var statusConnected = 'connected';
kmadhusu
2012/05/08 20:20:19
Done.
|
| +var statusDisconnected = 'disconnected'; |
| +var statusConnecting = 'connecting'; |
| +var statusError = 'error'; |
| -const NetworkOther = 'other'; |
| +var networkOther = 'other'; |
| // Setup css canvas 'spinner-circle' |
| (function() { |
| @@ -29,7 +29,11 @@ const NetworkOther = 'other'; |
| })(); |
| /** |
| - * Sends "connect" using the 'action' WebUI message. |
| + * Sends 'connect' using the 'action' WebUI message. |
| + * @param {number} index Selected network index. |
| + * @param {string} passphrase Password |
|
Dan Beam
2012/05/07 17:43:53
I'm not sure passphrase is quite the same as passw
kmadhusu
2012/05/08 20:20:19
Fixed.
|
| + * @param {string} identity Network ssid. |
| + * @param {boolean} auto_connect True if the network can be auto connected. |
|
Dan Beam
2012/05/07 17:43:53
can you change auto_connect to autoConnect?
kmadhusu
2012/05/08 20:20:19
Done.
|
| */ |
| function sendConnect(index, passphrase, identity, auto_connect) { |
| chrome.send('action', |
| @@ -53,6 +57,10 @@ var networkMenuItemProto = (function() { |
| return networkMenuItem; |
| })(); |
| +/** |
| + * Network menu item class |
| + * @constructor |
| + */ |
| var NetworkMenuItem = cr.ui.define(function() { |
| return networkMenuItemProto.cloneNode(true); |
| }); |
| @@ -66,6 +74,7 @@ NetworkMenuItem.prototype = { |
| /** |
| * The label element. |
| + * @this {NetworkMenuItem} |
| * @private |
| */ |
| get label_() { |
| @@ -74,6 +83,7 @@ NetworkMenuItem.prototype = { |
| /** |
| * The icon element. |
| + * @this {NetworkMenuItem} |
| * @private |
| */ |
| get icon_() { |
| @@ -82,6 +92,7 @@ NetworkMenuItem.prototype = { |
| /** |
| * The status area element. |
| + * @this {NetworkMenuItem} |
| * @private |
| */ |
| get status_() { |
| @@ -90,6 +101,7 @@ NetworkMenuItem.prototype = { |
| /** |
| * The action area container element. |
| + * @this {NetworkMenuItem} |
| * @private |
| */ |
| get action_() { |
| @@ -99,6 +111,7 @@ NetworkMenuItem.prototype = { |
| /** |
| * Set status message. |
| * @param {string} message The message to display in status area. |
| + * @this {NetworkMenuItem} |
| * @private |
| */ |
| setStatus_: function(message) { |
| @@ -113,6 +126,7 @@ NetworkMenuItem.prototype = { |
| /** |
| * Set status icon. |
| * @param {string} icon Source url for the icon image. |
| + * @this {NetworkMenuItem} |
| * @private |
| */ |
| setIcon_: function(icon) { |
| @@ -126,9 +140,10 @@ NetworkMenuItem.prototype = { |
| /** |
| * Handle reconnect. |
| + * @this {NetworkMenuItem} |
| * @private |
| */ |
| - handleConnect_ : function(e) { |
| + handleConnect_: function(e) { |
| var index = this.menu_.getMenuItemIndexOf(this); |
| if (this.ssidEdit && this.passwordEdit) { |
| if (this.ssidEdit.value) { |
| @@ -153,6 +168,7 @@ NetworkMenuItem.prototype = { |
| /** |
| * Handle keydown event in ssid edit. |
| + * @this {NetworkMenuItem} |
| * @private |
| */ |
| handleSsidEditKeydown_: function(e) { |
| @@ -164,6 +180,7 @@ NetworkMenuItem.prototype = { |
| /** |
| * Handle keydown event in password edit. |
| + * @this {NetworkMenuItem} |
| * @private |
| */ |
| handlePassEditKeydown_: function(e) { |
| @@ -175,6 +192,8 @@ NetworkMenuItem.prototype = { |
| /** |
| * Returns whether action area is visible. |
| + * @this {NetworkMenuItem} |
| + * @return {boolean} True if the action area is visible. |
| * @private |
| */ |
| isActionVisible_: function() { |
| @@ -183,6 +202,7 @@ NetworkMenuItem.prototype = { |
| /** |
| * Show/hide action area. |
| + * @this {NetworkMenuItem} |
| * @private |
| */ |
| showAction_: function(show) { |
| @@ -196,6 +216,7 @@ NetworkMenuItem.prototype = { |
| /** |
| * Add network name edit to action area. |
| + * @this {NetworkMenuItem} |
| * @private |
| */ |
| addSsidEdit_: function() { |
| @@ -213,6 +234,7 @@ NetworkMenuItem.prototype = { |
| /** |
| * Add password edit to action area. |
| + * @this {NetworkMenuItem} |
| * @private |
| */ |
| addPasswordEdit_: function() { |
| @@ -230,6 +252,7 @@ NetworkMenuItem.prototype = { |
| /** |
| * Add auto-connect this network check box to action area. |
| + * @this {NetworkMenuItem} |
| * @private |
| */ |
| addAutoConnectCheckbox_: function() { |
| @@ -250,6 +273,7 @@ NetworkMenuItem.prototype = { |
| /** |
| * Internal method to initiailze the MenuItem. |
| + * @this {NetworkMenuItem} |
| * @private |
| */ |
| initMenuItem_: function() { |
| @@ -263,19 +287,19 @@ NetworkMenuItem.prototype = { |
| // TODO: Handle specific types of network, connecting icon. |
| this.label_.textContent = attrs.label; |
| - if (attrs.network_type == NetworkOther) { |
| + if (attrs.network_type == networkOther) { |
| this.addSsidEdit_(); |
| this.addPasswordEdit_(); |
| this.addAutoConnectCheckbox_(); |
| } else if (attrs.status && attrs.status != 'unknown') { |
| - if (attrs.status == StatusConnected) { |
| + if (attrs.status == statusConnected) { |
| this.setStatus_(attrs.ip_address); |
| - } else if (attrs.status == StatusConnecting) { |
| + } else if (attrs.status == statusConnecting) { |
| this.setStatus_(attrs.message); |
| this.icon_.classList.add('spinner'); |
| this.icon_.classList.remove('hidden'); |
| - } else if (attrs.status == StatusError) { |
| + } else if (attrs.status == statusError) { |
| this.setStatus_(attrs.message); |
| this.setIcon_('chrome://theme/IDR_WARNING'); |
| @@ -306,7 +330,10 @@ NetworkMenuItem.prototype = { |
| } |
| }, |
| - /** @inheritDoc */ |
| + /** |
| + * @inheritDoc |
| + * @this {NetworkMenuItem} |
| + */ |
| activate: function() { |
| // Close action area and connect if it is visible. |
| if (this.isActionVisible_()) { |
| @@ -316,8 +343,8 @@ NetworkMenuItem.prototype = { |
| } |
| // Show action area for encrypted network and 'other' network. |
| - if ((this.attrs.network_type == NetworkOther || |
| - this.attrs.status == StatusDisconnected) && |
| + if ((this.attrs.network_type == networkOther || |
| + this.attrs.status == statusDisconnected) && |
| this.attrs.need_passphrase && |
| !this.isActionVisible_()) { |
| this.showAction_(true); |
| @@ -328,13 +355,21 @@ NetworkMenuItem.prototype = { |
| } |
| }; |
| - |
| +/** |
| + * Network Menu class. |
| + * @constructor |
| + * @extends {HTMLDivElement} |
| + */ |
| var NetworkMenu = cr.ui.define('div'); |
| NetworkMenu.prototype = { |
| __proto__: Menu.prototype, |
| - /** @inheritDoc */ |
| + /** |
| + * @inheritDoc |
| + * @this {NetworkMenu} |
| + * @return {Object} Network menu item. |
| + */ |
| createMenuItem: function(attrs) { |
| if (attrs.type == 'command') { |
| return new NetworkMenuItem(); |
| @@ -343,7 +378,10 @@ NetworkMenu.prototype = { |
| } |
| }, |
| - /** @inheritDoc */ |
| + /** |
| + * @inheritDoc |
| + * @this {NetworkMenu} |
| + */ |
| onClick_: function(event, item) { |
| // If item is a NetworkMenuItem, it must have at least one of the following. |
| if (item.autoConnectCheckbox || item.ssidEdit || item.passwordEdit) { |