| OLD | NEW |
| 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 binding for the pageCapture API. | 5 // Custom bindings for the pageCapture API. |
| 6 | |
| 7 var binding = require('binding').Binding.create('pageCapture'); | |
| 8 | 6 |
| 9 var pageCaptureNatives = requireNative('page_capture'); | 7 var pageCaptureNatives = requireNative('page_capture'); |
| 10 var CreateBlob = pageCaptureNatives.CreateBlob; | 8 var CreateBlob = pageCaptureNatives.CreateBlob; |
| 11 var SendResponseAck = pageCaptureNatives.SendResponseAck; | 9 var SendResponseAck = pageCaptureNatives.SendResponseAck; |
| 12 | 10 |
| 13 binding.registerCustomHook(function(bindingsAPI) { | 11 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
| 12 |
| 13 chromeHidden.registerCustomHook('pageCapture', function(bindingsAPI) { |
| 14 var apiFunctions = bindingsAPI.apiFunctions; | 14 var apiFunctions = bindingsAPI.apiFunctions; |
| 15 | 15 |
| 16 apiFunctions.setCustomCallback('saveAsMHTML', | 16 apiFunctions.setCustomCallback('saveAsMHTML', |
| 17 function(name, request, response) { | 17 function(name, request, response) { |
| 18 var path = response.mhtmlFilePath; | 18 var path = response.mhtmlFilePath; |
| 19 var size = response.mhtmlFileLength; | 19 var size = response.mhtmlFileLength; |
| 20 | 20 |
| 21 if (request.callback) | 21 if (request.callback) |
| 22 request.callback(CreateBlob(path, size)); | 22 request.callback(CreateBlob(path, size)); |
| 23 request.callback = null; | 23 request.callback = null; |
| 24 | 24 |
| 25 // Notify the browser. Now that the blob is referenced from JavaScript, | 25 // Notify the browser. Now that the blob is referenced from JavaScript, |
| 26 // the browser can drop its reference to it. | 26 // the browser can drop its reference to it. |
| 27 SendResponseAck(request.id); | 27 SendResponseAck(request.id); |
| 28 }); | 28 }); |
| 29 }); | 29 }); |
| 30 | |
| 31 exports.binding = binding.generate(); | |
| OLD | NEW |