blob: e8a7af447d9e71a9c085a5e9061fe7c81d757539 (
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
32
33
34
|
// 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 bindings for the pageCapture API.
(function() {
native function GetChromeHidden();
native function CreateBlob(filePath);
native function SendResponseAck(requestId);
var chromeHidden = GetChromeHidden();
chromeHidden.registerCustomHook('pageCapture', function(bindingsAPI) {
var apiFunctions = bindingsAPI.apiFunctions;
apiFunctions.setCustomCallback('saveAsMHTML',
function(name, request, response) {
var params = chromeHidden.JSON.parse(response);
var path = params.mhtmlFilePath;
var size = params.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);
});
});
})();
|