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

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: nits 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
mmenke 2011/12/01 19:33:35 nit: Blank line not needed.
achuithb 2011/12/02 05:25:42 Done.
231 },
232
227 //-------------------------------------------------------------------------- 233 //--------------------------------------------------------------------------
228 // Messages received from the browser. 234 // Messages received from the browser.
229 //-------------------------------------------------------------------------- 235 //--------------------------------------------------------------------------
230 236
231 receive: function(command, params) { 237 receive: function(command, params) {
232 // Does nothing if disabled. 238 // Does nothing if disabled.
233 if (this.disabled_) 239 if (this.disabled_)
234 return; 240 return;
235 this[command](params); 241 this[command](params);
236 }, 242 },
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 receivedCompletedConnectionTestSuite: function() { 310 receivedCompletedConnectionTestSuite: function() {
305 for (var i = 0; i < this.connectionTestsObservers_.length; ++i) 311 for (var i = 0; i < this.connectionTestsObservers_.length; ++i)
306 this.connectionTestsObservers_[i].onCompletedConnectionTestSuite(); 312 this.connectionTestsObservers_[i].onCompletedConnectionTestSuite();
307 }, 313 },
308 314
309 receivedHSTSResult: function(info) { 315 receivedHSTSResult: function(info) {
310 for (var i = 0; i < this.hstsObservers_.length; ++i) 316 for (var i = 0; i < this.hstsObservers_.length; ++i)
311 this.hstsObservers_[i].onHSTSQueryResult(info); 317 this.hstsObservers_[i].onHSTSQueryResult(info);
312 }, 318 },
313 319
320 receivedONCFileParse: function(status) {
321 for (var i = 0; i < this.crosONCFileParseObservers_.length; ++i)
322 this.crosONCFileParseObservers_[i].onONCFileParse(status);
323 },
324
314 receivedHttpCacheInfo: function(info) { 325 receivedHttpCacheInfo: function(info) {
315 this.pollableDataHelpers_.httpCacheInfo.update(info); 326 this.pollableDataHelpers_.httpCacheInfo.update(info);
316 }, 327 },
317 328
318 receivedHttpThrottlingEnabledPrefChanged: function(enabled) { 329 receivedHttpThrottlingEnabledPrefChanged: function(enabled) {
319 for (var i = 0; i < this.httpThrottlingObservers_.length; ++i) { 330 for (var i = 0; i < this.httpThrottlingObservers_.length; ++i) {
320 this.httpThrottlingObservers_[i].onHttpThrottlingEnabledPrefChanged( 331 this.httpThrottlingObservers_[i].onHttpThrottlingEnabledPrefChanged(
321 enabled); 332 enabled);
322 } 333 }
323 }, 334 },
(...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) 489 * Adds a listener for the results of HSTS (HTTPS Strict Transport Security)
479 * queries. The observer will be called back with: 490 * queries. The observer will be called back with:
480 * 491 *
481 * observer.onHSTSQueryResult(result); 492 * observer.onHSTSQueryResult(result);
482 */ 493 */
483 addHSTSObserver: function(observer) { 494 addHSTSObserver: function(observer) {
484 this.hstsObservers_.push(observer); 495 this.hstsObservers_.push(observer);
485 }, 496 },
486 497
487 /** 498 /**
499 * Adds a listener for ONC File Parse failures. The observer will be called
500 * back with:
501 *
502 * observer.onONCFileParse(status);
503 */
504 addCrosONCFileParseObserver: function(observer) {
505 this.crosONCFileParseObservers_.push(observer);
506 },
507
508 /**
488 * Adds a listener for HTTP throttling-related events. |observer| will be 509 * Adds a listener for HTTP throttling-related events. |observer| will be
489 * called back when HTTP throttling is enabled/disabled, through: 510 * called back when HTTP throttling is enabled/disabled, through:
490 * 511 *
491 * observer.onHttpThrottlingEnabledPrefChanged(enabled); 512 * observer.onHttpThrottlingEnabledPrefChanged(enabled);
492 */ 513 */
493 addHttpThrottlingObserver: function(observer) { 514 addHttpThrottlingObserver: function(observer) {
494 this.httpThrottlingObservers_.push(observer); 515 this.httpThrottlingObservers_.push(observer);
495 }, 516 },
496 517
497 /** 518 /**
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 helper.removeObserver(this); 689 helper.removeObserver(this);
669 --this.observingCount_; 690 --this.observingCount_;
670 this.updatedData_[name] = data; 691 this.updatedData_[name] = data;
671 if (this.observingCount_ == 0) 692 if (this.observingCount_ == 0)
672 this.callback_(this.updatedData_); 693 this.callback_(this.updatedData_);
673 } 694 }
674 }; 695 };
675 696
676 return BrowserBridge; 697 return BrowserBridge;
677 })(); 698 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698