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

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

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more progress Created 7 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 // Custom bindings for the pageCapture API. 5 // Custom bindings for the pageCapture API.
6 6
7 var Bindings = require('schema_binding_generator').Bindings;
8 var bindings = new Bindings('pageCapture');
9
7 var pageCaptureNatives = requireNative('page_capture'); 10 var pageCaptureNatives = requireNative('page_capture');
8 var CreateBlob = pageCaptureNatives.CreateBlob; 11 var CreateBlob = pageCaptureNatives.CreateBlob;
9 var SendResponseAck = pageCaptureNatives.SendResponseAck; 12 var SendResponseAck = pageCaptureNatives.SendResponseAck;
10 13
11 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 14 bindings.registerCustomHook(function(bindingsAPI) {
12
13 chromeHidden.registerCustomHook('pageCapture', function(bindingsAPI) {
14 var apiFunctions = bindingsAPI.apiFunctions; 15 var apiFunctions = bindingsAPI.apiFunctions;
15 16
16 apiFunctions.setCustomCallback('saveAsMHTML', 17 apiFunctions.setCustomCallback('saveAsMHTML',
17 function(name, request, response) { 18 function(name, request, response) {
18 var path = response.mhtmlFilePath; 19 var path = response.mhtmlFilePath;
19 var size = response.mhtmlFileLength; 20 var size = response.mhtmlFileLength;
20 21
21 if (request.callback) 22 if (request.callback)
22 request.callback(CreateBlob(path, size)); 23 request.callback(CreateBlob(path, size));
23 request.callback = null; 24 request.callback = null;
24 25
25 // Notify the browser. Now that the blob is referenced from JavaScript, 26 // Notify the browser. Now that the blob is referenced from JavaScript,
26 // the browser can drop its reference to it. 27 // the browser can drop its reference to it.
27 SendResponseAck(request.id); 28 SendResponseAck(request.id);
28 }); 29 });
29 }); 30 });
31
32 exports.bindings = bindings.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698