| Index: components/dom_distiller/core/javascript/domdistiller.js
|
| diff --git a/components/dom_distiller/core/javascript/domdistiller.js b/components/dom_distiller/core/javascript/domdistiller.js
|
| index 8f010d9d64b55e6f5dece729d2bbd8c5339161ef..22b10b396dcd83e5929fc8e533c1f085dc9d5741 100644
|
| --- a/components/dom_distiller/core/javascript/domdistiller.js
|
| +++ b/components/dom_distiller/core/javascript/domdistiller.js
|
| @@ -4,7 +4,7 @@
|
|
|
| // Applies DomDistillerJs to the content of the page and returns a
|
| // DomDistillerResults (as a javascript object/dict).
|
| -(function() {
|
| +(function(options, stringify_output, use_new_context) {
|
| try {
|
| // The generated domdistiller.js accesses the window object only explicitly
|
| // via the window name. So, we create a new object with the normal window
|
| @@ -14,16 +14,7 @@
|
| // This include will be processed at build time by grit.
|
| <include src="../../../../third_party/dom_distiller_js/package/js/domdistiller.js"/>
|
| }
|
| - <if expr="is_ios">
|
| - // UIWebView's JavaScript engine has a bug that causes crashes when
|
| - // creating a separate window object, so allow the script to run directly
|
| - // in the window until a better solution is created.
|
| - // TODO(kkhorimoto): investigate whether this is necessary for WKWebView.
|
| - var context = window;
|
| - </if>
|
| - <if expr="not is_ios">
|
| - var context = Object.create(window);
|
| - </if>
|
| + var context = use_new_context ? Object.create(window) : window
|
| context.setTimeout = function() {};
|
| context.clearTimeout = function() {};
|
| initialize(context);
|
| @@ -31,17 +22,17 @@
|
| // The OPTIONS placeholder will be replaced with the DomDistillerOptions at
|
| // runtime.
|
| var distiller = context.org.chromium.distiller.DomDistiller;
|
| - var res = distiller.applyWithOptions($$OPTIONS);
|
| - <if expr="is_ios">
|
| - // UIWebView requires javascript to return a single string value.
|
| - return JSON.stringify(res);
|
| - </if>
|
| - <if expr="not is_ios">
|
| + var res = distiller.applyWithOptions(options);
|
| +
|
| + if (stringify_output) {
|
| + return JSON.stringify(res);
|
| + }
|
| return res;
|
| - </if>
|
| } catch (e) {
|
| window.console.error("Error during distillation: " + e);
|
| if (e.stack != undefined) window.console.error(e.stack);
|
| }
|
| return undefined;
|
| -})()
|
| +})(options = $$OPTIONS,
|
| + stringify_output = $$STRINGIFY,
|
| + use_new_context = $$NEW_CONTEXT)
|
|
|