*/
var IPInfo;
-/**
- * InternetDetailedInfo argument passed to showDetailedInfo.
- * @see chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
- * @typedef {{
- * servicePath: string,
- * showCarrierSelect: (boolean|undefined),
- * showViewAccountButton: (boolean|undefined)
- * }}
- */
-var InternetDetailedInfo;
-
cr.define('options.internet', function() {
var OncData = cr.onc.OncData;
var Page = cr.ui.pageManager.Page;
function sendCheckedIfEnabled(path, message, checkboxId, opt_action) {
var checkbox = assertInstanceof($(checkboxId), HTMLInputElement);
if (!checkbox.hidden && !checkbox.disabled) {
- chrome.send(message, [path, checkbox.checked ? 'true' : 'false']);
+ chrome.send(message, [path, !!checkbox.checked]);
if (opt_action)
sendChromeMetricsAction(opt_action);
}
// We show the Proxy configuration tab for remembered networks and when
// configuring a proxy from the login screen.
this.showProxy_ = false;
- // In Chrome we sometimes want to enable the Cellular carrier select UI.
- this.showCarrierSelect_ = false;
- // In Chrome we sometimes want to show the 'View Account' button.
- this.showViewAccountButton_ = false;
Page.call(this, 'detailsInternetPage', '', 'details-internet-page');
}
var servicePath = parseQueryParams(window.location).servicePath;
if (!servicePath || !servicePath.length)
return;
- var networkType = ''; // ignored for 'showDetails'
- chrome.send('networkCommand', [networkType, servicePath, 'showDetails']);
+ // TODO(stevenjb): chrome.networkingPrivate.getManagedProperties
+ // with initializeDetailsPage as the callback.
+ chrome.send('getManagedProperties', [servicePath]);
},
/**
*/
updateControls: function() {
// Note: onc may be undefined when called from a pref update before
- // initialized in sendNetworkDetails.
+ // initialized in initializeDetailsPage.
var onc = this.onc_;
// Always show the ipconfig section. TODO(stevenjb): Improve the display
},
/**
- * Helper method called from showDetailedInfo and updateConnectionData.
+ * Helper method called from initializeDetailsPage and updateConnectionData.
* Updates visibility/enabled of the login/disconnect/configure buttons.
* @private
*/
},
/**
- * Helper method called from showDetailedInfo and updateConnectionData.
+ * Helper method called from initializeDetailsPage and updateConnectionData.
* Updates the connection state property and account / sim card links.
* @private
*/
$('sim-card-lock-enabled').checked = lockEnabled;
$('change-pin').hidden = !lockEnabled;
}
- showViewAccount = this.showViewAccountButton_;
+ showViewAccount = onc.getActiveValue('showViewAccountButton');
var activationState = onc.getActiveValue('Cellular.ActivationState');
showActivate = activationState == 'NotActivated' ||
activationState == 'PartiallyActivated';
},
/**
- * Helper method called from showDetailedInfo and updateConnectionData.
+ * Helper method called from initializeDetailsPage and updateConnectionData.
* Updates the fields in the header section of the details frame.
* @private
*/
},
/**
- * Helper method called from showDetailedInfo to initialize the Apn list.
+ * Helper method called from initializeDetailsPage to initialize the Apn
+ * list.
* @private
*/
initializeApnList_: function() {
DetailsInternetPage.configureNetwork = function() {
var detailsPage = DetailsInternetPage.getInstance();
- chrome.send('networkCommand',
- [detailsPage.type_, detailsPage.servicePath_, 'configure']);
+ chrome.send('configureNetwork', [detailsPage.servicePath_]);
PageManager.closeOverlay();
};
DetailsInternetPage.activateFromDetails = function() {
var detailsPage = DetailsInternetPage.getInstance();
if (detailsPage.type_ == 'Cellular') {
- chrome.send('networkCommand',
- [detailsPage.type_, detailsPage.servicePath_, 'activate']);
+ chrome.send('activateNetwork', [detailsPage.servicePath_]);
}
PageManager.closeOverlay();
};
};
/**
- * Method called from Chrome with a dictionary of non ONC configuration
- * properties, including the HUID and service path to be used for requesting
- * the ONC properties. Note: currently GUID is only used to confirm that the
- * selected network still exists. It will be used instead of servicePath
- * once switching to the networkingPrivate API (see TODO below).
- * @param {InternetDetailedInfo} info
- */
- DetailsInternetPage.showDetailedInfo = function(info) {
- if (!('GUID' in info)) {
- // No network was found for, close the overlay.
- PageManager.closeOverlay();
- return;
- }
- var detailsPage = DetailsInternetPage.getInstance();
- detailsPage.servicePath_ = info.servicePath;
- detailsPage.showCarrierSelect_ = info.showCarrierSelect;
- detailsPage.showViewAccountButton_ = info.showViewAccountButton;
- // Ask Chrome to call sendNetworkDetails with the ONC properties.
- // TODO(stevenjb): Use networkingPrivate.getManagedProperties(info.guid).
- chrome.send('getManagedProperties', [info.servicePath]);
- };
-
- /**
* Method called from Chrome when the ONC properties for the displayed
* network may have changed.
- * @param {Object} update The updated ONC dictionary for the network.
+ * @param {Object} oncData The updated ONC dictionary for the network.
*/
DetailsInternetPage.updateConnectionData = function(oncData) {
var detailsPage = DetailsInternetPage.getInstance();
};
/**
- * Method called from Chrome when the initial dictionary of ONC configuration
- * properties is available.
+ * Method called from Chrome in response to getManagedProperties.
+ * We only use this when we want to call initializeDetailsPage.
+ * TODO(stevenjb): Eliminate when we switch to networkingPrivate
+ * (initializeDetailsPage will be provided as the callback).
+ * @param {Object} oncData Dictionary of ONC properties.
+ */
+ DetailsInternetPage.getManagedPropertiesResult = function(oncData) {
+ DetailsInternetPage.initializeDetailsPage(oncData);
+ };
+
+ /**
+ * Initializes the details page with the provided ONC data.
* @param {Object} oncData Dictionary of ONC properties.
*/
- DetailsInternetPage.sendNetworkDetails = function(oncData) {
+ DetailsInternetPage.initializeDetailsPage = function(oncData) {
var onc = new OncData(oncData);
var detailsPage = DetailsInternetPage.getInstance();
+ detailsPage.servicePath_ = oncData.servicePath;
detailsPage.onc_ = onc;
var type = onc.getActiveValue('Type');
detailsPage.type_ = type;
}
var savedPrefix = onc.getActiveValue('SavedIPConfig.RoutingPrefix');
if (savedPrefix != undefined) {
- var savedNetmask = prefixLengthToNetmask(savedPrefix);
+ assert(typeof savedPrefix == 'number');
+ var savedNetmask = prefixLengthToNetmask(
+ /** @type {number} */(savedPrefix));
inetNetmask.automatic = savedNetmask;
inetNetmask.value = savedNetmask;
}
}
var staticPrefix = onc.getActiveValue('StaticIPConfig.RoutingPrefix');
if (staticPrefix != undefined) {
- var staticNetmask = prefixLengthToNetmask(staticPrefix);
+ assert(typeof staticPrefix == 'number');
+ var staticNetmask = prefixLengthToNetmask(
+ /** @type {number} */(staticPrefix));
inetNetmask.user = staticNetmask;
inetNetmask.value = staticNetmask;
}
var isGsm = onc.getActiveValue('Cellular.Family') == 'GSM';
var currentCarrierIndex = -1;
- if (this.showCarrierSelect_) {
+ if (loadTimeData.getValue('showCarrierSelect')) {
var currentCarrier =
isGsm ? CarrierGenericUMTS : onc.getActiveValue('Cellular.Carrier');
var supportedCarriers =