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

Side by Side Diff: chrome/renderer/resources/event_bindings.js

Issue 115681: switch to using native JSON object (Closed)
Patch Set: all in one Created 11 years, 6 months 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
OLDNEW
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 // ----------------------------------------------------------------------------- 5 // -----------------------------------------------------------------------------
6 // NOTE: If you change this file you need to touch renderer_resources.grd to 6 // NOTE: If you change this file you need to touch renderer_resources.grd to
7 // have your change take effect. 7 // have your change take effect.
8 // ----------------------------------------------------------------------------- 8 // -----------------------------------------------------------------------------
9 9
10 var chrome = chrome || {}; 10 var chrome = chrome || {};
(...skipping 17 matching lines...) Expand all
28 28
29 // A map of event names to the event object that is registered to that name. 29 // A map of event names to the event object that is registered to that name.
30 chrome.Event.attached_ = {}; 30 chrome.Event.attached_ = {};
31 31
32 // Dispatches a named event with the given JSON array, which is deserialized 32 // Dispatches a named event with the given JSON array, which is deserialized
33 // before dispatch. The JSON array is the list of arguments that will be 33 // before dispatch. The JSON array is the list of arguments that will be
34 // sent with the event callback. 34 // sent with the event callback.
35 chrome.Event.dispatchJSON_ = function(name, args) { 35 chrome.Event.dispatchJSON_ = function(name, args) {
36 if (chrome.Event.attached_[name]) { 36 if (chrome.Event.attached_[name]) {
37 if (args) { 37 if (args) {
38 args = goog.json.parse(args); 38 args = JSON.parse(args);
39 } 39 }
40 chrome.Event.attached_[name].dispatch.apply( 40 chrome.Event.attached_[name].dispatch.apply(
41 chrome.Event.attached_[name], args); 41 chrome.Event.attached_[name], args);
42 } 42 }
43 }; 43 };
44 44
45 // Dispatches a named event with the given arguments, supplied as an array. 45 // Dispatches a named event with the given arguments, supplied as an array.
46 chrome.Event.dispatch_ = function(name, args) { 46 chrome.Event.dispatch_ = function(name, args) {
47 if (chrome.Event.attached_[name]) { 47 if (chrome.Event.attached_[name]) {
48 chrome.Event.attached_[name].dispatch.apply( 48 chrome.Event.attached_[name].dispatch.apply(
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return; 126 return;
127 127
128 if (!chrome.Event.attached_[this.eventName_]) { 128 if (!chrome.Event.attached_[this.eventName_]) {
129 throw new Error("chrome.Event '" + this.eventName_ + 129 throw new Error("chrome.Event '" + this.eventName_ +
130 "' is not attached."); 130 "' is not attached.");
131 } 131 }
132 132
133 delete chrome.Event.attached_[this.eventName_]; 133 delete chrome.Event.attached_[this.eventName_];
134 }; 134 };
135 })(); 135 })();
OLDNEW
« no previous file with comments | « chrome/renderer/renderer_resources.grd ('k') | chrome/renderer/resources/extension_process_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698