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