| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/dom_distiller/content/browser/distiller_page_web_contents.h
" | 5 #include "components/dom_distiller/content/browser/distiller_page_web_contents.h
" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/location.h" |
| 9 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 10 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 11 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/single_thread_task_runner.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "base/values.h" | 16 #include "base/values.h" |
| 14 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 15 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" | 18 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" |
| 16 #include "components/dom_distiller/content/browser/web_contents_main_frame_obser
ver.h" | 19 #include "components/dom_distiller/content/browser/web_contents_main_frame_obser
ver.h" |
| 17 #include "components/dom_distiller/core/distiller_page.h" | 20 #include "components/dom_distiller/core/distiller_page.h" |
| 18 #include "components/dom_distiller/core/proto/distilled_article.pb.h" | 21 #include "components/dom_distiller/core/proto/distilled_article.pb.h" |
| 19 #include "components/dom_distiller/core/proto/distilled_page.pb.h" | 22 #include "components/dom_distiller/core/proto/distilled_page.pb.h" |
| 20 #include "components/dom_distiller/core/viewer.h" | 23 #include "components/dom_distiller/core/viewer.h" |
| 21 #include "content/public/browser/browser_context.h" | 24 #include "content/public/browser/browser_context.h" |
| 22 #include "content/public/browser/navigation_controller.h" | 25 #include "content/public/browser/navigation_controller.h" |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 std::move(source_page_handle), false)); | 405 std::move(source_page_handle), false)); |
| 403 distiller_page_ = distiller_page; | 406 distiller_page_ = distiller_page; |
| 404 | 407 |
| 405 base::RunLoop run_loop; | 408 base::RunLoop run_loop; |
| 406 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); | 409 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); |
| 407 | 410 |
| 408 // It can not crash the loop when returning the result. | 411 // It can not crash the loop when returning the result. |
| 409 delete distiller_page_; | 412 delete distiller_page_; |
| 410 | 413 |
| 411 // Make sure the test ends when it does not crash. | 414 // Make sure the test ends when it does not crash. |
| 412 base::MessageLoop::current()->PostDelayedTask( | 415 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 413 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(2)); | 416 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(2)); |
| 414 | 417 |
| 415 run_loop.Run(); | 418 run_loop.Run(); |
| 416 } | 419 } |
| 417 | 420 |
| 418 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, MarkupInfo) { | 421 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, MarkupInfo) { |
| 419 DistillerPageWebContents distiller_page( | 422 DistillerPageWebContents distiller_page( |
| 420 shell()->web_contents()->GetBrowserContext(), | 423 shell()->web_contents()->GetBrowserContext(), |
| 421 shell()->web_contents()->GetContainerBounds().size(), | 424 shell()->web_contents()->GetContainerBounds().size(), |
| 422 std::unique_ptr<SourcePageHandleWebContents>()); | 425 std::unique_ptr<SourcePageHandleWebContents>()); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 ASSERT_TRUE(js_result_); | 520 ASSERT_TRUE(js_result_); |
| 518 ASSERT_TRUE(js_result_->GetAsDictionary(&dict)); | 521 ASSERT_TRUE(js_result_->GetAsDictionary(&dict)); |
| 519 | 522 |
| 520 ASSERT_TRUE(dict->HasKey("success")); | 523 ASSERT_TRUE(dict->HasKey("success")); |
| 521 bool success; | 524 bool success; |
| 522 ASSERT_TRUE(dict->GetBoolean("success", &success)); | 525 ASSERT_TRUE(dict->GetBoolean("success", &success)); |
| 523 EXPECT_TRUE(success); | 526 EXPECT_TRUE(success); |
| 524 } | 527 } |
| 525 | 528 |
| 526 } // namespace dom_distiller | 529 } // namespace dom_distiller |
| OLD | NEW |