OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 public: | 607 public: |
608 // Monitors any frame in WebContents. | 608 // Monitors any frame in WebContents. |
609 TestNavigationManager(WebContents* web_contents, const GURL& url); | 609 TestNavigationManager(WebContents* web_contents, const GURL& url); |
610 | 610 |
611 ~TestNavigationManager() override; | 611 ~TestNavigationManager() override; |
612 | 612 |
613 // Waits until the navigation request is ready to be sent to the network | 613 // Waits until the navigation request is ready to be sent to the network |
614 // stack. Returns false if the request was aborted before starting. | 614 // stack. Returns false if the request was aborted before starting. |
615 WARN_UNUSED_RESULT bool WaitForWillStartRequest(); | 615 WARN_UNUSED_RESULT bool WaitForWillStartRequest(); |
616 | 616 |
| 617 // Waits until the navigation response has been sent received. Returns false |
| 618 // if the request was aborted before getting a response. |
| 619 WARN_UNUSED_RESULT bool WaitForWillProcessResponse(); |
| 620 |
617 // Waits until the navigation has been finished. Will automatically resume | 621 // Waits until the navigation has been finished. Will automatically resume |
618 // navigations paused before this point. | 622 // navigations paused before this point. |
619 void WaitForNavigationFinished(); | 623 void WaitForNavigationFinished(); |
620 | 624 |
621 protected: | 625 protected: |
622 // Derived classes can override if they want to filter out navigations. This | 626 // Derived classes can override if they want to filter out navigations. This |
623 // is called from DidStartNavigation. | 627 // is called from DidStartNavigation. |
624 virtual bool ShouldMonitorNavigation(NavigationHandle* handle); | 628 virtual bool ShouldMonitorNavigation(NavigationHandle* handle); |
625 | 629 |
626 private: | 630 private: |
627 // WebContentsObserver: | 631 // WebContentsObserver: |
628 void DidStartNavigation(NavigationHandle* handle) override; | 632 void DidStartNavigation(NavigationHandle* handle) override; |
629 void DidFinishNavigation(NavigationHandle* handle) override; | 633 void DidFinishNavigation(NavigationHandle* handle) override; |
630 | 634 |
631 // Called when the NavigationThrottle pauses the navigation in | 635 // Called when the NavigationThrottle pauses the navigation in |
632 // WillStartRequest. | 636 // WillStartRequest. |
633 void OnWillStartRequest(); | 637 void OnWillStartRequest(); |
634 | 638 |
| 639 // Called when the NavigationThrottle pauses the navigation in |
| 640 // WillProcessResponse. |
| 641 void OnWillProcessResponse(); |
| 642 |
635 // Resumes the navigation. | 643 // Resumes the navigation. |
636 void ResumeNavigation(); | 644 void ResumeNavigation(); |
637 | 645 |
638 const GURL url_; | 646 const GURL url_; |
639 bool navigation_paused_; | 647 bool navigation_paused_in_will_start_; |
| 648 bool navigation_paused_in_will_process_response_; |
640 NavigationHandle* handle_; | 649 NavigationHandle* handle_; |
641 bool handled_navigation_; | 650 bool handled_navigation_; |
642 scoped_refptr<MessageLoopRunner> will_start_loop_runner_; | 651 scoped_refptr<MessageLoopRunner> will_start_loop_runner_; |
| 652 scoped_refptr<MessageLoopRunner> will_process_response_loop_runner_; |
643 scoped_refptr<MessageLoopRunner> did_finish_loop_runner_; | 653 scoped_refptr<MessageLoopRunner> did_finish_loop_runner_; |
644 | 654 |
645 base::WeakPtrFactory<TestNavigationManager> weak_factory_; | 655 base::WeakPtrFactory<TestNavigationManager> weak_factory_; |
646 | 656 |
647 DISALLOW_COPY_AND_ASSIGN(TestNavigationManager); | 657 DISALLOW_COPY_AND_ASSIGN(TestNavigationManager); |
648 }; | 658 }; |
649 | 659 |
650 } // namespace content | 660 } // namespace content |
651 | 661 |
652 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 662 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
OLD | NEW |