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 // Note: this <include> is not behind a single-line comment because the |
| 12 // first line of the file is source code (so the first line would be |
| 13 // skipped) instead of a licence header. |
| 14 // clang-format off |
11 <include src="../../../../third_party/dom_distiller_js/dist/js/domdistille
r.js"/> | 15 <include src="../../../../third_party/dom_distiller_js/dist/js/domdistille
r.js"/> |
| 16 // clang-format on |
12 } | 17 } |
13 window.setTimeout = function() {}; | 18 window.setTimeout = function() {}; |
14 window.clearTimeout = function() {}; | 19 window.clearTimeout = function() {}; |
15 initialize(); | 20 initialize(); |
16 | 21 |
17 // The OPTIONS placeholder will be replaced with the DomDistillerOptions at | 22 // The OPTIONS placeholder will be replaced with the DomDistillerOptions at |
18 // runtime. | 23 // runtime. |
19 var distiller = window.org.chromium.distiller.DomDistiller; | 24 var distiller = window.org.chromium.distiller.DomDistiller; |
20 var res = distiller.applyWithOptions(options); | 25 var res = distiller.applyWithOptions(options); |
21 | 26 |
22 if (stringify_output) { | 27 if (stringify_output) { |
23 return JSON.stringify(res); | 28 return JSON.stringify(res); |
24 } | 29 } |
25 return res; | 30 return res; |
26 } catch (e) { | 31 } catch (e) { |
27 window.console.error("Error during distillation: " + e); | 32 window.console.error("Error during distillation: " + e); |
28 if (e.stack != undefined) window.console.error(e.stack); | 33 if (e.stack != undefined) window.console.error(e.stack); |
29 } | 34 } |
30 return undefined; | 35 return undefined; |
31 })(options = $$OPTIONS, | 36 })(options = $$OPTIONS, |
32 stringify_output = $$STRINGIFY) | 37 stringify_output = $$STRINGIFY) |
OLD | NEW |