OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Applies DomDistillerJs to the content of the page and returns a | 5 // Applies DomDistillerJs to the content of the page and returns a |
6 // DomDistillerResults (as a javascript object/dict). | 6 // DomDistillerResults (as a javascript object/dict). |
7 (function(options, stringify_output) { | 7 (function(options, stringify_output) { |
8 try { | 8 try { |
9 function initialize() { | 9 function initialize() { |
10 // This include will be processed at build time by grit. | 10 // This include will be processed at build time by grit. |
11 <include src="../../../../third_party/dom_distiller_js/dist/js/domdistille
r.js"/> | 11 // <include src="../../../../third_party/dom_distiller_js/dist/js/domdisti
ller.js"/> |
12 } | 12 } |
13 window.setTimeout = function() {}; | 13 window.setTimeout = function() {}; |
14 window.clearTimeout = function() {}; | 14 window.clearTimeout = function() {}; |
15 initialize(); | 15 initialize(); |
16 | 16 |
17 // The OPTIONS placeholder will be replaced with the DomDistillerOptions at | 17 // The OPTIONS placeholder will be replaced with the DomDistillerOptions at |
18 // runtime. | 18 // runtime. |
19 var distiller = window.org.chromium.distiller.DomDistiller; | 19 var distiller = window.org.chromium.distiller.DomDistiller; |
20 var res = distiller.applyWithOptions(options); | 20 var res = distiller.applyWithOptions(options); |
21 | 21 |
22 if (stringify_output) { | 22 if (stringify_output) { |
23 return JSON.stringify(res); | 23 return JSON.stringify(res); |
24 } | 24 } |
25 return res; | 25 return res; |
26 } catch (e) { | 26 } catch (e) { |
27 window.console.error("Error during distillation: " + e); | 27 window.console.error("Error during distillation: " + e); |
28 if (e.stack != undefined) window.console.error(e.stack); | 28 if (e.stack != undefined) window.console.error(e.stack); |
29 } | 29 } |
30 return undefined; | 30 return undefined; |
31 })(options = $$OPTIONS, | 31 })(options = $$OPTIONS, |
32 stringify_output = $$STRINGIFY) | 32 stringify_output = $$STRINGIFY) |
OLD | NEW |