| OLD | NEW |
| 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 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 native function Print(); | 10 native function Print(); |
| 11 | 11 |
| 12 var chromeHidden = GetChromeHidden(); | 12 var chromeHidden = GetChromeHidden(); |
| 13 | 13 |
| 14 // Local implementation of JSON.parse & JSON.stringify that protect us | 14 // Local implementation of JSON.parse & JSON.stringify that protect us |
| 15 // from being clobbered by an extension. | 15 // from being clobbered by an extension. |
| 16 // |
| 17 // TODO(aa): This makes me so sad. We shouldn't need it, as we can just pass |
| 18 // Values directly over IPC without serializing to strings and use |
| 19 // JSONValueConverter. |
| 16 chromeHidden.JSON = new (function() { | 20 chromeHidden.JSON = new (function() { |
| 17 var $Object = Object; | 21 var $Object = Object; |
| 18 var $Array = Array; | 22 var $Array = Array; |
| 19 var $jsonStringify = JSON.stringify; | 23 var $jsonStringify = JSON.stringify; |
| 20 var $jsonParse = JSON.parse; | 24 var $jsonParse = JSON.parse; |
| 21 | 25 |
| 22 this.stringify = function(thing) { | 26 this.stringify = function(thing) { |
| 23 var customizedObjectToJSON = $Object.prototype.toJSON; | 27 var customizedObjectToJSON = $Object.prototype.toJSON; |
| 24 var customizedArrayToJSON = $Array.prototype.toJSON; | 28 var customizedArrayToJSON = $Array.prototype.toJSON; |
| 25 if (customizedObjectToJSON !== undefined) { | 29 if (customizedObjectToJSON !== undefined) { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 var event = allAttachedEvents[i]; | 245 var event = allAttachedEvents[i]; |
| 242 if (event) | 246 if (event) |
| 243 event.detach_(); | 247 event.detach_(); |
| 244 } | 248 } |
| 245 }; | 249 }; |
| 246 | 250 |
| 247 chromeHidden.dispatchError = function(msg) { | 251 chromeHidden.dispatchError = function(msg) { |
| 248 console.error(msg); | 252 console.error(msg); |
| 249 }; | 253 }; |
| 250 })(); | 254 })(); |
| OLD | NEW |