NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / renderer / resources / extensions / page_capture_custom_bindings.js
blobf9147d787eb0e51922b9aa556efa08b846b8e0cd
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
3 // found in the LICENSE file.
5 // Custom binding for the pageCapture API.
7 var binding = require('binding').Binding.create('pageCapture');
9 var pageCaptureNatives = requireNative('page_capture');
10 var CreateBlob = pageCaptureNatives.CreateBlob;
11 var SendResponseAck = pageCaptureNatives.SendResponseAck;
13 binding.registerCustomHook(function(bindingsAPI) {
14   var apiFunctions = bindingsAPI.apiFunctions;
16   apiFunctions.setCustomCallback('saveAsMHTML',
17                                  function(name, request, response) {
18     var path = response.mhtmlFilePath;
19     var size = response.mhtmlFileLength;
21     if (request.callback)
22       request.callback(CreateBlob(path, size));
23     request.callback = null;
25     // Notify the browser. Now that the blob is referenced from JavaScript,
26     // the browser can drop its reference to it.
27     SendResponseAck(request.id);
28   });
29 });
31 exports.binding = binding.generate();