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 <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 "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
14 #include "components/dom_distiller/content/distiller_page_web_contents.h" | 14 #include "components/dom_distiller/content/distiller_page_web_contents.h" |
15 #include "components/dom_distiller/core/article_entry.h" | 15 #include "components/dom_distiller/core/article_entry.h" |
| 16 #include "components/dom_distiller/core/distilled_page_prefs.h" |
16 #include "components/dom_distiller/core/distiller.h" | 17 #include "components/dom_distiller/core/distiller.h" |
17 #include "components/dom_distiller/core/dom_distiller_service.h" | 18 #include "components/dom_distiller/core/dom_distiller_service.h" |
18 #include "components/dom_distiller/core/dom_distiller_store.h" | 19 #include "components/dom_distiller/core/dom_distiller_store.h" |
19 #include "components/dom_distiller/core/proto/distilled_article.pb.h" | 20 #include "components/dom_distiller/core/proto/distilled_article.pb.h" |
20 #include "components/dom_distiller/core/proto/distilled_page.pb.h" | 21 #include "components/dom_distiller/core/proto/distilled_page.pb.h" |
21 #include "components/dom_distiller/core/task_tracker.h" | 22 #include "components/dom_distiller/core/task_tracker.h" |
22 #include "components/leveldb_proto/proto_database.h" | 23 #include "components/leveldb_proto/proto_database.h" |
23 #include "components/leveldb_proto/proto_database_impl.h" | 24 #include "components/leveldb_proto/proto_database_impl.h" |
| 25 #include "components/pref_registry/testing_pref_service_syncable.h" |
24 #include "content/public/browser/browser_context.h" | 26 #include "content/public/browser/browser_context.h" |
25 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/test/content_browser_test.h" | 28 #include "content/public/test/content_browser_test.h" |
27 #include "content/shell/browser/shell.h" | 29 #include "content/shell/browser/shell.h" |
28 #include "google/protobuf/io/coded_stream.h" | 30 #include "google/protobuf/io/coded_stream.h" |
29 #include "google/protobuf/io/zero_copy_stream_impl_lite.h" | 31 #include "google/protobuf/io/zero_copy_stream_impl_lite.h" |
30 #include "net/dns/mock_host_resolver.h" | 32 #include "net/dns/mock_host_resolver.h" |
31 #include "third_party/dom_distiller_js/dom_distiller.pb.h" | 33 #include "third_party/dom_distiller_js/dom_distiller.pb.h" |
32 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
33 | 35 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kDebugLevel) && | 92 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kDebugLevel) && |
91 base::StringToInt( | 93 base::StringToInt( |
92 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 94 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
93 kDebugLevel), | 95 kDebugLevel), |
94 &debug_level)) { | 96 &debug_level)) { |
95 options.set_debug_level(debug_level); | 97 options.set_debug_level(debug_level); |
96 } | 98 } |
97 scoped_ptr<DistillerFactory> distiller_factory( | 99 scoped_ptr<DistillerFactory> distiller_factory( |
98 new DistillerFactoryImpl(distiller_url_fetcher_factory.Pass(), options)); | 100 new DistillerFactoryImpl(distiller_url_fetcher_factory.Pass(), options)); |
99 | 101 |
| 102 // Setting up PrefService for DistilledPagePrefs. |
| 103 user_prefs::TestingPrefServiceSyncable* pref_service = |
| 104 new user_prefs::TestingPrefServiceSyncable(); |
| 105 DistilledPagePrefs::RegisterProfilePrefs(pref_service->registry()); |
| 106 |
100 return scoped_ptr<DomDistillerService>(new DomDistillerService( | 107 return scoped_ptr<DomDistillerService>(new DomDistillerService( |
101 dom_distiller_store.PassAs<DomDistillerStoreInterface>(), | 108 dom_distiller_store.PassAs<DomDistillerStoreInterface>(), |
102 distiller_factory.Pass(), | 109 distiller_factory.Pass(), |
103 distiller_page_factory.Pass())); | 110 distiller_page_factory.Pass(), |
| 111 scoped_ptr<DistilledPagePrefs>( |
| 112 new DistilledPagePrefs(pref_service)))); |
104 } | 113 } |
105 | 114 |
106 void AddComponentsResources() { | 115 void AddComponentsResources() { |
107 base::FilePath pak_file; | 116 base::FilePath pak_file; |
108 base::FilePath pak_dir; | 117 base::FilePath pak_dir; |
109 PathService::Get(base::DIR_MODULE, &pak_dir); | 118 PathService::Get(base::DIR_MODULE, &pak_dir); |
110 pak_file = pak_dir.Append(FILE_PATH_LITERAL("components_resources.pak")); | 119 pak_file = pak_dir.Append(FILE_PATH_LITERAL("components_resources.pak")); |
111 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 120 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
112 pak_file, ui::SCALE_FACTOR_NONE); | 121 pak_file, ui::SCALE_FACTOR_NONE); |
113 } | 122 } |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 std::string output_data_; | 325 std::string output_data_; |
317 scoped_ptr<google::protobuf::io::StringOutputStream> protobuf_output_stream_; | 326 scoped_ptr<google::protobuf::io::StringOutputStream> protobuf_output_stream_; |
318 }; | 327 }; |
319 | 328 |
320 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) { | 329 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) { |
321 Start(); | 330 Start(); |
322 base::RunLoop().Run(); | 331 base::RunLoop().Run(); |
323 } | 332 } |
324 | 333 |
325 } // namespace dom_distiller | 334 } // namespace dom_distiller |
OLD | NEW |