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

Side by Side Diff: chrome/renderer/resources/extension_process_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 chrome Authors. All rights reserved. 1 // Copyright (c) 2009 The chrome 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; 10 var chrome;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 try { 79 try {
80 if (!success) { 80 if (!success) {
81 if (!error) 81 if (!error)
82 error = "Unknown error." 82 error = "Unknown error."
83 console.error("Error during " + name + ": " + error); 83 console.error("Error during " + name + ": " + error);
84 return; 84 return;
85 } 85 }
86 86
87 if (callbacks[requestId]) { 87 if (callbacks[requestId]) {
88 if (response) { 88 if (response) {
89 callbacks[requestId](goog.json.parse(response)); 89 callbacks[requestId](JSON.parse(response));
90 } else { 90 } else {
91 callbacks[requestId](); 91 callbacks[requestId]();
92 } 92 }
93 } 93 }
94 } finally { 94 } finally {
95 delete callbacks[requestId]; 95 delete callbacks[requestId];
96 } 96 }
97 }; 97 };
98 98
99 // Send an API request and optionally register a callback. 99 // Send an API request and optionally register a callback.
100 function sendRequest(request, args, callback) { 100 function sendRequest(request, args, callback) {
101 var sargs = goog.json.serialize(args); 101 // JSON.stringify doesn't support a root object which is undefined.
102 if (args === undefined)
103 args = null;
104 var sargs = JSON.stringify(args);
102 var requestId = GetNextRequestId(); 105 var requestId = GetNextRequestId();
103 var hasCallback = false; 106 var hasCallback = false;
104 if (callback) { 107 if (callback) {
105 hasCallback = true; 108 hasCallback = true;
106 callbacks[requestId] = callback; 109 callbacks[requestId] = callback;
107 } 110 }
108 request(sargs, requestId, hasCallback); 111 request(sargs, requestId, hasCallback);
109 } 112 }
110 113
111 //---------------------------------------------------------------------------- 114 //----------------------------------------------------------------------------
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 window.addEventListener('unload', function() { 514 window.addEventListener('unload', function() {
512 UnregisterExtension(extensionId); }, false); 515 UnregisterExtension(extensionId); }, false);
513 delete chrome.self.register_; 516 delete chrome.self.register_;
514 } 517 }
515 518
516 chrome.self.getViews = function() { 519 chrome.self.getViews = function() {
517 return GetViews(); 520 return GetViews();
518 } 521 }
519 })(); 522 })();
520 523
OLDNEW
« no previous file with comments | « chrome/renderer/resources/event_bindings.js ('k') | chrome/renderer/resources/renderer_extension_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698