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

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

Issue 396503003: DomDistiller: fix 0 document width (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 output << "URL: " << page.url() << std::endl; 135 output << "URL: " << page.url() << std::endl;
136 output << "Content: " << page.html() << std::endl; 136 output << "Content: " << page.html() << std::endl;
137 } 137 }
138 return output.str(); 138 return output.str();
139 } 139 }
140 140
141 } // namespace 141 } // namespace
142 142
143 class ContentExtractionRequest : public ViewRequestDelegate { 143 class ContentExtractionRequest : public ViewRequestDelegate {
144 public: 144 public:
145 void Start(DomDistillerService* service, base::Closure finished_callback) { 145 void Start(DomDistillerService* service, const gfx::Size& render_view_size,
146 base::Closure finished_callback) {
146 finished_callback_ = finished_callback; 147 finished_callback_ = finished_callback;
147 viewer_handle_ = 148 viewer_handle_ =
148 service->ViewUrl(this, service->CreateDefaultDistillerPage(), url_); 149 service->ViewUrl(this,
150 service->CreateDefaultDistillerPage(render_view_size),
151 url_);
149 } 152 }
150 153
151 DistilledArticleProto GetArticleCopy() { 154 DistilledArticleProto GetArticleCopy() {
152 return *article_proto_; 155 return *article_proto_;
153 } 156 }
154 157
155 static ScopedVector<ContentExtractionRequest> CreateForCommandLine( 158 static ScopedVector<ContentExtractionRequest> CreateForCommandLine(
156 const CommandLine& command_line) { 159 const CommandLine& command_line) {
157 ScopedVector<ContentExtractionRequest> requests; 160 ScopedVector<ContentExtractionRequest> requests;
158 if (command_line.HasSwitch(kUrlSwitch)) { 161 if (command_line.HasSwitch(kUrlSwitch)) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 db_dir_.path()); 239 db_dir_.path());
237 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 240 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
238 requests_ = ContentExtractionRequest::CreateForCommandLine(command_line); 241 requests_ = ContentExtractionRequest::CreateForCommandLine(command_line);
239 PumpQueue(); 242 PumpQueue();
240 } 243 }
241 244
242 void PumpQueue() { 245 void PumpQueue() {
243 while (pending_tasks_ < max_tasks_ && next_request_ < requests_.size()) { 246 while (pending_tasks_ < max_tasks_ && next_request_ < requests_.size()) {
244 requests_[next_request_]->Start( 247 requests_[next_request_]->Start(
245 service_.get(), 248 service_.get(),
249 shell()->web_contents()->GetContainerBounds().size(),
246 base::Bind(&ContentExtractor::FinishRequest, base::Unretained(this))); 250 base::Bind(&ContentExtractor::FinishRequest, base::Unretained(this)));
247 ++next_request_; 251 ++next_request_;
248 ++pending_tasks_; 252 ++pending_tasks_;
249 } 253 }
250 } 254 }
251 255
252 private: 256 private:
253 // Change behavior of the default host resolver to allow DNS lookup 257 // Change behavior of the default host resolver to allow DNS lookup
254 // to proceed instead of being blocked by the test infrastructure. 258 // to proceed instead of being blocked by the test infrastructure.
255 void EnableDNSLookupForThisTest() { 259 void EnableDNSLookupForThisTest() {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 std::string output_data_; 320 std::string output_data_;
317 scoped_ptr<google::protobuf::io::StringOutputStream> protobuf_output_stream_; 321 scoped_ptr<google::protobuf::io::StringOutputStream> protobuf_output_stream_;
318 }; 322 };
319 323
320 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) { 324 IN_PROC_BROWSER_TEST_F(ContentExtractor, MANUAL_ExtractUrl) {
321 Start(); 325 Start();
322 base::RunLoop().Run(); 326 base::RunLoop().Run();
323 } 327 }
324 328
325 } // namespace dom_distiller 329 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698