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

Side by Side Diff: components/dom_distiller/core/javascript/domdistiller.js

Issue 1384433002: distiller: Retires support of CreateNewContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Synced. Created 5 years, 2 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 unified diff | Download patch
OLDNEW
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, use_new_context) { 7 (function(options, stringify_output) {
8 try { 8 try {
9 // The generated domdistiller.js accesses the window object only explicitly 9 function initialize() {
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
12 // context so that it doesn't change the real window object.
13 function initialize(window) {
14 // This include will be processed at build time by grit. 10 // This include will be processed at build time by grit.
15 <include src="../../../../third_party/dom_distiller_js/dist/js/domdistille r.js"/> 11 <include src="../../../../third_party/dom_distiller_js/dist/js/domdistille r.js"/>
16 } 12 }
17 var context = use_new_context ? Object.create(window) : window 13 window.setTimeout = function() {};
18 context.setTimeout = function() {}; 14 window.clearTimeout = function() {};
19 context.clearTimeout = function() {}; 15 initialize();
20 initialize(context);
21 16
22 // The OPTIONS placeholder will be replaced with the DomDistillerOptions at 17 // The OPTIONS placeholder will be replaced with the DomDistillerOptions at
23 // runtime. 18 // runtime.
24 var distiller = context.org.chromium.distiller.DomDistiller; 19 var distiller = window.org.chromium.distiller.DomDistiller;
25 var res = distiller.applyWithOptions(options); 20 var res = distiller.applyWithOptions(options);
26 21
27 if (stringify_output) { 22 if (stringify_output) {
28 return JSON.stringify(res); 23 return JSON.stringify(res);
29 } 24 }
30 return res; 25 return res;
31 } catch (e) { 26 } catch (e) {
32 window.console.error("Error during distillation: " + e); 27 window.console.error("Error during distillation: " + e);
33 if (e.stack != undefined) window.console.error(e.stack); 28 if (e.stack != undefined) window.console.error(e.stack);
34 } 29 }
35 return undefined; 30 return undefined;
36 })(options = $$OPTIONS, 31 })(options = $$OPTIONS,
37 stringify_output = $$STRINGIFY, 32 stringify_output = $$STRINGIFY)
38 use_new_context = $$NEW_CONTEXT)
OLDNEW
« no previous file with comments | « components/dom_distiller/core/fake_distiller_page.h ('k') | components/dom_distiller/ios/distiller_page_ios.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698