| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "components/dom_distiller/content/browser/distillable_page_utils.h" | 8 #include "components/dom_distiller/content/browser/distillable_page_utils.h" |
| 9 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" | 9 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" |
| 10 #include "components/dom_distiller/core/distillable_page_detector.h" | 10 #include "components/dom_distiller/core/distillable_page_detector.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 SetUpTestServer(); | 35 SetUpTestServer(); |
| 36 ContentBrowserTest::SetUpOnMainThread(); | 36 ContentBrowserTest::SetUpOnMainThread(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void LoadURL(const std::string& url) { | 39 void LoadURL(const std::string& url) { |
| 40 content::WebContents* current_web_contents = shell()->web_contents(); | 40 content::WebContents* current_web_contents = shell()->web_contents(); |
| 41 Observe(current_web_contents); | 41 Observe(current_web_contents); |
| 42 base::RunLoop url_loaded_runner; | 42 base::RunLoop url_loaded_runner; |
| 43 main_frame_loaded_callback_ = url_loaded_runner.QuitClosure(); | 43 main_frame_loaded_callback_ = url_loaded_runner.QuitClosure(); |
| 44 current_web_contents->GetController().LoadURL( | 44 current_web_contents->GetController().LoadURL( |
| 45 embedded_test_server()->GetURL(url), | 45 embedded_test_server()->GetURL(url), content::Referrer(), |
| 46 content::Referrer(), | 46 ui::PAGE_TRANSITION_TYPED, std::string()); |
| 47 ui::PAGE_TRANSITION_TYPED, | |
| 48 std::string()); | |
| 49 url_loaded_runner.Run(); | 47 url_loaded_runner.Run(); |
| 50 main_frame_loaded_callback_ = base::Closure(); | 48 main_frame_loaded_callback_ = base::Closure(); |
| 51 Observe(nullptr); | 49 Observe(nullptr); |
| 52 } | 50 } |
| 53 | 51 |
| 54 private: | 52 private: |
| 55 void AddComponentsResources() { | 53 void AddComponentsResources() { |
| 56 base::FilePath pak_file; | 54 base::FilePath pak_file; |
| 57 base::FilePath pak_dir; | 55 base::FilePath pak_dir; |
| 58 #if defined(OS_ANDROID) | 56 #if defined(OS_ANDROID) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 86 | 84 |
| 87 class ResultHolder { | 85 class ResultHolder { |
| 88 public: | 86 public: |
| 89 ResultHolder(base::Closure callback) : callback_(callback) {} | 87 ResultHolder(base::Closure callback) : callback_(callback) {} |
| 90 | 88 |
| 91 void OnResult(bool result) { | 89 void OnResult(bool result) { |
| 92 result_ = result; | 90 result_ = result; |
| 93 callback_.Run(); | 91 callback_.Run(); |
| 94 } | 92 } |
| 95 | 93 |
| 96 bool GetResult() { | 94 bool GetResult() { return result_; } |
| 97 return result_; | |
| 98 } | |
| 99 | 95 |
| 100 base::Callback<void(bool)> GetCallback() { | 96 base::Callback<void(bool)> GetCallback() { |
| 101 return base::Bind(&ResultHolder::OnResult, base::Unretained(this)); | 97 return base::Bind(&ResultHolder::OnResult, base::Unretained(this)); |
| 102 } | 98 } |
| 103 | 99 |
| 104 private: | 100 private: |
| 105 base::Closure callback_; | 101 base::Closure callback_; |
| 106 bool result_; | 102 bool result_; |
| 107 }; | 103 }; |
| 108 | 104 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 LoadURL(kArticlePath); | 166 LoadURL(kArticlePath); |
| 171 base::RunLoop run_loop_; | 167 base::RunLoop run_loop_; |
| 172 ResultHolder holder(run_loop_.QuitClosure()); | 168 ResultHolder holder(run_loop_.QuitClosure()); |
| 173 IsDistillablePageForDetector(shell()->web_contents(), detector.get(), | 169 IsDistillablePageForDetector(shell()->web_contents(), detector.get(), |
| 174 holder.GetCallback()); | 170 holder.GetCallback()); |
| 175 run_loop_.Run(); | 171 run_loop_.Run(); |
| 176 ASSERT_FALSE(holder.GetResult()); | 172 ASSERT_FALSE(holder.GetResult()); |
| 177 } | 173 } |
| 178 | 174 |
| 179 } // namespace dom_distiller | 175 } // namespace dom_distiller |
| OLD | NEW |