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" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // temporary directory. | 54 // temporary directory. |
55 scoped_ptr<DomDistillerDatabase> db( | 55 scoped_ptr<DomDistillerDatabase> db( |
56 new DomDistillerDatabase(background_task_runner)); | 56 new DomDistillerDatabase(background_task_runner)); |
57 scoped_ptr<DomDistillerStore> dom_distiller_store(new DomDistillerStore( | 57 scoped_ptr<DomDistillerStore> dom_distiller_store(new DomDistillerStore( |
58 db.PassAs<DomDistillerDatabaseInterface>(), db_path)); | 58 db.PassAs<DomDistillerDatabaseInterface>(), db_path)); |
59 | 59 |
60 scoped_ptr<DistillerPageFactory> distiller_page_factory( | 60 scoped_ptr<DistillerPageFactory> distiller_page_factory( |
61 new DistillerPageWebContentsFactory(context)); | 61 new DistillerPageWebContentsFactory(context)); |
62 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( | 62 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( |
63 new DistillerURLFetcherFactory(context->GetRequestContext())); | 63 new DistillerURLFetcherFactory(context->GetRequestContext())); |
64 scoped_ptr<DistillerFactory> distiller_factory(new DistillerFactoryImpl( | 64 scoped_ptr<DistillerFactory> distiller_factory( |
65 distiller_page_factory.Pass(), distiller_url_fetcher_factory.Pass())); | 65 new DistillerFactoryImpl(distiller_url_fetcher_factory.Pass())); |
66 | 66 |
67 return scoped_ptr<DomDistillerService>(new DomDistillerService( | 67 return scoped_ptr<DomDistillerService>(new DomDistillerService( |
68 dom_distiller_store.PassAs<DomDistillerStoreInterface>(), | 68 dom_distiller_store.PassAs<DomDistillerStoreInterface>(), |
69 distiller_factory.Pass())); | 69 distiller_factory.Pass(), |
| 70 distiller_page_factory.Pass())); |
70 } | 71 } |
71 | 72 |
72 void AddComponentsResources() { | 73 void AddComponentsResources() { |
73 base::FilePath pak_file; | 74 base::FilePath pak_file; |
74 base::FilePath pak_dir; | 75 base::FilePath pak_dir; |
75 PathService::Get(base::DIR_MODULE, &pak_dir); | 76 PathService::Get(base::DIR_MODULE, &pak_dir); |
76 pak_file = pak_dir.Append(FILE_PATH_LITERAL("components_resources.pak")); | 77 pak_file = pak_dir.Append(FILE_PATH_LITERAL("components_resources.pak")); |
77 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 78 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
78 pak_file, ui::SCALE_FACTOR_NONE); | 79 pak_file, ui::SCALE_FACTOR_NONE); |
79 } | 80 } |
(...skipping 22 matching lines...) Expand all Loading... |
102 VLOG(0) << data; | 103 VLOG(0) << data; |
103 } | 104 } |
104 } | 105 } |
105 | 106 |
106 } // namespace | 107 } // namespace |
107 | 108 |
108 class ContentExtractionRequest : public ViewRequestDelegate { | 109 class ContentExtractionRequest : public ViewRequestDelegate { |
109 public: | 110 public: |
110 void Start(DomDistillerService* service, base::Closure finished_callback) { | 111 void Start(DomDistillerService* service, base::Closure finished_callback) { |
111 finished_callback_ = finished_callback; | 112 finished_callback_ = finished_callback; |
112 viewer_handle_ = service->ViewUrl(this, url_); | 113 viewer_handle_ = |
| 114 service->ViewUrl(this, service->CreateDefaultDistillerPage(), url_); |
113 } | 115 } |
114 | 116 |
115 DistilledArticleProto GetArticleCopy() { | 117 DistilledArticleProto GetArticleCopy() { |
116 return *article_proto_; | 118 return *article_proto_; |
117 } | 119 } |
118 | 120 |
119 static scoped_ptr<ContentExtractionRequest> CreateForCommandLine( | 121 static scoped_ptr<ContentExtractionRequest> CreateForCommandLine( |
120 const CommandLine& command_line) { | 122 const CommandLine& command_line) { |
121 GURL url; | 123 GURL url; |
122 if (command_line.HasSwitch(kUrlSwitch)) { | 124 if (command_line.HasSwitch(kUrlSwitch)) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 scoped_ptr<DomDistillerService> service_; | 213 scoped_ptr<DomDistillerService> service_; |
212 scoped_ptr<ContentExtractionRequest> request_; | 214 scoped_ptr<ContentExtractionRequest> request_; |
213 }; | 215 }; |
214 | 216 |
215 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) { | 217 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) { |
216 Start(); | 218 Start(); |
217 base::RunLoop().Run(); | 219 base::RunLoop().Run(); |
218 } | 220 } |
219 | 221 |
220 } // namespace dom_distiller | 222 } // namespace dom_distiller |
OLD | NEW |