Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Unified Diff: war/wrapped_domdistiller_template.js

Issue 863863007: Add support for wrapping the standalone JavaScript. (Closed) Base URL: git@github.com:chromium/dom-distiller.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « create_wrapped_standalone_js.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: war/wrapped_domdistiller_template.js
diff --git a/war/wrapped_domdistiller_template.js b/war/wrapped_domdistiller_template.js
new file mode 100644
index 0000000000000000000000000000000000000000..2eee0f48a162ab0150f0490724ccf62e3180f340
--- /dev/null
+++ b/war/wrapped_domdistiller_template.js
@@ -0,0 +1,31 @@
+// Copyright 2015 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.
+
+// Creates a DomDistiller, applies to to the content of the page, and returns
+// a DomDistillerResults as a JavaScript object/dictionary.
+(function(options) {
+ try {
+ // The generated domdistiller.js accesses the window object only explicitly
+ // via the window name. This creates a new object with the normal window
+ // object as its prototype and initialize the domdistiller.js with that new
+ // context so that it does not change the real window object.
+ function initialize(window) {
+ $$DISTILLER_JAVASCRIPT
+ }
+ var context = Object.create(window);
+ context.setTimeout = function() {};
+ context.clearTimeout = function() {};
+ initialize(context);
+
+ var distiller = context.org.chromium.distiller.DomDistiller;
+ var res = distiller.applyWithOptions(options);
+ return res;
+ } catch (e) {
+ window.console.error("Error during distillation: " + e);
+ if (e.stack != undefined) window.console.error(e.stack);
+ }
+ return undefined;
+// The OPTIONS placeholder will be replaced with the DomDistillerOptions at
+// runtime.
+})($$OPTIONS)
« no previous file with comments | « create_wrapped_standalone_js.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698