blob: f9147d787eb0e51922b9aa556efa08b846b8e0cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Custom binding for the pageCapture API.
var binding = require('binding').Binding.create('pageCapture');
var pageCaptureNatives = requireNative('page_capture');
var CreateBlob = pageCaptureNatives.CreateBlob;
var SendResponseAck = pageCaptureNatives.SendResponseAck;
binding.registerCustomHook(function(bindingsAPI) {
var apiFunctions = bindingsAPI.apiFunctions;
apiFunctions.setCustomCallback('saveAsMHTML',
function(name, request, response) {
var path = response.mhtmlFilePath;
var size = response.mhtmlFileLength;
if (request.callback)
request.callback(CreateBlob(path, size));
request.callback = null;
// Notify the browser. Now that the blob is referenced from JavaScript,
// the browser can drop its reference to it.
SendResponseAck(request.id);
});
});
exports.binding = binding.generate();
|