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() { | 7 (function() { |
8 try { | 8 try { |
9 // The generated domdistiller.js accesses the window object only explicitly | 9 // The generated domdistiller.js accesses the window object only explicitly |
10 // via the window name. So, we create a new object with the normal window | 10 // via the window name. So, we create a new object with the normal window |
11 // object as its prototype and initialize the domdistiller.js with that new | 11 // object as its prototype and initialize the domdistiller.js with that new |
12 // context so that it doesn't change the real window object. | 12 // context so that it doesn't change the real window object. |
13 function initialize(window) { | 13 function initialize(window) { |
14 // This include will be processed at build time by grit. | 14 // This include will be processed at build time by grit. |
15 <include src="../../../../third_party/dom_distiller_js/package/js/domdisti
ller.js"/> | 15 <include src="../../../../third_party/dom_distiller_js/dist/js/domdistille
r.js"/> |
16 } | 16 } |
17 <if expr="is_ios"> | 17 <if expr="is_ios"> |
18 // UIWebView's JavaScript engine has a bug that causes crashes when | 18 // UIWebView's JavaScript engine has a bug that causes crashes when |
19 // creating a separate window object, so allow the script to run directly | 19 // creating a separate window object, so allow the script to run directly |
20 // in the window until a better solution is created. | 20 // in the window until a better solution is created. |
21 // TODO(kkhorimoto): investigate whether this is necessary for WKWebView. | 21 // TODO(kkhorimoto): investigate whether this is necessary for WKWebView. |
22 var context = window; | 22 var context = window; |
23 </if> | 23 </if> |
24 <if expr="not is_ios"> | 24 <if expr="not is_ios"> |
25 var context = Object.create(window); | 25 var context = Object.create(window); |
(...skipping 12 matching lines...) Expand all Loading... |
38 </if> | 38 </if> |
39 <if expr="not is_ios"> | 39 <if expr="not is_ios"> |
40 return res; | 40 return res; |
41 </if> | 41 </if> |
42 } catch (e) { | 42 } catch (e) { |
43 window.console.error("Error during distillation: " + e); | 43 window.console.error("Error during distillation: " + e); |
44 if (e.stack != undefined) window.console.error(e.stack); | 44 if (e.stack != undefined) window.console.error(e.stack); |
45 } | 45 } |
46 return undefined; | 46 return undefined; |
47 })() | 47 })() |
OLD | NEW |