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

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

Issue 8102019: redesign and reimplement proxy config service and tracker, revise proxy ui on cros (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 cr.define('options', function() { 5 cr.define('options', function() {
6 6
7 var OptionsPage = options.OptionsPage; 7 var OptionsPage = options.OptionsPage;
8 var Preferences = options.Preferences; 8 var Preferences = options.Preferences;
9 9
10 ///////////////////////////////////////////////////////////////////////////// 10 /////////////////////////////////////////////////////////////////////////////
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 37
38 ProxyOptions.prototype = { 38 ProxyOptions.prototype = {
39 // Inherit ProxyOptions from OptionsPage. 39 // Inherit ProxyOptions from OptionsPage.
40 __proto__: OptionsPage.prototype, 40 __proto__: OptionsPage.prototype,
41 41
42 /** 42 /**
43 * Initializes ProxyOptions page. 43 * Initializes ProxyOptions page.
44 */ 44 */
45 initializePage: function() { 45 initializePage: function() {
46 // Call base class implementation to starts preference initialization. 46 // Call base class implementation to start preference initialization.
47 OptionsPage.prototype.initializePage.call(this); 47 OptionsPage.prototype.initializePage.call(this);
48 48
49 // Set up ignored page. 49 // Set up ignored page.
50 options.proxyexceptions.ProxyExceptions.decorate($('ignoredHostList')); 50 options.proxyexceptions.ProxyExceptions.decorate($('ignoredHostList'));
51 51
52 this.addEventListener('visibleChange', this.handleVisibleChange_); 52 this.addEventListener('visibleChange', this.handleVisibleChange_);
53 $('removeHost').addEventListener('click', this.handleRemoveExceptions_); 53 $('removeHost').addEventListener('click', this.handleRemoveExceptions_);
54 $('addHost').addEventListener('click', this.handleAddException_); 54 $('addHost').addEventListener('click', this.handleAddException_);
55 $('directProxy').addEventListener('click', this.disableManual_); 55 $('directProxy').addEventListener('click', this.disableManual_);
56 $('manualProxy').addEventListener('click', this.enableManual_); 56 $('manualProxy').addEventListener('click', this.enableManual_);
57 $('autoProxy').addEventListener('click', this.disableManual_); 57 $('autoProxy').addEventListener('click', this.disableManual_);
58 $('proxyAllProtocols').addEventListener('click', this.toggleSingle_); 58 $('proxyAllProtocols').addEventListener('click', this.toggleSingle_);
59 59
60 observePrefsUI($('directProxy')); 60 observePrefsUI($('directProxy'));
61 observePrefsUI($('manualProxy')); 61 observePrefsUI($('manualProxy'));
62 observePrefsUI($('autoProxy')); 62 observePrefsUI($('autoProxy'));
63 observePrefsUI($('proxyAllProtocols')); 63 observePrefsUI($('proxyAllProtocols'));
64 }, 64 },
65 65
66 proxyListInitalized_: false, 66 proxyListInitialized_: false,
67 67
68 /** 68 /**
69 * Update controls state. 69 * Update controls state.
70 * @public 70 * @public
71 */ 71 */
72 updateControls: function() { 72 updateControls: function() {
73 this.updateBannerVisibility_();
73 this.toggleSingle_(); 74 this.toggleSingle_();
74 if ($('manualProxy').checked) { 75 if ($('manualProxy').checked) {
75 this.enableManual_(); 76 this.enableManual_();
76 } else { 77 } else {
77 this.disableManual_(); 78 this.disableManual_();
78 } 79 }
79 if (!this.proxyListInitalized_ && this.visible) { 80 if (!this.proxyListInitialized_ && this.visible) {
80 this.proxyListInitalized_ = true; 81 this.proxyListInitialized_ = true;
81 $('ignoredHostList').redraw(); 82 $('ignoredHostList').redraw();
82 } 83 }
83 }, 84 },
84 85
85 /** 86 /**
86 * Handler for OptionsPage's visible property change event. 87 * Handler for OptionsPage's visible property change event.
87 * @private 88 * @private
88 * @param {Event} e Property change event. 89 * @param {Event} e Property change event.
89 */ 90 */
90 handleVisibleChange_: function(e) { 91 handleVisibleChange_: function(e) {
91 this.updateControls(); 92 this.updateControls();
92 }, 93 },
93 94
94 /** 95 /**
96 * Updates info banner visibility state. This function shows the banner
97 * if proxy is managed or shared-proxies is off for shared network.
98 * @private
99 */
100 updateBannerVisibility_: function() {
101 var bannerDiv = $('info-banner');
102 // Remove class and listener for click event in case they were added
103 // before and updateBannerVisibility_ is called repeatedly.
104 bannerDiv.classList.remove("clickable");
105 bannerDiv.removeEventListener('click', this.handleSharedProxiesHint_);
106
107 // Show banner and determine its message if necessary.
108 var controlledBy = $('directProxy').controlledBy;
109 if (controlledBy == '') {
110 bannerDiv.hidden = true;
111 } else {
112 bannerDiv.hidden = false;
113 // controlledBy must match strings loaded in proxy_handler.cc and
114 // set in proxy_cros_settings_provider.cc.
115 $('banner-text').textContent = localStrings.getString(controlledBy);
116 if (controlledBy == "enableSharedProxiesBannerText") {
117 bannerDiv.classList.add("clickable");
118 bannerDiv.addEventListener('click', this.handleSharedProxiesHint_);
119 }
120 }
121 },
122
123 /**
124 * Handler for "click" event on yellow banner with enable-shared-proxies
125 * hint.
126 * @private
127 * @param {Event} e Click event fired from info-banner.
128 */
129 handleSharedProxiesHint_: function(e) {
130 OptionsPage.navigateToPage("internet");
131 },
132
133 /**
95 * Handler for when the user clicks on the checkbox to allow a 134 * Handler for when the user clicks on the checkbox to allow a
96 * single proxy usage. 135 * single proxy usage.
97 * @private 136 * @private
98 * @param {Event} e Click Event. 137 * @param {Event} e Click Event.
99 */ 138 */
100 toggleSingle_: function(e) { 139 toggleSingle_: function(e) {
101 if ($('proxyAllProtocols').checked) { 140 if ($('proxyAllProtocols').checked) {
102 $('multiProxy').style.display = 'none'; 141 $('multiProxy').style.display = 'none';
103 $('singleProxy').style.display = 'block'; 142 $('singleProxy').style.display = 'block';
104 } else { 143 } else {
105 $('multiProxy').style.display = 'block'; 144 $('multiProxy').style.display = 'block';
106 $('singleProxy').style.display = 'none'; 145 $('singleProxy').style.display = 'none';
107 } 146 }
108 }, 147 },
109 148
110 /** 149 /**
111 * Handler for selecting a radio button that will disable the manual 150 * Handler for selecting a radio button that will disable the manual
112 * controls. 151 * controls.
113 * @private 152 * @private
114 * @param {Event} e Click event. 153 * @param {Event} e Click event.
115 */ 154 */
116 disableManual_: function(e) { 155 disableManual_: function(e) {
156 $('advancedConfig').hidden = true;
117 $('proxyAllProtocols').disabled = true; 157 $('proxyAllProtocols').disabled = true;
118 $('proxyHostName').disabled = true; 158 $('proxyHostName').disabled = true;
119 $('proxyHostPort').disabled = true; 159 $('proxyHostPort').disabled = true;
120 $('proxyHostSingleName').disabled = true; 160 $('proxyHostSingleName').disabled = true;
121 $('proxyHostSinglePort').disabled = true; 161 $('proxyHostSinglePort').disabled = true;
122 $('secureProxyHostName').disabled = true; 162 $('secureProxyHostName').disabled = true;
123 $('secureProxyPort').disabled = true; 163 $('secureProxyPort').disabled = true;
124 $('ftpProxy').disabled = true; 164 $('ftpProxy').disabled = true;
125 $('ftpProxyPort').disabled = true; 165 $('ftpProxyPort').disabled = true;
126 $('socksHost').disabled = true; 166 $('socksHost').disabled = true;
127 $('socksPort').disabled = true; 167 $('socksPort').disabled = true;
128 $('newHost').disabled = true; 168 $('proxyConfig').disabled = $('autoProxy').disabled ||
129 $('removeHost').disabled = true; 169 !$('autoProxy').checked;
130 $('addHost').disabled = true;
131 $('advancedConfig').style.display = 'none';
132 $('proxyConfig').disabled = !$('autoProxy').checked;
133 }, 170 },
134 171
135 /** 172 /**
136 * Handler for selecting a radio button that will enable the manual 173 * Handler for selecting a radio button that will enable the manual
137 * controls. 174 * controls.
138 * @private 175 * @private
139 * @param {Event} e Click event. 176 * @param {Event} e Click event.
140 */ 177 */
141 enableManual_: function(e) { 178 enableManual_: function(e) {
142 $('proxyAllProtocols').disabled = false; 179 $('advancedConfig').hidden = false;
143 $('proxyHostName').disabled = false;
144 $('proxyHostPort').disabled = false;
145 $('proxyHostSingleName').disabled = false;
146 $('proxyHostSinglePort').disabled = false;
147 $('secureProxyHostName').disabled = false;
148 $('secureProxyPort').disabled = false;
149 $('ftpProxy').disabled = false;
150 $('ftpProxyPort').disabled = false;
151 $('socksHost').disabled = false;
152 $('socksPort').disabled = false;
153 $('newHost').disabled = false;
154 $('removeHost').disabled = false;
155 $('addHost').disabled = false;
156 $('advancedConfig').style.display = '-webkit-box';
157 $('ignoredHostList').redraw(); 180 $('ignoredHostList').redraw();
181 var all_disabled = $('manualProxy').disabled;
182 $('newHost').disabled = all_disabled;
183 $('removeHost').disabled = all_disabled;
184 $('addHost').disabled = all_disabled;
185 $('proxyAllProtocols').disabled = all_disabled;
186 $('proxyHostName').disabled = all_disabled;
187 $('proxyHostPort').disabled = all_disabled;
188 $('proxyHostSingleName').disabled = all_disabled;
189 $('proxyHostSinglePort').disabled = all_disabled;
190 $('secureProxyHostName').disabled = all_disabled;
191 $('secureProxyPort').disabled = all_disabled;
192 $('ftpProxy').disabled = all_disabled;
193 $('ftpProxyPort').disabled = all_disabled;
194 $('socksHost').disabled = all_disabled;
195 $('socksPort').disabled = all_disabled;
158 $('proxyConfig').disabled = true; 196 $('proxyConfig').disabled = true;
159 }, 197 },
160 198
161 /** 199 /**
162 * Handler for "add" event fired from userNameEdit. 200 * Handler for "add" event fired from userNameEdit.
163 * @private 201 * @private
164 * @param {Event} e Add event fired from userNameEdit. 202 * @param {Event} e Add event fired from userNameEdit.
165 */ 203 */
166 handleAddException_: function(e) { 204 handleAddException_: function(e) {
167 var exception = $('newHost').value; 205 var exception = $('newHost').value;
(...skipping 29 matching lines...) Expand all
197 ProxyOptions.setNetworkName = function(network) { 235 ProxyOptions.setNetworkName = function(network) {
198 ProxyOptions.getInstance().setNetworkName(network); 236 ProxyOptions.getInstance().setNetworkName(network);
199 }; 237 };
200 238
201 // Export 239 // Export
202 return { 240 return {
203 ProxyOptions: ProxyOptions 241 ProxyOptions: ProxyOptions
204 }; 242 };
205 243
206 }); 244 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698