Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_TEST_NAVIGATION_SIMULATOR_IMPL_H_ | |
| 6 #define CONTENT_TEST_NAVIGATION_SIMULATOR_IMPL_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "content/public/browser/web_contents_observer.h" | |
| 11 #include "content/public/common/referrer.h" | |
| 12 #include "content/public/test/navigation_simulator.h" | |
| 13 #include "ui/base/page_transition_types.h" | |
| 14 | |
| 15 namespace content { | |
| 16 | |
| 17 class NavigationHandleImpl; | |
| 18 class TestRenderFrameHost; | |
| 19 | |
| 20 // See NavigationSimulator for a description of what this class does. | |
| 21 class NavigationSimulatorImpl : public NavigationSimulator, | |
|
ncarter (slow)
2017/02/28 23:27:44
It looks like this ought to be preferred over Rend
clamy
2017/03/01 16:18:09
Done.
| |
| 22 WebContentsObserver { | |
|
ncarter (slow)
2017/02/28 23:27:44
should be public WebContentsObserver
clamy
2017/03/01 16:18:09
Done.
| |
| 23 public: | |
| 24 static void NavigateAndCommitFromDocument( | |
| 25 const GURL& original_url, | |
| 26 TestRenderFrameHost* render_frame_host); | |
| 27 static void NavigateAndFailFromDocument( | |
| 28 const GURL& original_url, | |
| 29 int net_error_code, | |
| 30 TestRenderFrameHost* render_frame_host); | |
| 31 | |
| 32 NavigationSimulatorImpl(const GURL& original_url, | |
| 33 TestRenderFrameHost* render_frame_host); | |
| 34 ~NavigationSimulatorImpl() override; | |
| 35 | |
| 36 // NavigationSimulator: | |
| 37 void Start() override; | |
| 38 void Redirect(const GURL& new_url) override; | |
| 39 void Commit() override; | |
| 40 void Fail(int error_code) override; | |
| 41 void CommitErrorPage() override; | |
| 42 void CommitSamePage() override; | |
| 43 void SetTransition(ui::PageTransition transition) override; | |
| 44 void SetReferrer(const Referrer& referrer) override; | |
| 45 | |
| 46 // WebContentsObserver: | |
| 47 void DidStartNavigation(NavigationHandle* navigation_handle) override; | |
| 48 void DidRedirectNavigation(NavigationHandle* navigation_handle) override; | |
| 49 void ReadyToCommitNavigation(NavigationHandle* navigation_handle) override; | |
| 50 void DidFinishNavigation(NavigationHandle* navigation_handle) override; | |
| 51 | |
| 52 private: | |
| 53 void OnWillStartRequest(); | |
| 54 void OnWillRedirectRequest(); | |
| 55 void OnWillProcessResponse(); | |
| 56 | |
| 57 enum State { | |
| 58 INITIALIZATION, | |
| 59 STARTED, | |
| 60 FAILED, | |
| 61 FINISHED, | |
| 62 }; | |
| 63 | |
| 64 State state_ = INITIALIZATION; | |
| 65 | |
| 66 // The renderer associated with this navigation. | |
| 67 TestRenderFrameHost* render_frame_host_; | |
| 68 | |
| 69 // The NavigationHandle associated with this navigation. | |
| 70 NavigationHandleImpl* handle_; | |
| 71 | |
| 72 GURL navigation_url_; | |
| 73 Referrer referrer_; | |
| 74 ui::PageTransition transition_ = ui::PAGE_TRANSITION_LINK; | |
| 75 | |
| 76 // These are used to sanity check the content/public/ API calls emitted as | |
| 77 // part of the navigation. | |
| 78 int num_did_start_navigation_called_ = 0; | |
| 79 int num_will_start_request_called_ = 0; | |
| 80 int num_will_redirect_request_called_ = 0; | |
| 81 int num_did_redirect_navigation_called_ = 0; | |
| 82 int num_will_process_response_called_ = 0; | |
| 83 int num_ready_to_commit_called_ = 0; | |
| 84 int num_did_finish_navigation_called_ = 0; | |
| 85 | |
| 86 base::WeakPtrFactory<NavigationSimulatorImpl> weak_factory_; | |
| 87 }; | |
| 88 | |
| 89 } // namespace content | |
| 90 | |
| 91 #endif // CONTENT_TEST_NAVIGATION_SIMULATOR_IMPL_H_ | |
| OLD | NEW |