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

Side by Side Diff: chrome/browser/resources/net_internals/browser_bridge.js

Issue 8741009: ONC import option to chromeos tab in chrome://net-internals (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review feedback Created 9 years 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 /** 5 /**
6 * This class provides a "bridge" for communicating between the javascript and 6 * This class provides a "bridge" for communicating between the javascript and
7 * the browser. 7 * the browser.
8 */ 8 */
9 var BrowserBridge = (function() { 9 var BrowserBridge = (function() {
10 'use strict'; 10 'use strict';
11 11
12 /** 12 /**
13 * Delay in milliseconds between updates of certain browser information. 13 * Delay in milliseconds between updates of certain browser information.
14 */ 14 */
15 var POLL_INTERVAL_MS = 5000; 15 var POLL_INTERVAL_MS = 5000;
16 16
17 /** 17 /**
18 * @constructor 18 * @constructor
19 */ 19 */
20 function BrowserBridge() { 20 function BrowserBridge() {
21 assertFirstConstructorCall(BrowserBridge); 21 assertFirstConstructorCall(BrowserBridge);
22 22
23 // List of observers for various bits of browser state. 23 // List of observers for various bits of browser state.
24 this.connectionTestsObservers_ = []; 24 this.connectionTestsObservers_ = [];
25 this.hstsObservers_ = []; 25 this.hstsObservers_ = [];
26 this.httpThrottlingObservers_ = []; 26 this.httpThrottlingObservers_ = [];
27 this.constantsObservers_ = []; 27 this.constantsObservers_ = [];
28 this.crosONCFileParseObservers_ = [];
28 29
29 this.pollableDataHelpers_ = {}; 30 this.pollableDataHelpers_ = {};
30 this.pollableDataHelpers_.proxySettings = 31 this.pollableDataHelpers_.proxySettings =
31 new PollableDataHelper('onProxySettingsChanged', 32 new PollableDataHelper('onProxySettingsChanged',
32 this.sendGetProxySettings.bind(this)); 33 this.sendGetProxySettings.bind(this));
33 this.pollableDataHelpers_.badProxies = 34 this.pollableDataHelpers_.badProxies =
34 new PollableDataHelper('onBadProxiesChanged', 35 new PollableDataHelper('onBadProxiesChanged',
35 this.sendGetBadProxies.bind(this)); 36 this.sendGetBadProxies.bind(this));
36 this.pollableDataHelpers_.httpCacheInfo = 37 this.pollableDataHelpers_.httpCacheInfo =
37 new PollableDataHelper('onHttpCacheInfoChanged', 38 new PollableDataHelper('onHttpCacheInfoChanged',
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 }, 218 },
218 219
219 refreshSystemLogs: function() { 220 refreshSystemLogs: function() {
220 this.send('refreshSystemLogs'); 221 this.send('refreshSystemLogs');
221 }, 222 },
222 223
223 getSystemLog: function(log_key, cellId) { 224 getSystemLog: function(log_key, cellId) {
224 this.send('getSystemLog', [log_key, cellId]); 225 this.send('getSystemLog', [log_key, cellId]);
225 }, 226 },
226 227
228 importONCFile: function(fileContent, passcode) {
229 this.send('importONCFile', [fileContent, passcode]);
230 },
231
227 //-------------------------------------------------------------------------- 232 //--------------------------------------------------------------------------
228 // Messages received from the browser. 233 // Messages received from the browser.
229 //-------------------------------------------------------------------------- 234 //--------------------------------------------------------------------------
230 235
231 receive: function(command, params) { 236 receive: function(command, params) {
232 // Does nothing if disabled. 237 // Does nothing if disabled.
233 if (this.disabled_) 238 if (this.disabled_)
234 return; 239 return;
235 this[command](params); 240 this[command](params);
236 }, 241 },
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 receivedCompletedConnectionTestSuite: function() { 309 receivedCompletedConnectionTestSuite: function() {
305 for (var i = 0; i < this.connectionTestsObservers_.length; ++i) 310 for (var i = 0; i < this.connectionTestsObservers_.length; ++i)
306 this.connectionTestsObservers_[i].onCompletedConnectionTestSuite(); 311 this.connectionTestsObservers_[i].onCompletedConnectionTestSuite();
307 }, 312 },
308 313
309 receivedHSTSResult: function(info) { 314 receivedHSTSResult: function(info) {
310 for (var i = 0; i < this.hstsObservers_.length; ++i) 315 for (var i = 0; i < this.hstsObservers_.length; ++i)
311 this.hstsObservers_[i].onHSTSQueryResult(info); 316 this.hstsObservers_[i].onHSTSQueryResult(info);
312 }, 317 },
313 318
319 receivedONCFileParse: function(status) {
320 for (var i = 0; i < this.crosONCFileParseObservers_.length; ++i)
James Hawkins 2011/12/02 22:08:57 i++
achuithb 2011/12/03 00:23:32 Done.
321 this.crosONCFileParseObservers_[i].onONCFileParse(status);
322 },
323
314 receivedHttpCacheInfo: function(info) { 324 receivedHttpCacheInfo: function(info) {
315 this.pollableDataHelpers_.httpCacheInfo.update(info); 325 this.pollableDataHelpers_.httpCacheInfo.update(info);
316 }, 326 },
317 327
318 receivedHttpThrottlingEnabledPrefChanged: function(enabled) { 328 receivedHttpThrottlingEnabledPrefChanged: function(enabled) {
319 for (var i = 0; i < this.httpThrottlingObservers_.length; ++i) { 329 for (var i = 0; i < this.httpThrottlingObservers_.length; ++i) {
320 this.httpThrottlingObservers_[i].onHttpThrottlingEnabledPrefChanged( 330 this.httpThrottlingObservers_[i].onHttpThrottlingEnabledPrefChanged(
321 enabled); 331 enabled);
322 } 332 }
323 }, 333 },
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 * Adds a listener for the results of HSTS (HTTPS Strict Transport Security) 488 * Adds a listener for the results of HSTS (HTTPS Strict Transport Security)
479 * queries. The observer will be called back with: 489 * queries. The observer will be called back with:
480 * 490 *
481 * observer.onHSTSQueryResult(result); 491 * observer.onHSTSQueryResult(result);
482 */ 492 */
483 addHSTSObserver: function(observer) { 493 addHSTSObserver: function(observer) {
484 this.hstsObservers_.push(observer); 494 this.hstsObservers_.push(observer);
485 }, 495 },
486 496
487 /** 497 /**
498 * Adds a listener for ONC file parse status. The observer will be called
499 * back with:
500 *
501 * observer.onONCFileParse(status);
502 */
503 addCrosONCFileParseObserver: function(observer) {
504 this.crosONCFileParseObservers_.push(observer);
505 },
506
507 /**
488 * Adds a listener for HTTP throttling-related events. |observer| will be 508 * Adds a listener for HTTP throttling-related events. |observer| will be
489 * called back when HTTP throttling is enabled/disabled, through: 509 * called back when HTTP throttling is enabled/disabled, through:
490 * 510 *
491 * observer.onHttpThrottlingEnabledPrefChanged(enabled); 511 * observer.onHttpThrottlingEnabledPrefChanged(enabled);
492 */ 512 */
493 addHttpThrottlingObserver: function(observer) { 513 addHttpThrottlingObserver: function(observer) {
494 this.httpThrottlingObservers_.push(observer); 514 this.httpThrottlingObservers_.push(observer);
495 }, 515 },
496 516
497 /** 517 /**
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 helper.removeObserver(this); 688 helper.removeObserver(this);
669 --this.observingCount_; 689 --this.observingCount_;
670 this.updatedData_[name] = data; 690 this.updatedData_[name] = data;
671 if (this.observingCount_ == 0) 691 if (this.observingCount_ == 0)
672 this.callback_(this.updatedData_); 692 this.callback_(this.updatedData_);
673 } 693 }
674 }; 694 };
675 695
676 return BrowserBridge; 696 return BrowserBridge;
677 })(); 697 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698