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

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

Issue 8530003: Delete the temporary file when generating MHTML with the extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor clean-ups Created 9 years, 1 month 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) 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 // This script contains privileged chrome extension related javascript APIs. 5 // This script contains privileged chrome extension related javascript APIs.
6 // It is loaded by pages whose URL has the chrome-extension protocol. 6 // It is loaded by pages whose URL has the chrome-extension protocol.
7 7
8 var chrome = chrome || {}; 8 var chrome = chrome || {};
9 (function() { 9 (function() {
10 native function GetExtensionAPIDefinition(); 10 native function GetExtensionAPIDefinition();
11 native function StartRequest(); 11 native function StartRequest();
12 native function GetChromeHidden(); 12 native function GetChromeHidden();
13 native function GetNextRequestId(); 13 native function GetNextRequestId();
14 native function Print(); 14 native function Print();
15 15
16 native function GetCurrentPageActions(extensionId); 16 native function GetCurrentPageActions(extensionId);
17 native function GetExtensionViews(); 17 native function GetExtensionViews();
18 native function GetNextContextMenuId(); 18 native function GetNextContextMenuId();
19 native function GetNextTtsEventId(); 19 native function GetNextTtsEventId();
20 native function OpenChannelToTab(); 20 native function OpenChannelToTab();
21 native function GetRenderViewId(); 21 native function GetRenderViewId();
22 native function SetIconCommon(); 22 native function SetIconCommon();
23 native function GetUniqueSubEventName(eventName); 23 native function GetUniqueSubEventName(eventName);
24 native function GetLocalFileSystem(name, path); 24 native function GetLocalFileSystem(name, path);
25 native function DecodeJPEG(jpegImage); 25 native function DecodeJPEG(jpegImage);
26 native function CreateBlob(filePath); 26 native function CreateBlob(filePath);
27 native function SendResponseAck(requestId);
27 28
28 var chromeHidden = GetChromeHidden(); 29 var chromeHidden = GetChromeHidden();
29 30
30 if (!chrome) 31 if (!chrome)
31 chrome = {}; 32 chrome = {};
32 33
33 function forEach(dict, f) { 34 function forEach(dict, f) {
34 for (key in dict) { 35 for (key in dict) {
35 if (dict.hasOwnProperty(key)) 36 if (dict.hasOwnProperty(key))
36 f(key, dict[key]); 37 f(key, dict[key]);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 172 }
172 // JSON.stringify doesn't support a root object which is undefined. 173 // JSON.stringify doesn't support a root object which is undefined.
173 if (request.args === undefined) 174 if (request.args === undefined)
174 request.args = null; 175 request.args = null;
175 176
176 var sargs = opt_args.noStringify ? 177 var sargs = opt_args.noStringify ?
177 request.args : chromeHidden.JSON.stringify(request.args); 178 request.args : chromeHidden.JSON.stringify(request.args);
178 var nativeFunction = opt_args.nativeFunction || StartRequest; 179 var nativeFunction = opt_args.nativeFunction || StartRequest;
179 180
180 var requestId = GetNextRequestId(); 181 var requestId = GetNextRequestId();
182 request.id = requestId;
181 requests[requestId] = request; 183 requests[requestId] = request;
182 var hasCallback = 184 var hasCallback =
183 (request.callback || opt_args.customCallback) ? true : false; 185 (request.callback || opt_args.customCallback) ? true : false;
184 return nativeFunction(functionName, sargs, requestId, hasCallback, 186 return nativeFunction(functionName, sargs, requestId, hasCallback,
185 opt_args.forIOThread); 187 opt_args.forIOThread);
186 } 188 }
187 189
188 // --- Setup additional api's not currently handled in common/extensions/api 190 // --- Setup additional api's not currently handled in common/extensions/api
189 191
190 // WebRequestEvent object. This is used for special webRequest events with 192 // WebRequestEvent object. This is used for special webRequest events with
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 }; 790 };
789 791
790 apiFunctions["experimental.savePage.saveAsMHTML"].customCallback = 792 apiFunctions["experimental.savePage.saveAsMHTML"].customCallback =
791 function(name, request, response) { 793 function(name, request, response) {
792 var params = chromeHidden.JSON.parse(response); 794 var params = chromeHidden.JSON.parse(response);
793 var path = params.mhtmlFilePath; 795 var path = params.mhtmlFilePath;
794 var size = params.mhtmlFileLength; 796 var size = params.mhtmlFileLength;
795 797
796 if (request.callback) 798 if (request.callback)
797 request.callback(CreateBlob(path, size)); 799 request.callback(CreateBlob(path, size));
800 request.callback = null;
798 801
799 request.callback = null; 802 // Notify the browser. Now that the blob is referenced from JavaScript,
803 // the browser can drop its reference to it.
804 SendResponseAck(request.id);
800 }; 805 };
801 806
802 apiFunctions["fileBrowserPrivate.requestLocalFileSystem"].customCallback = 807 apiFunctions["fileBrowserPrivate.requestLocalFileSystem"].customCallback =
803 function(name, request, response) { 808 function(name, request, response) {
804 var resp = response ? [chromeHidden.JSON.parse(response)] : []; 809 var resp = response ? [chromeHidden.JSON.parse(response)] : [];
805 var fs = null; 810 var fs = null;
806 if (!resp[0].error) 811 if (!resp[0].error)
807 fs = GetLocalFileSystem(resp[0].name, resp[0].path); 812 fs = GetLocalFileSystem(resp[0].name, resp[0].path);
808 if (request.callback) 813 if (request.callback)
809 request.callback(fs); 814 request.callback(fs);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1083
1079 if (!chrome.tts) 1084 if (!chrome.tts)
1080 chrome.tts = {}; 1085 chrome.tts = {};
1081 1086
1082 if (!chrome.ttsEngine) 1087 if (!chrome.ttsEngine)
1083 chrome.ttsEngine = {}; 1088 chrome.ttsEngine = {};
1084 1089
1085 if (!chrome.experimental.downloads) 1090 if (!chrome.experimental.downloads)
1086 chrome.experimental.downloads = {}; 1091 chrome.experimental.downloads = {};
1087 })(); 1092 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698