| 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 /** | 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_ = []; | |
| 27 this.constantsObservers_ = []; | 26 this.constantsObservers_ = []; |
| 28 this.crosONCFileParseObservers_ = []; | 27 this.crosONCFileParseObservers_ = []; |
| 29 this.storeDebugLogsObservers_ = []; | 28 this.storeDebugLogsObservers_ = []; |
| 30 this.setNetworkDebugModeObservers_ = []; | 29 this.setNetworkDebugModeObservers_ = []; |
| 31 | 30 |
| 32 this.pollableDataHelpers_ = {}; | 31 this.pollableDataHelpers_ = {}; |
| 33 this.pollableDataHelpers_.proxySettings = | 32 this.pollableDataHelpers_.proxySettings = |
| 34 new PollableDataHelper('onProxySettingsChanged', | 33 new PollableDataHelper('onProxySettingsChanged', |
| 35 this.sendGetProxySettings.bind(this)); | 34 this.sendGetProxySettings.bind(this)); |
| 36 this.pollableDataHelpers_.badProxies = | 35 this.pollableDataHelpers_.badProxies = |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 }, | 211 }, |
| 213 | 212 |
| 214 enableIPv6: function() { | 213 enableIPv6: function() { |
| 215 this.send('enableIPv6'); | 214 this.send('enableIPv6'); |
| 216 }, | 215 }, |
| 217 | 216 |
| 218 setLogLevel: function(logLevel) { | 217 setLogLevel: function(logLevel) { |
| 219 this.send('setLogLevel', ['' + logLevel]); | 218 this.send('setLogLevel', ['' + logLevel]); |
| 220 }, | 219 }, |
| 221 | 220 |
| 222 enableHttpThrottling: function(enable) { | |
| 223 this.send('enableHttpThrottling', [enable]); | |
| 224 }, | |
| 225 | |
| 226 refreshSystemLogs: function() { | 221 refreshSystemLogs: function() { |
| 227 this.send('refreshSystemLogs'); | 222 this.send('refreshSystemLogs'); |
| 228 }, | 223 }, |
| 229 | 224 |
| 230 getSystemLog: function(log_key, cellId) { | 225 getSystemLog: function(log_key, cellId) { |
| 231 this.send('getSystemLog', [log_key, cellId]); | 226 this.send('getSystemLog', [log_key, cellId]); |
| 232 }, | 227 }, |
| 233 | 228 |
| 234 importONCFile: function(fileContent, passcode) { | 229 importONCFile: function(fileContent, passcode) { |
| 235 this.send('importONCFile', [fileContent, passcode]); | 230 this.send('importONCFile', [fileContent, passcode]); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 337 |
| 343 receivedSetNetworkDebugMode: function(status) { | 338 receivedSetNetworkDebugMode: function(status) { |
| 344 for (var i = 0; i < this.setNetworkDebugModeObservers_.length; i++) | 339 for (var i = 0; i < this.setNetworkDebugModeObservers_.length; i++) |
| 345 this.setNetworkDebugModeObservers_[i].onSetNetworkDebugMode(status); | 340 this.setNetworkDebugModeObservers_[i].onSetNetworkDebugMode(status); |
| 346 }, | 341 }, |
| 347 | 342 |
| 348 receivedHttpCacheInfo: function(info) { | 343 receivedHttpCacheInfo: function(info) { |
| 349 this.pollableDataHelpers_.httpCacheInfo.update(info); | 344 this.pollableDataHelpers_.httpCacheInfo.update(info); |
| 350 }, | 345 }, |
| 351 | 346 |
| 352 receivedHttpThrottlingEnabledPrefChanged: function(enabled) { | |
| 353 for (var i = 0; i < this.httpThrottlingObservers_.length; i++) { | |
| 354 this.httpThrottlingObservers_[i].onHttpThrottlingEnabledPrefChanged( | |
| 355 enabled); | |
| 356 } | |
| 357 }, | |
| 358 | |
| 359 receivedPrerenderInfo: function(prerenderInfo) { | 347 receivedPrerenderInfo: function(prerenderInfo) { |
| 360 this.pollableDataHelpers_.prerenderInfo.update(prerenderInfo); | 348 this.pollableDataHelpers_.prerenderInfo.update(prerenderInfo); |
| 361 }, | 349 }, |
| 362 | 350 |
| 363 receivedHttpPipeliningStatus: function(httpPipeliningStatus) { | 351 receivedHttpPipeliningStatus: function(httpPipeliningStatus) { |
| 364 this.pollableDataHelpers_.httpPipeliningStatus.update( | 352 this.pollableDataHelpers_.httpPipeliningStatus.update( |
| 365 httpPipeliningStatus); | 353 httpPipeliningStatus); |
| 366 }, | 354 }, |
| 367 | 355 |
| 368 //-------------------------------------------------------------------------- | 356 //-------------------------------------------------------------------------- |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 * Adds a listener for network debugging mode status. The observer | 542 * Adds a listener for network debugging mode status. The observer |
| 555 * will be called back with: | 543 * will be called back with: |
| 556 * | 544 * |
| 557 * observer.onSetNetworkDebugMode(status); | 545 * observer.onSetNetworkDebugMode(status); |
| 558 */ | 546 */ |
| 559 addSetNetworkDebugModeObserver: function(observer) { | 547 addSetNetworkDebugModeObserver: function(observer) { |
| 560 this.setNetworkDebugModeObservers_.push(observer); | 548 this.setNetworkDebugModeObservers_.push(observer); |
| 561 }, | 549 }, |
| 562 | 550 |
| 563 /** | 551 /** |
| 564 * Adds a listener for HTTP throttling-related events. |observer| will be | |
| 565 * called back when HTTP throttling is enabled/disabled, through: | |
| 566 * | |
| 567 * observer.onHttpThrottlingEnabledPrefChanged(enabled); | |
| 568 */ | |
| 569 addHttpThrottlingObserver: function(observer) { | |
| 570 this.httpThrottlingObservers_.push(observer); | |
| 571 }, | |
| 572 | |
| 573 /** | |
| 574 * Adds a listener for the received constants event. |observer| will be | 552 * Adds a listener for the received constants event. |observer| will be |
| 575 * called back when the constants are received, through: | 553 * called back when the constants are received, through: |
| 576 * | 554 * |
| 577 * observer.onReceivedConstants(constants); | 555 * observer.onReceivedConstants(constants); |
| 578 */ | 556 */ |
| 579 addConstantsObserver: function(observer) { | 557 addConstantsObserver: function(observer) { |
| 580 this.constantsObservers_.push(observer); | 558 this.constantsObservers_.push(observer); |
| 581 }, | 559 }, |
| 582 | 560 |
| 583 /** | 561 /** |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 helper.removeObserver(this); | 733 helper.removeObserver(this); |
| 756 --this.observingCount_; | 734 --this.observingCount_; |
| 757 this.updatedData_[name] = data; | 735 this.updatedData_[name] = data; |
| 758 if (this.observingCount_ == 0) | 736 if (this.observingCount_ == 0) |
| 759 this.callback_(this.updatedData_); | 737 this.callback_(this.updatedData_); |
| 760 } | 738 } |
| 761 }; | 739 }; |
| 762 | 740 |
| 763 return BrowserBridge; | 741 return BrowserBridge; |
| 764 })(); | 742 })(); |
| OLD | NEW |