OLD | NEW |
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 // require: onc_data.js | 5 // require: onc_data.js |
6 | 6 |
7 // NOTE(stevenjb): This code is in the process of being converted to be | 7 // NOTE(stevenjb): This code is in the process of being converted to be |
8 // compatible with the networkingPrivate extension API: | 8 // compatible with the networkingPrivate extension API: |
9 // * The network property dictionaries are being converted to use ONC values. | 9 // * The network property dictionaries are being converted to use ONC values. |
10 // * chrome.send calls will be replaced with an API object that simulates the | 10 // * chrome.send calls will be replaced with an API object that simulates the |
11 // networkingPrivate API. See network_config.js. | 11 // networkingPrivate API. See network_config.js. |
12 // See crbug.com/279351 for more info. | 12 // See crbug.com/279351 for more info. |
13 | 13 |
| 14 /** @typedef {{activationState: (string|undefined), |
| 15 * carriers: Array, |
| 16 * currentCarrierIndex; (number|undefined), |
| 17 * ipAutoConfig: boolean, |
| 18 * ipconfig: Object, |
| 19 * nameServerType: string, |
| 20 * restrictedPool: (string|undefined), |
| 21 * roamingState: (string|undefined), |
| 22 * savedIP: Object, |
| 23 * showActivateButton: (boolean|undefined) |
| 24 * showViewAccountButton: (boolean|undefined), |
| 25 * staticIP: Object}} |
| 26 * Only the keys which had caused problems are declared in this typedef. |
| 27 * There are many more of them. |
| 28 * @see chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc |
| 29 */ |
| 30 var InternetDetailedInfo; |
| 31 |
14 cr.define('options.internet', function() { | 32 cr.define('options.internet', function() { |
15 var OncData = cr.onc.OncData; | 33 var OncData = cr.onc.OncData; |
16 var Page = cr.ui.pageManager.Page; | 34 var Page = cr.ui.pageManager.Page; |
17 var PageManager = cr.ui.pageManager.PageManager; | 35 var PageManager = cr.ui.pageManager.PageManager; |
18 /** @const */ var IPAddressField = options.internet.IPAddressField; | 36 /** @const */ var IPAddressField = options.internet.IPAddressField; |
19 | 37 |
20 /** @const */ var GoogleNameServersString = '8.8.4.4,8.8.8.8'; | 38 /** @const */ var GoogleNameServersString = '8.8.4.4,8.8.8.8'; |
21 | 39 |
22 /** | 40 /** |
23 * Helper function to set hidden attribute for elements matching a selector. | 41 * Helper function to set hidden attribute for elements matching a selector. |
24 * @param {string} selector CSS selector for extracting a list of elements. | 42 * @param {string} selector CSS selector for extracting a list of elements. |
25 * @param {bool} hidden New hidden value. | 43 * @param {boolean} hidden New hidden value. |
26 */ | 44 */ |
27 function updateHidden(selector, hidden) { | 45 function updateHidden(selector, hidden) { |
28 var elements = cr.doc.querySelectorAll(selector); | 46 var elements = cr.doc.querySelectorAll(selector); |
29 for (var i = 0, el; el = elements[i]; i++) { | 47 for (var i = 0, el; el = elements[i]; i++) { |
30 el.hidden = hidden; | 48 el.hidden = hidden; |
31 } | 49 } |
32 } | 50 } |
33 | 51 |
34 /** | 52 /** |
35 * Helper function to update the properties of the data object from the | 53 * Helper function to update the properties of the data object from the |
(...skipping 20 matching lines...) Expand all Loading... |
56 * UI pref change handler. | 74 * UI pref change handler. |
57 * @param {Event} e The update event. | 75 * @param {Event} e The update event. |
58 */ | 76 */ |
59 function handlePrefUpdate(e) { | 77 function handlePrefUpdate(e) { |
60 DetailsInternetPage.getInstance().updateControls(); | 78 DetailsInternetPage.getInstance().updateControls(); |
61 } | 79 } |
62 | 80 |
63 /** | 81 /** |
64 * Simple helper method for converting a field to a string. It is used to | 82 * Simple helper method for converting a field to a string. It is used to |
65 * easily assign an empty string from fields that may be unknown or undefined. | 83 * easily assign an empty string from fields that may be unknown or undefined. |
66 * @param {object} value that should be converted to a string. | 84 * @param {Object} value that should be converted to a string. |
67 * @return {string} the result. | 85 * @return {string} the result. |
68 */ | 86 */ |
69 function stringFromValue(value) { | 87 function stringFromValue(value) { |
70 return value ? String(value) : ''; | 88 return value ? String(value) : ''; |
71 } | 89 } |
72 | 90 |
73 /** | 91 /** |
74 * Sends the 'checked' state of a control to chrome for a network. | 92 * Sends the 'checked' state of a control to chrome for a network. |
75 * @param {string} path The service path of the network. | 93 * @param {string} path The service path of the network. |
76 * @param {string} message The message to send to chrome. | 94 * @param {string} message The message to send to chrome. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 } | 126 } |
109 return netmask; | 127 return netmask; |
110 } | 128 } |
111 | 129 |
112 ///////////////////////////////////////////////////////////////////////////// | 130 ///////////////////////////////////////////////////////////////////////////// |
113 // DetailsInternetPage class: | 131 // DetailsInternetPage class: |
114 | 132 |
115 /** | 133 /** |
116 * Encapsulated handling of ChromeOS internet details overlay page. | 134 * Encapsulated handling of ChromeOS internet details overlay page. |
117 * @constructor | 135 * @constructor |
| 136 * @extends {cr.ui.pageManager.Page} |
118 */ | 137 */ |
119 function DetailsInternetPage() { | 138 function DetailsInternetPage() { |
120 // Cached Apn properties | 139 // Cached Apn properties |
121 this.userApnIndex_ = -1; | 140 this.userApnIndex_ = -1; |
122 this.selectedApnIndex_ = -1; | 141 this.selectedApnIndex_ = -1; |
123 this.userApn_ = {}; | 142 this.userApn_ = {}; |
124 // We show the Proxy configuration tab for remembered networks and when | 143 // We show the Proxy configuration tab for remembered networks and when |
125 // configuring a proxy from the login screen. | 144 // configuring a proxy from the login screen. |
126 this.showProxy_ = false; | 145 this.showProxy_ = false; |
127 // TODO(stevenjb): Use networkingPrivate.getNetworks to set this. | 146 // TODO(stevenjb): Use networkingPrivate.getNetworks to set this. |
128 this.deviceConnected_ = false; | 147 this.deviceConnected_ = false; |
129 Page.call(this, 'detailsInternetPage', null, 'details-internet-page'); | 148 Page.call(this, 'detailsInternetPage', '', 'details-internet-page'); |
130 } | 149 } |
131 | 150 |
132 cr.addSingletonGetter(DetailsInternetPage); | 151 cr.addSingletonGetter(DetailsInternetPage); |
133 | 152 |
134 DetailsInternetPage.prototype = { | 153 DetailsInternetPage.prototype = { |
135 __proto__: Page.prototype, | 154 __proto__: Page.prototype, |
136 | 155 |
137 /** @override */ | 156 /** @override */ |
138 initializePage: function() { | 157 initializePage: function() { |
139 Page.prototype.initializePage.call(this); | 158 Page.prototype.initializePage.call(this); |
140 var params = parseQueryParams(window.location); | 159 this.initializePageContents_(); |
141 this.initializePageContents_(params); | 160 this.showNetworkDetails_(); |
142 this.showNetworkDetails_(params); | |
143 }, | 161 }, |
144 | 162 |
145 /** | 163 /** |
146 * Auto-activates the network details dialog if network information | 164 * Auto-activates the network details dialog if network information |
147 * is included in the URL. | 165 * is included in the URL. |
148 */ | 166 */ |
149 showNetworkDetails_: function(params) { | 167 showNetworkDetails_: function() { |
150 var servicePath = params.servicePath; | 168 var servicePath = parseQueryParams(window.location).servicePath; |
151 if (!servicePath || !servicePath.length) | 169 if (!servicePath || !servicePath.length) |
152 return; | 170 return; |
153 var networkType = ''; // ignored for 'options' | 171 var networkType = ''; // ignored for 'options' |
154 chrome.send('networkCommand', [networkType, servicePath, 'options']); | 172 chrome.send('networkCommand', [networkType, servicePath, 'options']); |
155 }, | 173 }, |
156 | 174 |
157 /** | 175 /** |
158 * Initializes the contents of the page. | 176 * Initializes the contents of the page. |
159 */ | 177 */ |
160 initializePageContents_: function(params) { | 178 initializePageContents_: function() { |
161 $('details-internet-dismiss').addEventListener('click', function(event) { | 179 $('details-internet-dismiss').addEventListener('click', function(event) { |
162 DetailsInternetPage.setDetails(); | 180 DetailsInternetPage.setDetails(); |
163 }); | 181 }); |
164 | 182 |
165 $('details-internet-login').addEventListener('click', function(event) { | 183 $('details-internet-login').addEventListener('click', function(event) { |
166 DetailsInternetPage.setDetails(); | 184 DetailsInternetPage.setDetails(); |
167 DetailsInternetPage.loginFromDetails(); | 185 DetailsInternetPage.loginFromDetails(); |
168 }); | 186 }); |
169 | 187 |
170 $('details-internet-disconnect').addEventListener('click', | 188 $('details-internet-disconnect').addEventListener('click', |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 var bannerText = 'proxyBanner' + controlledBy.charAt(0).toUpperCase() + | 487 var bannerText = 'proxyBanner' + controlledBy.charAt(0).toUpperCase() + |
470 controlledBy.slice(1); | 488 controlledBy.slice(1); |
471 $('banner-text').textContent = loadTimeData.getString(bannerText); | 489 $('banner-text').textContent = loadTimeData.getString(bannerText); |
472 } | 490 } |
473 }, | 491 }, |
474 | 492 |
475 /** | 493 /** |
476 * Handler for when the user clicks on the checkbox to allow a | 494 * Handler for when the user clicks on the checkbox to allow a |
477 * single proxy usage. | 495 * single proxy usage. |
478 * @private | 496 * @private |
479 * @param {Event} e Click Event. | |
480 */ | 497 */ |
481 toggleSingleProxy_: function(e) { | 498 toggleSingleProxy_: function() { |
482 if ($('proxy-all-protocols').checked) { | 499 if ($('proxy-all-protocols').checked) { |
483 $('multi-proxy').hidden = true; | 500 $('multi-proxy').hidden = true; |
484 $('single-proxy').hidden = false; | 501 $('single-proxy').hidden = false; |
485 } else { | 502 } else { |
486 $('multi-proxy').hidden = false; | 503 $('multi-proxy').hidden = false; |
487 $('single-proxy').hidden = true; | 504 $('single-proxy').hidden = true; |
488 } | 505 } |
489 }, | 506 }, |
490 | 507 |
491 /** | 508 /** |
492 * Handler for when the user clicks on the checkbox to enter | 509 * Handler for when the user clicks on the checkbox to enter |
493 * auto configuration URL. | 510 * auto configuration URL. |
494 * @private | 511 * @private |
495 * @param {Event} e Click Event. | |
496 */ | 512 */ |
497 handleAutoConfigProxy_: function(e) { | 513 handleAutoConfigProxy_: function() { |
498 $('proxy-pac-url').disabled = !$('proxy-use-pac-url').checked; | 514 $('proxy-pac-url').disabled = !$('proxy-use-pac-url').checked; |
499 }, | 515 }, |
500 | 516 |
501 /** | 517 /** |
502 * Handler for selecting a radio button that will disable the manual | 518 * Handler for selecting a radio button that will disable the manual |
503 * controls. | 519 * controls. |
504 * @private | 520 * @private |
505 * @param {Event} e Click event. | |
506 */ | 521 */ |
507 disableManualProxy_: function(e) { | 522 disableManualProxy_: function() { |
508 $('ignored-host-list').disabled = true; | 523 $('ignored-host-list').disabled = true; |
509 $('new-host').disabled = true; | 524 $('new-host').disabled = true; |
510 $('remove-host').disabled = true; | 525 $('remove-host').disabled = true; |
511 $('add-host').disabled = true; | 526 $('add-host').disabled = true; |
512 $('proxy-all-protocols').disabled = true; | 527 $('proxy-all-protocols').disabled = true; |
513 $('proxy-host-name').disabled = true; | 528 $('proxy-host-name').disabled = true; |
514 $('proxy-host-port').disabled = true; | 529 $('proxy-host-port').disabled = true; |
515 $('proxy-host-single-name').disabled = true; | 530 $('proxy-host-single-name').disabled = true; |
516 $('proxy-host-single-port').disabled = true; | 531 $('proxy-host-single-port').disabled = true; |
517 $('secure-proxy-host-name').disabled = true; | 532 $('secure-proxy-host-name').disabled = true; |
518 $('secure-proxy-port').disabled = true; | 533 $('secure-proxy-port').disabled = true; |
519 $('ftp-proxy').disabled = true; | 534 $('ftp-proxy').disabled = true; |
520 $('ftp-proxy-port').disabled = true; | 535 $('ftp-proxy-port').disabled = true; |
521 $('socks-host').disabled = true; | 536 $('socks-host').disabled = true; |
522 $('socks-port').disabled = true; | 537 $('socks-port').disabled = true; |
523 $('proxy-use-pac-url').disabled = $('auto-proxy').disabled || | 538 $('proxy-use-pac-url').disabled = $('auto-proxy').disabled || |
524 !$('auto-proxy').checked; | 539 !$('auto-proxy').checked; |
525 $('proxy-pac-url').disabled = $('proxy-use-pac-url').disabled || | 540 $('proxy-pac-url').disabled = $('proxy-use-pac-url').disabled || |
526 !$('proxy-use-pac-url').checked; | 541 !$('proxy-use-pac-url').checked; |
527 $('auto-proxy-parms').hidden = !$('auto-proxy').checked; | 542 $('auto-proxy-parms').hidden = !$('auto-proxy').checked; |
528 $('manual-proxy-parms').hidden = !$('manual-proxy').checked; | 543 $('manual-proxy-parms').hidden = !$('manual-proxy').checked; |
529 chrome.send('coreOptionsUserMetricsAction', | 544 chrome.send('coreOptionsUserMetricsAction', |
530 ['Options_NetworkManualProxy_Disable']); | 545 ['Options_NetworkManualProxy_Disable']); |
531 }, | 546 }, |
532 | 547 |
533 /** | 548 /** |
534 * Handler for selecting a radio button that will enable the manual | 549 * Handler for selecting a radio button that will enable the manual |
535 * controls. | 550 * controls. |
536 * @private | 551 * @private |
537 * @param {Event} e Click event. | |
538 */ | 552 */ |
539 enableManualProxy_: function(e) { | 553 enableManualProxy_: function() { |
540 $('ignored-host-list').redraw(); | 554 $('ignored-host-list').redraw(); |
541 var allDisabled = $('manual-proxy').disabled; | 555 var allDisabled = $('manual-proxy').disabled; |
542 $('ignored-host-list').disabled = allDisabled; | 556 $('ignored-host-list').disabled = allDisabled; |
543 $('new-host').disabled = allDisabled; | 557 $('new-host').disabled = allDisabled; |
544 $('remove-host').disabled = allDisabled; | 558 $('remove-host').disabled = allDisabled; |
545 $('add-host').disabled = allDisabled; | 559 $('add-host').disabled = allDisabled; |
546 $('proxy-all-protocols').disabled = allDisabled; | 560 $('proxy-all-protocols').disabled = allDisabled; |
547 $('proxy-host-name').disabled = allDisabled; | 561 $('proxy-host-name').disabled = allDisabled; |
548 $('proxy-host-port').disabled = allDisabled; | 562 $('proxy-host-port').disabled = allDisabled; |
549 $('proxy-host-single-name').disabled = allDisabled; | 563 $('proxy-host-single-name').disabled = allDisabled; |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 } | 981 } |
968 PageManager.closeOverlay(); | 982 PageManager.closeOverlay(); |
969 }; | 983 }; |
970 | 984 |
971 DetailsInternetPage.setDetails = function() { | 985 DetailsInternetPage.setDetails = function() { |
972 var detailsPage = DetailsInternetPage.getInstance(); | 986 var detailsPage = DetailsInternetPage.getInstance(); |
973 var type = detailsPage.type_; | 987 var type = detailsPage.type_; |
974 var servicePath = detailsPage.servicePath_; | 988 var servicePath = detailsPage.servicePath_; |
975 if (type == 'WiFi') { | 989 if (type == 'WiFi') { |
976 sendCheckedIfEnabled(servicePath, 'setPreferNetwork', | 990 sendCheckedIfEnabled(servicePath, 'setPreferNetwork', |
977 $('prefer-network-wifi')); | 991 assertInstanceof($('prefer-network-wifi'), HTMLInputElement)); |
978 sendCheckedIfEnabled(servicePath, 'setAutoConnect', | 992 sendCheckedIfEnabled(servicePath, 'setAutoConnect', |
979 $('auto-connect-network-wifi')); | 993 assertInstanceof($('auto-connect-network-wifi'), HTMLInputElement)); |
980 } else if (type == 'Wimax') { | 994 } else if (type == 'Wimax') { |
981 sendCheckedIfEnabled(servicePath, 'setAutoConnect', | 995 sendCheckedIfEnabled(servicePath, 'setAutoConnect', |
982 $('auto-connect-network-wimax')); | 996 assertInstanceof($('auto-connect-network-wimax'), HTMLInputElement)); |
983 } else if (type == 'Cellular') { | 997 } else if (type == 'Cellular') { |
984 sendCheckedIfEnabled(servicePath, 'setAutoConnect', | 998 sendCheckedIfEnabled(servicePath, 'setAutoConnect', |
985 $('auto-connect-network-cellular')); | 999 assertInstanceof($('auto-connect-network-cellular'), |
| 1000 HTMLInputElement)); |
986 } else if (type == 'VPN') { | 1001 } else if (type == 'VPN') { |
987 chrome.send('setServerHostname', | 1002 chrome.send('setServerHostname', |
988 [servicePath, | 1003 [servicePath, |
989 $('inet-server-hostname').value]); | 1004 $('inet-server-hostname').value]); |
990 sendCheckedIfEnabled(servicePath, 'setAutoConnect', | 1005 sendCheckedIfEnabled(servicePath, 'setAutoConnect', |
991 $('auto-connect-network-vpn')); | 1006 assertInstanceof($('auto-connect-network-vpn'), HTMLInputElement)); |
992 } | 1007 } |
993 | 1008 |
994 var nameServerTypes = ['automatic', 'google', 'user']; | 1009 var nameServerTypes = ['automatic', 'google', 'user']; |
995 var nameServerType = 'automatic'; | 1010 var nameServerType = 'automatic'; |
996 for (var i = 0; i < nameServerTypes.length; ++i) { | 1011 for (var i = 0; i < nameServerTypes.length; ++i) { |
997 if ($(nameServerTypes[i] + '-dns-radio').checked) { | 1012 if ($(nameServerTypes[i] + '-dns-radio').checked) { |
998 nameServerType = nameServerTypes[i]; | 1013 nameServerType = nameServerTypes[i]; |
999 break; | 1014 break; |
1000 } | 1015 } |
1001 } | 1016 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 | 1079 |
1065 // Update our cached data object. | 1080 // Update our cached data object. |
1066 var onc = detailsPage.onc_; | 1081 var onc = detailsPage.onc_; |
1067 onc.updateData(update); | 1082 onc.updateData(update); |
1068 | 1083 |
1069 detailsPage.populateHeader_(); | 1084 detailsPage.populateHeader_(); |
1070 detailsPage.updateConnectionButtonVisibilty_(); | 1085 detailsPage.updateConnectionButtonVisibilty_(); |
1071 detailsPage.updateDetails_(update); | 1086 detailsPage.updateDetails_(update); |
1072 }; | 1087 }; |
1073 | 1088 |
| 1089 /** |
| 1090 * @param {InternetDetailedInfo} data |
| 1091 */ |
1074 DetailsInternetPage.showDetailedInfo = function(data) { | 1092 DetailsInternetPage.showDetailedInfo = function(data) { |
1075 var onc = new OncData(data); | 1093 var onc = new OncData(data); |
1076 | 1094 |
1077 var detailsPage = DetailsInternetPage.getInstance(); | 1095 var detailsPage = DetailsInternetPage.getInstance(); |
1078 detailsPage.onc_ = onc; | 1096 detailsPage.onc_ = onc; |
1079 var type = onc.getActiveValue('Type'); | 1097 var type = onc.getActiveValue('Type'); |
1080 detailsPage.type_ = type; | 1098 detailsPage.type_ = type; |
1081 detailsPage.servicePath_ = data.servicePath; | 1099 detailsPage.servicePath_ = data.servicePath; |
1082 | 1100 |
1083 detailsPage.populateHeader_(); | 1101 detailsPage.populateHeader_(); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 | 1439 |
1422 // Don't show page name in address bar and in history to prevent people | 1440 // Don't show page name in address bar and in history to prevent people |
1423 // navigate here by hand and solve issue with page session restore. | 1441 // navigate here by hand and solve issue with page session restore. |
1424 PageManager.showPageByName('detailsInternetPage', false); | 1442 PageManager.showPageByName('detailsInternetPage', false); |
1425 }; | 1443 }; |
1426 | 1444 |
1427 return { | 1445 return { |
1428 DetailsInternetPage: DetailsInternetPage | 1446 DetailsInternetPage: DetailsInternetPage |
1429 }; | 1447 }; |
1430 }); | 1448 }); |
OLD | NEW |