Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Side by Side Diff: chrome/renderer/resources/extensions/page_capture_custom_bindings.js

Issue 384653002: Improve robustness of pageCapture.saveAsMHTML custom binding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo in error message Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/api/page_capture/page_capture_api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 binding for the pageCapture API.
6 6
7 var binding = require('binding').Binding.create('pageCapture'); 7 var binding = require('binding').Binding.create('pageCapture');
8 8
9 var pageCaptureNatives = requireNative('page_capture'); 9 var pageCaptureNatives = requireNative('page_capture');
10 var CreateBlob = pageCaptureNatives.CreateBlob; 10 var CreateBlob = pageCaptureNatives.CreateBlob;
11 var SendResponseAck = pageCaptureNatives.SendResponseAck; 11 var SendResponseAck = pageCaptureNatives.SendResponseAck;
12 12
13 binding.registerCustomHook(function(bindingsAPI) { 13 binding.registerCustomHook(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 callback = request.callback;
19 var size = response.mhtmlFileLength; 19 request.callback = null;
20 if (response) {
Devlin 2014/07/10 20:53:28 nit: inline? if (response) response = CreateBlo
robwu 2014/07/10 21:15:56 Done.
21 var path = response.mhtmlFilePath;
22 var size = response.mhtmlFileLength;
23 response = CreateBlob(path, size);
24 }
20 25
21 if (request.callback) 26 try {
22 request.callback(CreateBlob(path, size)); 27 callback(response);
23 request.callback = null; 28 } finally {
Devlin 2014/07/10 20:53:28 We usually put a catch here and log the error so t
robwu 2014/07/10 21:15:56 Done.
24 29 // Notify the browser. Now that the blob is referenced from JavaScript,
25 // Notify the browser. Now that the blob is referenced from JavaScript, 30 // the browser can drop its reference to it.
26 // the browser can drop its reference to it. 31 SendResponseAck(request.id);
27 SendResponseAck(request.id); 32 }
28 }); 33 });
29 }); 34 });
30 35
31 exports.binding = binding.generate(); 36 exports.binding = binding.generate();
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/page_capture/page_capture_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698