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

Side by Side Diff: chrome/renderer/resources/extensions/send_request.js

Issue 145463002: Extensions: Send the tab id to platform apps. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
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 var lastError = require('lastError'); 5 var lastError = require('lastError');
6 var logging = requireNative('logging'); 6 var logging = requireNative('logging');
7 var natives = requireNative('sendRequest'); 7 var natives = requireNative('sendRequest');
8 var processNatives = requireNative('process'); 8 var processNatives = requireNative('process');
9 var validate = require('schemaUtils').validate; 9 var validate = require('schemaUtils').validate;
10 10
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 // Send an API request and optionally register a callback. 117 // Send an API request and optionally register a callback.
118 // |optArgs| is an object with optional parameters as follows: 118 // |optArgs| is an object with optional parameters as follows:
119 // - customCallback: a callback that should be called instead of the standard 119 // - customCallback: a callback that should be called instead of the standard
120 // callback. 120 // callback.
121 // - nativeFunction: the v8 native function to handle the request, or 121 // - nativeFunction: the v8 native function to handle the request, or
122 // StartRequest if missing. 122 // StartRequest if missing.
123 // - forIOThread: true if this function should be handled on the browser IO 123 // - forIOThread: true if this function should be handled on the browser IO
124 // thread. 124 // thread.
125 // - preserveNullInObjects: true if it is safe for null to be in objects. 125 // - preserveNullInObjects: true if it is safe for null to be in objects.
126 // - senderTabId: the ID of the tab that triggered this request.
126 function sendRequest(functionName, args, argSchemas, optArgs) { 127 function sendRequest(functionName, args, argSchemas, optArgs) {
127 calledSendRequest = true; 128 calledSendRequest = true;
128 if (!optArgs) 129 if (!optArgs)
129 optArgs = {}; 130 optArgs = {};
130 var request = prepareRequest(args, argSchemas); 131 var request = prepareRequest(args, argSchemas);
131 request.stack = getExtensionStackTrace(); 132 request.stack = getExtensionStackTrace();
132 if (optArgs.customCallback) { 133 if (optArgs.customCallback) {
133 request.customCallback = optArgs.customCallback; 134 request.customCallback = optArgs.customCallback;
134 } 135 }
135 136
136 var nativeFunction = optArgs.nativeFunction || natives.StartRequest; 137 var nativeFunction = optArgs.nativeFunction || natives.StartRequest;
137 138
138 var requestId = natives.GetNextRequestId(); 139 var requestId = natives.GetNextRequestId();
139 request.id = requestId; 140 request.id = requestId;
140 requests[requestId] = request; 141 requests[requestId] = request;
141 142
142 var hasCallback = request.callback || optArgs.customCallback; 143 var hasCallback = request.callback || optArgs.customCallback;
143 return nativeFunction(functionName, 144 return nativeFunction(functionName,
144 request.args, 145 request.args,
145 requestId, 146 requestId,
146 hasCallback, 147 hasCallback,
147 optArgs.forIOThread, 148 optArgs.forIOThread,
148 optArgs.preserveNullInObjects); 149 optArgs.preserveNullInObjects,
150 optArgs.senderTabId);
149 } 151 }
150 152
151 function getCalledSendRequest() { 153 function getCalledSendRequest() {
152 return calledSendRequest; 154 return calledSendRequest;
153 } 155 }
154 156
155 function clearCalledSendRequest() { 157 function clearCalledSendRequest() {
156 calledSendRequest = false; 158 calledSendRequest = false;
157 } 159 }
158 160
159 exports.sendRequest = sendRequest; 161 exports.sendRequest = sendRequest;
160 exports.getCalledSendRequest = getCalledSendRequest; 162 exports.getCalledSendRequest = getCalledSendRequest;
161 exports.clearCalledSendRequest = clearCalledSendRequest; 163 exports.clearCalledSendRequest = clearCalledSendRequest;
162 164
163 // Called by C++. 165 // Called by C++.
164 exports.handleResponse = handleResponse; 166 exports.handleResponse = handleResponse;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698