diff options
author | noyau <noyau@chromium.org> | 2015-03-12 11:13:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-12 18:14:07 +0000 |
commit | 43a2b8170db29bda0ca11411b8a231ea2b47947b (patch) | |
tree | 8508072ee0a605edd7f4ba9025bb0ea0eab7ee3b /components/dom_distiller | |
parent | 3cdfd4c133b815fd386b377770a38b9f3c0b084e (diff) | |
download | chromium_src-43a2b8170db29bda0ca11411b8a231ea2b47947b.zip chromium_src-43a2b8170db29bda0ca11411b8a231ea2b47947b.tar.gz chromium_src-43a2b8170db29bda0ca11411b8a231ea2b47947b.tar.bz2 |
Integrate iOS specific changes in the core domdistiller.js
The file in iOS was just a modified copy and diverged over time. Moved
the if from the grd file to the core js file in order to allow for easier
maintenance.
BUG=None
Review URL: https://codereview.chromium.org/995343002
Cr-Commit-Position: refs/heads/master@{#320321}
Diffstat (limited to 'components/dom_distiller')
-rw-r--r-- | components/dom_distiller/core/javascript/domdistiller.js | 17 | ||||
-rw-r--r-- | components/dom_distiller/ios/javascript/domdistiller.js | 24 |
2 files changed, 16 insertions, 25 deletions
diff --git a/components/dom_distiller/core/javascript/domdistiller.js b/components/dom_distiller/core/javascript/domdistiller.js index 8bf3d8c..8f010d9 100644 --- a/components/dom_distiller/core/javascript/domdistiller.js +++ b/components/dom_distiller/core/javascript/domdistiller.js @@ -14,7 +14,16 @@ // This include will be processed at build time by grit. <include src="../../../../third_party/dom_distiller_js/package/js/domdistiller.js"/> } - var context = Object.create(window); + <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> context.setTimeout = function() {}; context.clearTimeout = function() {}; initialize(context); @@ -23,7 +32,13 @@ // 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"> return res; + </if> } catch (e) { window.console.error("Error during distillation: " + e); if (e.stack != undefined) window.console.error(e.stack); diff --git a/components/dom_distiller/ios/javascript/domdistiller.js b/components/dom_distiller/ios/javascript/domdistiller.js deleted file mode 100644 index 874b977..0000000 --- a/components/dom_distiller/ios/javascript/domdistiller.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Applies DomDistillerJs to the content of the page and returns a -// DomDistillerResults (as a javascript object/dict). -(function() { - try { - // UIWebView's JavaScript engine has a bug that causes crashes when creating - // a separate window object (as in the non-iOS version of this file), 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. - <include - src="../../../../third_party/dom_distiller_js/package/js/domdistiller.js"/> - // UIWebView requires javascript to return a single string value. - return JSON.stringify( - window.com.dom_distiller.DomDistiller.applyWithOptions($$OPTIONS)); - } catch (e) { - window.console.error("Error during distillation: " + e); - if (e.stack != undefined) window.console.error(e.stack); - } - return undefined; -})(); |