| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 var chrome = chrome || {}; | 5 var chrome = chrome || {}; |
| 6 (function () { | 6 (function () { |
| 7 native function GetChromeHidden(); | 7 native function GetChromeHidden(); |
| 8 native function AttachEvent(eventName); | 8 native function AttachEvent(eventName); |
| 9 native function DetachEvent(eventName); | 9 native function DetachEvent(eventName); |
| 10 | 10 |
| 11 var chromeHidden = GetChromeHidden(); | 11 var chromeHidden = GetChromeHidden(); |
| 12 | 12 |
| 13 // Local implementation of JSON.parse & JSON.stringify that protect us | 13 // Local implementation of JSON.parse & JSON.stringify that protect us |
| 14 // from being clobbered by an extension. | 14 // from being clobbered by an extension. |
| 15 chromeHidden.JSON = new (function() { | 15 chromeHidden.JSON = new (function() { |
| 16 const $Object = Object; | 16 var $Object = Object; |
| 17 const $Array = Array; | 17 var $Array = Array; |
| 18 const $jsonStringify = JSON.stringify; | 18 var $jsonStringify = JSON.stringify; |
| 19 const $jsonParse = JSON.parse; | 19 var $jsonParse = JSON.parse; |
| 20 | 20 |
| 21 this.stringify = function(thing) { | 21 this.stringify = function(thing) { |
| 22 var customizedObjectToJSON = $Object.prototype.toJSON; | 22 var customizedObjectToJSON = $Object.prototype.toJSON; |
| 23 var customizedArrayToJSON = $Array.prototype.toJSON; | 23 var customizedArrayToJSON = $Array.prototype.toJSON; |
| 24 if (customizedObjectToJSON !== undefined) { | 24 if (customizedObjectToJSON !== undefined) { |
| 25 $Object.prototype.toJSON = null; | 25 $Object.prototype.toJSON = null; |
| 26 } | 26 } |
| 27 if (customizedArrayToJSON !== undefined) { | 27 if (customizedArrayToJSON !== undefined) { |
| 28 $Array.prototype.toJSON = null; | 28 $Array.prototype.toJSON = null; |
| 29 } | 29 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 var event = allAttachedEvents[i]; | 219 var event = allAttachedEvents[i]; |
| 220 if (event) | 220 if (event) |
| 221 event.detach_(); | 221 event.detach_(); |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 | 224 |
| 225 chromeHidden.dispatchError = function(msg) { | 225 chromeHidden.dispatchError = function(msg) { |
| 226 console.error(msg); | 226 console.error(msg); |
| 227 } | 227 } |
| 228 })(); | 228 })(); |
| OLD | NEW |