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

Side by Side Diff: chrome/browser/resources/options/chromeos/internet_detail.js

Issue 570743002: Move network settings metrics to JS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_279351_internet_options_10b
Patch Set: Rebase Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/options/chromeos/network_list.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 * Simple helper method for converting a field to a string. It is used to 78 * Simple helper method for converting a field to a string. It is used to
79 * easily assign an empty string from fields that may be unknown or undefined. 79 * easily assign an empty string from fields that may be unknown or undefined.
80 * @param {Object} value that should be converted to a string. 80 * @param {Object} value that should be converted to a string.
81 * @return {string} the result. 81 * @return {string} the result.
82 */ 82 */
83 function stringFromValue(value) { 83 function stringFromValue(value) {
84 return value ? String(value) : ''; 84 return value ? String(value) : '';
85 } 85 }
86 86
87 /** 87 /**
88 * @param {string} action An action to send to coreOptionsUserMetricsAction.
89 */
90 function sendChromeMetricsAction(action) {
91 chrome.send('coreOptionsUserMetricsAction', [action]);
92 }
93
94 /**
88 * Sends the 'checked' state of a control to chrome for a network. 95 * Sends the 'checked' state of a control to chrome for a network.
89 * @param {string} path The service path of the network. 96 * @param {string} path The service path of the network.
90 * @param {string} message The message to send to chrome. 97 * @param {string} message The message to send to chrome.
91 * @param {HTMLInputElement} checkbox The checkbox storing the value to send. 98 * @param {string} checkboxId The id of the checkbox with the value to send.
99 * @param {string=} opt_action Optional action to record.
92 */ 100 */
93 function sendCheckedIfEnabled(path, message, checkbox) { 101 function sendCheckedIfEnabled(path, message, checkboxId, opt_action) {
94 if (!checkbox.hidden && !checkbox.disabled) 102 var checkbox = assertInstanceof($(checkboxId), HTMLInputElement);
103 if (!checkbox.hidden && !checkbox.disabled) {
95 chrome.send(message, [path, checkbox.checked ? 'true' : 'false']); 104 chrome.send(message, [path, checkbox.checked ? 'true' : 'false']);
105 if (opt_action)
106 sendChromeMetricsAction(opt_action);
107 }
96 } 108 }
97 109
98 /** 110 /**
111 * Send metrics to Chrome when the detailed page is opened.
112 * @param {string} type The ONC type of the network being shown.
113 * @param {string} state The ONC network state.
114 */
115 function sendShowDetailsMetrics(type, state) {
116 if (type == 'WiFi') {
117 sendChromeMetricsAction('Options_NetworkShowDetailsWifi');
118 if (state != 'NotConnected')
119 sendChromeMetricsAction('Options_NetworkShowDetailsWifiConnected');
120 } else if (type == 'Cellular') {
121 sendChromeMetricsAction('Options_NetworkShowDetailsCellular');
122 if (state != 'NotConnected')
123 sendChromeMetricsAction('Options_NetworkShowDetailsCellularConnected');
124 } else if (type == 'VPN') {
125 sendChromeMetricsAction('Options_NetworkShowDetailsVPN');
126 if (state != 'NotConnected')
127 sendChromeMetricsAction('Options_NetworkShowDetailsVPNConnected');
128 }
129 }
130
131 /**
99 * Returns the netmask as a string for a given prefix length. 132 * Returns the netmask as a string for a given prefix length.
100 * @param {number} prefixLength The ONC routing prefix length. 133 * @param {number} prefixLength The ONC routing prefix length.
101 * @return {string} The corresponding netmask. 134 * @return {string} The corresponding netmask.
102 */ 135 */
103 function prefixLengthToNetmask(prefixLength) { 136 function prefixLengthToNetmask(prefixLength) {
104 // Return the empty string for invalid inputs. 137 // Return the empty string for invalid inputs.
105 if (prefixLength < 0 || prefixLength > 32) 138 if (prefixLength < 0 || prefixLength > 32)
106 return ''; 139 return '';
107 var netmask = ''; 140 var netmask = '';
108 for (var i = 0; i < 4; ++i) { 141 for (var i = 0; i < 4; ++i) {
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 $('ftp-proxy').disabled = true; 563 $('ftp-proxy').disabled = true;
531 $('ftp-proxy-port').disabled = true; 564 $('ftp-proxy-port').disabled = true;
532 $('socks-host').disabled = true; 565 $('socks-host').disabled = true;
533 $('socks-port').disabled = true; 566 $('socks-port').disabled = true;
534 $('proxy-use-pac-url').disabled = $('auto-proxy').disabled || 567 $('proxy-use-pac-url').disabled = $('auto-proxy').disabled ||
535 !$('auto-proxy').checked; 568 !$('auto-proxy').checked;
536 $('proxy-pac-url').disabled = $('proxy-use-pac-url').disabled || 569 $('proxy-pac-url').disabled = $('proxy-use-pac-url').disabled ||
537 !$('proxy-use-pac-url').checked; 570 !$('proxy-use-pac-url').checked;
538 $('auto-proxy-parms').hidden = !$('auto-proxy').checked; 571 $('auto-proxy-parms').hidden = !$('auto-proxy').checked;
539 $('manual-proxy-parms').hidden = !$('manual-proxy').checked; 572 $('manual-proxy-parms').hidden = !$('manual-proxy').checked;
540 chrome.send('coreOptionsUserMetricsAction', 573 sendChromeMetricsAction('Options_NetworkManualProxy_Disable');
541 ['Options_NetworkManualProxy_Disable']);
542 }, 574 },
543 575
544 /** 576 /**
545 * Handler for selecting a radio button that will enable the manual 577 * Handler for selecting a radio button that will enable the manual
546 * controls. 578 * controls.
547 * @private 579 * @private
548 */ 580 */
549 enableManualProxy_: function() { 581 enableManualProxy_: function() {
550 $('ignored-host-list').redraw(); 582 $('ignored-host-list').redraw();
551 var allDisabled = $('manual-proxy').disabled; 583 var allDisabled = $('manual-proxy').disabled;
552 $('ignored-host-list').disabled = allDisabled; 584 $('ignored-host-list').disabled = allDisabled;
553 $('new-host').disabled = allDisabled; 585 $('new-host').disabled = allDisabled;
554 $('remove-host').disabled = allDisabled; 586 $('remove-host').disabled = allDisabled;
555 $('add-host').disabled = allDisabled; 587 $('add-host').disabled = allDisabled;
556 $('proxy-all-protocols').disabled = allDisabled; 588 $('proxy-all-protocols').disabled = allDisabled;
557 $('proxy-host-name').disabled = allDisabled; 589 $('proxy-host-name').disabled = allDisabled;
558 $('proxy-host-port').disabled = allDisabled; 590 $('proxy-host-port').disabled = allDisabled;
559 $('proxy-host-single-name').disabled = allDisabled; 591 $('proxy-host-single-name').disabled = allDisabled;
560 $('proxy-host-single-port').disabled = allDisabled; 592 $('proxy-host-single-port').disabled = allDisabled;
561 $('secure-proxy-host-name').disabled = allDisabled; 593 $('secure-proxy-host-name').disabled = allDisabled;
562 $('secure-proxy-port').disabled = allDisabled; 594 $('secure-proxy-port').disabled = allDisabled;
563 $('ftp-proxy').disabled = allDisabled; 595 $('ftp-proxy').disabled = allDisabled;
564 $('ftp-proxy-port').disabled = allDisabled; 596 $('ftp-proxy-port').disabled = allDisabled;
565 $('socks-host').disabled = allDisabled; 597 $('socks-host').disabled = allDisabled;
566 $('socks-port').disabled = allDisabled; 598 $('socks-port').disabled = allDisabled;
567 $('proxy-use-pac-url').disabled = true; 599 $('proxy-use-pac-url').disabled = true;
568 $('proxy-pac-url').disabled = true; 600 $('proxy-pac-url').disabled = true;
569 $('auto-proxy-parms').hidden = !$('auto-proxy').checked; 601 $('auto-proxy-parms').hidden = !$('auto-proxy').checked;
570 $('manual-proxy-parms').hidden = !$('manual-proxy').checked; 602 $('manual-proxy-parms').hidden = !$('manual-proxy').checked;
571 chrome.send('coreOptionsUserMetricsAction', 603 sendChromeMetricsAction('Options_NetworkManualProxy_Enable');
572 ['Options_NetworkManualProxy_Enable']);
573 }, 604 },
574 605
575 /** 606 /**
576 * Helper method called from showDetailedInfo and updateConnectionData. 607 * Helper method called from showDetailedInfo and updateConnectionData.
577 * Updates visibilty/enabled of the login/disconnect/configure buttons. 608 * Updates visibilty/enabled of the login/disconnect/configure buttons.
578 * @private 609 * @private
579 */ 610 */
580 updateConnectionButtonVisibilty_: function() { 611 updateConnectionButtonVisibilty_: function() {
581 var onc = this.onc_; 612 var onc = this.onc_;
582 if (this.type_ == 'Ethernet') { 613 if (this.type_ == 'Ethernet') {
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 $('network-details-header').hidden = true; 962 $('network-details-header').hidden = true;
932 $('activate-details').hidden = true; 963 $('activate-details').hidden = true;
933 $('view-account-details').hidden = true; 964 $('view-account-details').hidden = true;
934 $('web-proxy-auto-discovery').hidden = true; 965 $('web-proxy-auto-discovery').hidden = true;
935 detailsPage.showProxy_ = true; 966 detailsPage.showProxy_ = true;
936 updateHidden('#internet-tab', true); 967 updateHidden('#internet-tab', true);
937 updateHidden('#details-tab-strip', true); 968 updateHidden('#details-tab-strip', true);
938 updateHidden('#details-internet-page .action-area', true); 969 updateHidden('#details-internet-page .action-area', true);
939 detailsPage.updateControls(); 970 detailsPage.updateControls();
940 detailsPage.visible = true; 971 detailsPage.visible = true;
941 chrome.send('coreOptionsUserMetricsAction', 972 sendChromeMetricsAction('Options_NetworkShowProxyTab');
942 ['Options_NetworkShowProxyTab']);
943 }; 973 };
944 974
945 /** 975 /**
946 * Initializes even handling for keyboard driven flow. 976 * Initializes even handling for keyboard driven flow.
947 */ 977 */
948 DetailsInternetPage.initializeKeyboardFlow = function() { 978 DetailsInternetPage.initializeKeyboardFlow = function() {
949 keyboard.initializeKeyboardFlow(); 979 keyboard.initializeKeyboardFlow();
950 }; 980 };
951 981
952 DetailsInternetPage.updateProxySettings = function(type) { 982 DetailsInternetPage.updateProxySettings = function(type) {
(...skipping 28 matching lines...) Expand all
981 } 1011 }
982 } 1012 }
983 }; 1013 };
984 1014
985 DetailsInternetPage.updateCarrier = function() { 1015 DetailsInternetPage.updateCarrier = function() {
986 DetailsInternetPage.showCarrierChangeSpinner(false); 1016 DetailsInternetPage.showCarrierChangeSpinner(false);
987 }; 1017 };
988 1018
989 DetailsInternetPage.loginFromDetails = function() { 1019 DetailsInternetPage.loginFromDetails = function() {
990 var detailsPage = DetailsInternetPage.getInstance(); 1020 var detailsPage = DetailsInternetPage.getInstance();
1021 if (detailsPage.type_ == 'WiFi')
1022 sendChromeMetricsAction('Options_NetworkConnectToWifi');
1023 else if (detailsPage.type_ == 'VPN')
1024 sendChromeMetricsAction('Options_NetworkConnectToVPN');
991 chrome.send('networkCommand', 1025 chrome.send('networkCommand',
992 [detailsPage.type_, detailsPage.servicePath_, 'connect']); 1026 [detailsPage.type_, detailsPage.servicePath_, 'connect']);
993 PageManager.closeOverlay(); 1027 PageManager.closeOverlay();
994 }; 1028 };
995 1029
996 DetailsInternetPage.disconnectNetwork = function() { 1030 DetailsInternetPage.disconnectNetwork = function() {
997 var detailsPage = DetailsInternetPage.getInstance(); 1031 var detailsPage = DetailsInternetPage.getInstance();
1032 if (detailsPage.type_ == 'WiFi')
1033 sendChromeMetricsAction('Options_NetworkDisconnectWifi');
1034 else if (detailsPage.type_ == 'VPN')
1035 sendChromeMetricsAction('Options_NetworkDisconnectVPN');
998 chrome.send('networkCommand', 1036 chrome.send('networkCommand',
999 [detailsPage.type_, detailsPage.servicePath_, 'disconnect']); 1037 [detailsPage.type_, detailsPage.servicePath_, 'disconnect']);
1000 PageManager.closeOverlay(); 1038 PageManager.closeOverlay();
1001 }; 1039 };
1002 1040
1003 DetailsInternetPage.configureNetwork = function() { 1041 DetailsInternetPage.configureNetwork = function() {
1004 var detailsPage = DetailsInternetPage.getInstance(); 1042 var detailsPage = DetailsInternetPage.getInstance();
1005 chrome.send('networkCommand', 1043 chrome.send('networkCommand',
1006 [detailsPage.type_, detailsPage.servicePath_, 'configure']); 1044 [detailsPage.type_, detailsPage.servicePath_, 'configure']);
1007 PageManager.closeOverlay(); 1045 PageManager.closeOverlay();
1008 }; 1046 };
1009 1047
1010 DetailsInternetPage.activateFromDetails = function() { 1048 DetailsInternetPage.activateFromDetails = function() {
1011 var detailsPage = DetailsInternetPage.getInstance(); 1049 var detailsPage = DetailsInternetPage.getInstance();
1012 if (detailsPage.type_ == 'Cellular') { 1050 if (detailsPage.type_ == 'Cellular') {
1013 chrome.send('networkCommand', 1051 chrome.send('networkCommand',
1014 [detailsPage.type_, detailsPage.servicePath_, 'activate']); 1052 [detailsPage.type_, detailsPage.servicePath_, 'activate']);
1015 } 1053 }
1016 PageManager.closeOverlay(); 1054 PageManager.closeOverlay();
1017 }; 1055 };
1018 1056
1019 DetailsInternetPage.setDetails = function() { 1057 DetailsInternetPage.setDetails = function() {
1020 var detailsPage = DetailsInternetPage.getInstance(); 1058 var detailsPage = DetailsInternetPage.getInstance();
1021 var type = detailsPage.type_; 1059 var type = detailsPage.type_;
1022 var servicePath = detailsPage.servicePath_; 1060 var servicePath = detailsPage.servicePath_;
1023 if (type == 'WiFi') { 1061 if (type == 'WiFi') {
1024 sendCheckedIfEnabled(servicePath, 'setPreferNetwork', 1062 sendCheckedIfEnabled(servicePath,
1025 assertInstanceof($('prefer-network-wifi'), HTMLInputElement)); 1063 'setPreferNetwork',
1026 sendCheckedIfEnabled(servicePath, 'setAutoConnect', 1064 'prefer-network-wifi',
1027 assertInstanceof($('auto-connect-network-wifi'), HTMLInputElement)); 1065 'Options_NetworkSetPrefer');
1066 sendCheckedIfEnabled(servicePath,
1067 'setAutoConnect',
1068 'auto-connect-network-wifi',
1069 'Options_NetworkAutoConnect');
1028 } else if (type == 'Wimax') { 1070 } else if (type == 'Wimax') {
1029 sendCheckedIfEnabled(servicePath, 'setAutoConnect', 1071 sendCheckedIfEnabled(servicePath,
1030 assertInstanceof($('auto-connect-network-wimax'), HTMLInputElement)); 1072 'setAutoConnect',
1073 'auto-connect-network-wimax',
1074 'Options_NetworkAutoConnect');
1031 } else if (type == 'Cellular') { 1075 } else if (type == 'Cellular') {
1032 sendCheckedIfEnabled(servicePath, 'setAutoConnect', 1076 sendCheckedIfEnabled(servicePath,
1033 assertInstanceof($('auto-connect-network-cellular'), 1077 'setAutoConnect',
1034 HTMLInputElement)); 1078 'auto-connect-network-cellular',
1079 'Options_NetworkAutoConnect');
1035 } else if (type == 'VPN') { 1080 } else if (type == 'VPN') {
1036 chrome.send('setServerHostname', 1081 chrome.send('setServerHostname',
1037 [servicePath, 1082 [servicePath, $('inet-server-hostname').value]);
1038 $('inet-server-hostname').value]); 1083 sendCheckedIfEnabled(servicePath,
1039 sendCheckedIfEnabled(servicePath, 'setAutoConnect', 1084 'setAutoConnect',
1040 assertInstanceof($('auto-connect-network-vpn'), HTMLInputElement)); 1085 'auto-connect-network-vpn',
1086 'Options_NetworkAutoConnect');
1041 } 1087 }
1042 1088
1043 var nameServerTypes = ['automatic', 'google', 'user']; 1089 var nameServerTypes = ['automatic', 'google', 'user'];
1044 var nameServerType = 'automatic'; 1090 var nameServerType = 'automatic';
1045 for (var i = 0; i < nameServerTypes.length; ++i) { 1091 for (var i = 0; i < nameServerTypes.length; ++i) {
1046 if ($(nameServerTypes[i] + '-dns-radio').checked) { 1092 if ($(nameServerTypes[i] + '-dns-radio').checked) {
1047 nameServerType = nameServerTypes[i]; 1093 nameServerType = nameServerTypes[i];
1048 break; 1094 break;
1049 } 1095 }
1050 } 1096 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 */ 1171 */
1126 DetailsInternetPage.showDetailedInfo = function(data) { 1172 DetailsInternetPage.showDetailedInfo = function(data) {
1127 var onc = new OncData(data); 1173 var onc = new OncData(data);
1128 1174
1129 var detailsPage = DetailsInternetPage.getInstance(); 1175 var detailsPage = DetailsInternetPage.getInstance();
1130 detailsPage.onc_ = onc; 1176 detailsPage.onc_ = onc;
1131 var type = onc.getActiveValue('Type'); 1177 var type = onc.getActiveValue('Type');
1132 detailsPage.type_ = type; 1178 detailsPage.type_ = type;
1133 detailsPage.servicePath_ = data.servicePath; 1179 detailsPage.servicePath_ = data.servicePath;
1134 1180
1181 sendShowDetailsMetrics(type, onc.getActiveValue('ConnectionState'));
1182
1135 detailsPage.populateHeader_(); 1183 detailsPage.populateHeader_();
1136 detailsPage.updateConnectionButtonVisibilty_(); 1184 detailsPage.updateConnectionButtonVisibilty_();
1137 detailsPage.updateDetails_(data); 1185 detailsPage.updateDetails_(data);
1138 1186
1139 // TODO(stevenjb): Some of the setup below should be moved to 1187 // TODO(stevenjb): Some of the setup below should be moved to
1140 // updateDetails_() so that updates are reflected in the UI. 1188 // updateDetails_() so that updates are reflected in the UI.
1141 1189
1142 // Only show proxy for remembered networks. 1190 // Only show proxy for remembered networks.
1143 var remembered = onc.getSource() != 'None'; 1191 var remembered = onc.getSource() != 'None';
1144 if (remembered) { 1192 if (remembered) {
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 1548
1501 // Don't show page name in address bar and in history to prevent people 1549 // Don't show page name in address bar and in history to prevent people
1502 // navigate here by hand and solve issue with page session restore. 1550 // navigate here by hand and solve issue with page session restore.
1503 PageManager.showPageByName('detailsInternetPage', false); 1551 PageManager.showPageByName('detailsInternetPage', false);
1504 }; 1552 };
1505 1553
1506 return { 1554 return {
1507 DetailsInternetPage: DetailsInternetPage 1555 DetailsInternetPage: DetailsInternetPage
1508 }; 1556 };
1509 }); 1557 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/options/chromeos/network_list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698