Index: components/dom_distiller/standalone/content_extractor.cc |
diff --git a/components/dom_distiller/standalone/content_extractor.cc b/components/dom_distiller/standalone/content_extractor.cc |
index 6c0e75bd5884391e189dc628cddddaf1b7a2fea8..d093f3ac69dc3d68e54f1d04c8de89014764fa1d 100644 |
--- a/components/dom_distiller/standalone/content_extractor.cc |
+++ b/components/dom_distiller/standalone/content_extractor.cc |
@@ -5,6 +5,8 @@ |
#include <sstream> |
#include "base/command_line.h" |
+#include "base/files/file_path.h" |
+#include "base/files/file_util.h" |
#include "base/files/scoped_temp_dir.h" |
#include "base/id_map.h" |
#include "base/message_loop/message_loop.h" |
@@ -109,6 +111,11 @@ const char* kOriginalDomains = "original-domains"; |
// Maximum number of concurrent started extractor requests. |
const int kMaxExtractorTasks = 8; |
+// A path to a script for extracting content (domdistiller.js). If this argument |
+// is passed in, the script will be used instead of using the bundled version |
+// of the script. |
+const char* kExternalDomDistillerJs = "external-dom-distiller-js"; |
+ |
scoped_ptr<DomDistillerService> CreateDomDistillerService( |
content::BrowserContext* context, |
const base::FilePath& db_path, |
@@ -125,8 +132,24 @@ scoped_ptr<DomDistillerService> CreateDomDistillerService( |
scoped_ptr<DomDistillerStore> dom_distiller_store( |
new DomDistillerStore(db.Pass(), db_path)); |
- scoped_ptr<DistillerPageFactory> distiller_page_factory( |
- new DistillerPageWebContentsFactory(context)); |
+ scoped_ptr<DistillerPageFactory> distiller_page_factory; |
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ kExternalDomDistillerJs)) { |
+ std::string external_script_path = |
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
+ kExternalDomDistillerJs); |
+ std::string script_content; |
+ if (!base::ReadFileToString(base::FilePath(external_script_path), |
+ &script_content)) { |
+ ADD_FAILURE() << "Failed to read external script for distillation."; |
+ return nullptr; |
+ } |
+ distiller_page_factory.reset( |
+ new DistillerPageWebContentsFactory(context, script_content)); |
+ } else { |
+ distiller_page_factory.reset(new DistillerPageWebContentsFactory(context)); |
+ } |
+ |
scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( |
new DistillerURLFetcherFactory(context->GetRequestContext())); |