| OLD | NEW |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <sstream> | 6 #include <sstream> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "components/dom_distiller/core/dom_distiller_service.h" | 24 #include "components/dom_distiller/core/dom_distiller_service.h" |
| 25 #include "components/dom_distiller/core/dom_distiller_store.h" | 25 #include "components/dom_distiller/core/dom_distiller_store.h" |
| 26 #include "components/dom_distiller/core/proto/distilled_article.pb.h" | 26 #include "components/dom_distiller/core/proto/distilled_article.pb.h" |
| 27 #include "components/dom_distiller/core/proto/distilled_page.pb.h" | 27 #include "components/dom_distiller/core/proto/distilled_page.pb.h" |
| 28 #include "components/dom_distiller/core/task_tracker.h" | 28 #include "components/dom_distiller/core/task_tracker.h" |
| 29 #include "components/leveldb_proto/proto_database.h" | 29 #include "components/leveldb_proto/proto_database.h" |
| 30 #include "components/leveldb_proto/proto_database_impl.h" | 30 #include "components/leveldb_proto/proto_database_impl.h" |
| 31 #include "components/pref_registry/testing_pref_service_syncable.h" | 31 #include "components/pref_registry/testing_pref_service_syncable.h" |
| 32 #include "content/public/browser/browser_context.h" | 32 #include "content/public/browser/browser_context.h" |
| 33 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/storage_partition.h" |
| 34 #include "content/public/common/isolated_world_ids.h" | 35 #include "content/public/common/isolated_world_ids.h" |
| 35 #include "content/public/test/content_browser_test.h" | 36 #include "content/public/test/content_browser_test.h" |
| 36 #include "content/shell/browser/shell.h" | 37 #include "content/shell/browser/shell.h" |
| 37 #include "google/protobuf/io/coded_stream.h" | 38 #include "google/protobuf/io/coded_stream.h" |
| 38 #include "google/protobuf/io/zero_copy_stream_impl_lite.h" | 39 #include "google/protobuf/io/zero_copy_stream_impl_lite.h" |
| 39 #include "net/dns/mock_host_resolver.h" | 40 #include "net/dns/mock_host_resolver.h" |
| 40 #include "third_party/dom_distiller_js/dom_distiller.pb.h" | 41 #include "third_party/dom_distiller_js/dom_distiller.pb.h" |
| 41 #include "ui/base/resource/resource_bundle.h" | 42 #include "ui/base/resource/resource_bundle.h" |
| 42 | 43 |
| 43 using content::ContentBrowserTest; | 44 using content::ContentBrowserTest; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // temporary directory. | 133 // temporary directory. |
| 133 scoped_ptr<leveldb_proto::ProtoDatabaseImpl<ArticleEntry> > db( | 134 scoped_ptr<leveldb_proto::ProtoDatabaseImpl<ArticleEntry> > db( |
| 134 new leveldb_proto::ProtoDatabaseImpl<ArticleEntry>( | 135 new leveldb_proto::ProtoDatabaseImpl<ArticleEntry>( |
| 135 background_task_runner)); | 136 background_task_runner)); |
| 136 scoped_ptr<DomDistillerStore> dom_distiller_store( | 137 scoped_ptr<DomDistillerStore> dom_distiller_store( |
| 137 new DomDistillerStore(std::move(db), db_path)); | 138 new DomDistillerStore(std::move(db), db_path)); |
| 138 | 139 |
| 139 scoped_ptr<DistillerPageFactory> distiller_page_factory( | 140 scoped_ptr<DistillerPageFactory> distiller_page_factory( |
| 140 new DistillerPageWebContentsFactory(context)); | 141 new DistillerPageWebContentsFactory(context)); |
| 141 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( | 142 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( |
| 142 new DistillerURLFetcherFactory(context->GetRequestContext())); | 143 new DistillerURLFetcherFactory( |
| 144 content::BrowserContext::GetDefaultStoragePartition(context)-> |
| 145 GetURLRequestContext())); |
| 143 | 146 |
| 144 dom_distiller::proto::DomDistillerOptions options; | 147 dom_distiller::proto::DomDistillerOptions options; |
| 145 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kExtractTextOnly)) { | 148 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kExtractTextOnly)) { |
| 146 options.set_extract_text_only(true); | 149 options.set_extract_text_only(true); |
| 147 } | 150 } |
| 148 int debug_level = 0; | 151 int debug_level = 0; |
| 149 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kDebugLevel) && | 152 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kDebugLevel) && |
| 150 base::StringToInt( | 153 base::StringToInt( |
| 151 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 154 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 152 kDebugLevel), | 155 kDebugLevel), |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 scoped_ptr<google::protobuf::io::StringOutputStream> protobuf_output_stream_; | 435 scoped_ptr<google::protobuf::io::StringOutputStream> protobuf_output_stream_; |
| 433 }; | 436 }; |
| 434 | 437 |
| 435 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) { | 438 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) { |
| 436 SetDistillerJavaScriptWorldId(content::ISOLATED_WORLD_ID_CONTENT_END); | 439 SetDistillerJavaScriptWorldId(content::ISOLATED_WORLD_ID_CONTENT_END); |
| 437 Start(); | 440 Start(); |
| 438 base::RunLoop().Run(); | 441 base::RunLoop().Run(); |
| 439 } | 442 } |
| 440 | 443 |
| 441 } // namespace dom_distiller | 444 } // namespace dom_distiller |
| OLD | NEW |