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

Side by Side Diff: components/dom_distiller/standalone/content_extractor.cc

Issue 286583002: Pull DomDistillerOptions up to the DistillerFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: :/ Created 6 years, 7 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 | Annotate | Revision Log
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 #include <sstream> 5 #include <sstream>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "components/dom_distiller/content/distiller_page_web_contents.h" 12 #include "components/dom_distiller/content/distiller_page_web_contents.h"
13 #include "components/dom_distiller/core/distiller.h" 13 #include "components/dom_distiller/core/distiller.h"
14 #include "components/dom_distiller/core/dom_distiller_database.h" 14 #include "components/dom_distiller/core/dom_distiller_database.h"
15 #include "components/dom_distiller/core/dom_distiller_service.h" 15 #include "components/dom_distiller/core/dom_distiller_service.h"
16 #include "components/dom_distiller/core/dom_distiller_store.h" 16 #include "components/dom_distiller/core/dom_distiller_store.h"
17 #include "components/dom_distiller/core/proto/distilled_article.pb.h" 17 #include "components/dom_distiller/core/proto/distilled_article.pb.h"
18 #include "components/dom_distiller/core/proto/distilled_page.pb.h" 18 #include "components/dom_distiller/core/proto/distilled_page.pb.h"
19 #include "components/dom_distiller/core/task_tracker.h" 19 #include "components/dom_distiller/core/task_tracker.h"
20 #include "content/public/browser/browser_context.h" 20 #include "content/public/browser/browser_context.h"
21 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
22 #include "content/public/test/content_browser_test.h" 22 #include "content/public/test/content_browser_test.h"
23 #include "content/shell/browser/shell.h" 23 #include "content/shell/browser/shell.h"
24 #include "net/dns/mock_host_resolver.h" 24 #include "net/dns/mock_host_resolver.h"
25 #include "third_party/dom_distiller_js/dom_distiller.pb.h"
25 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
26 27
27 using content::ContentBrowserTest; 28 using content::ContentBrowserTest;
28 29
29 namespace dom_distiller { 30 namespace dom_distiller {
30 31
31 namespace { 32 namespace {
32 33
33 // The url to distill. 34 // The url to distill.
34 const char* kUrlSwitch = "url"; 35 const char* kUrlSwitch = "url";
35 36
36 // Indicates that DNS resolution should be disabled for this test. 37 // Indicates that DNS resolution should be disabled for this test.
37 const char* kDisableDnsSwitch = "disable-dns"; 38 const char* kDisableDnsSwitch = "disable-dns";
38 39
39 // Will write the distilled output to the given file instead of to stdout. 40 // Will write the distilled output to the given file instead of to stdout.
40 const char* kOutputFile = "output-file"; 41 const char* kOutputFile = "output-file";
41 42
42 // Indicates to output a serialized protocol buffer instead of human-readable 43 // Indicates to output a serialized protocol buffer instead of human-readable
43 // output. 44 // output.
44 const char* kShouldOutputBinary = "output-binary"; 45 const char* kShouldOutputBinary = "output-binary";
45 46
47 const char* kExtractTextOnly = "extract-text-only";
48
46 scoped_ptr<DomDistillerService> CreateDomDistillerService( 49 scoped_ptr<DomDistillerService> CreateDomDistillerService(
47 content::BrowserContext* context, 50 content::BrowserContext* context,
48 const base::FilePath& db_path) { 51 const base::FilePath& db_path) {
49 scoped_refptr<base::SequencedTaskRunner> background_task_runner = 52 scoped_refptr<base::SequencedTaskRunner> background_task_runner =
50 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( 53 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
51 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); 54 content::BrowserThread::GetBlockingPool()->GetSequenceToken());
52 55
53 // TODO(cjhopman): use an in-memory database instead of an on-disk one with 56 // TODO(cjhopman): use an in-memory database instead of an on-disk one with
54 // temporary directory. 57 // temporary directory.
55 scoped_ptr<DomDistillerDatabase> db( 58 scoped_ptr<DomDistillerDatabase> db(
56 new DomDistillerDatabase(background_task_runner)); 59 new DomDistillerDatabase(background_task_runner));
57 scoped_ptr<DomDistillerStore> dom_distiller_store(new DomDistillerStore( 60 scoped_ptr<DomDistillerStore> dom_distiller_store(new DomDistillerStore(
58 db.PassAs<DomDistillerDatabaseInterface>(), db_path)); 61 db.PassAs<DomDistillerDatabaseInterface>(), db_path));
59 62
60 scoped_ptr<DistillerPageFactory> distiller_page_factory( 63 scoped_ptr<DistillerPageFactory> distiller_page_factory(
61 new DistillerPageWebContentsFactory(context)); 64 new DistillerPageWebContentsFactory(context));
62 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( 65 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory(
63 new DistillerURLFetcherFactory(context->GetRequestContext())); 66 new DistillerURLFetcherFactory(context->GetRequestContext()));
67
68 dom_distiller::proto::DomDistillerOptions options;
69 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kExtractTextOnly)) {
70 options.set_extract_text_only(true);
71 }
64 scoped_ptr<DistillerFactory> distiller_factory( 72 scoped_ptr<DistillerFactory> distiller_factory(
65 new DistillerFactoryImpl(distiller_url_fetcher_factory.Pass())); 73 new DistillerFactoryImpl(distiller_url_fetcher_factory.Pass(), options));
66 74
67 return scoped_ptr<DomDistillerService>(new DomDistillerService( 75 return scoped_ptr<DomDistillerService>(new DomDistillerService(
68 dom_distiller_store.PassAs<DomDistillerStoreInterface>(), 76 dom_distiller_store.PassAs<DomDistillerStoreInterface>(),
69 distiller_factory.Pass(), 77 distiller_factory.Pass(),
70 distiller_page_factory.Pass())); 78 distiller_page_factory.Pass()));
71 } 79 }
72 80
73 void AddComponentsResources() { 81 void AddComponentsResources() {
74 base::FilePath pak_file; 82 base::FilePath pak_file;
75 base::FilePath pak_dir; 83 base::FilePath pak_dir;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 scoped_ptr<DomDistillerService> service_; 221 scoped_ptr<DomDistillerService> service_;
214 scoped_ptr<ContentExtractionRequest> request_; 222 scoped_ptr<ContentExtractionRequest> request_;
215 }; 223 };
216 224
217 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) { 225 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) {
218 Start(); 226 Start();
219 base::RunLoop().Run(); 227 base::RunLoop().Run();
220 } 228 }
221 229
222 } // namespace dom_distiller 230 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/core/distiller_unittest.cc ('k') | third_party/dom_distiller_js/dom_distiller_js.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698