Chromium Code Reviews| Index: content/test/content_browser_test_utils_internal.h |
| diff --git a/content/test/content_browser_test_utils_internal.h b/content/test/content_browser_test_utils_internal.h |
| index f4a4ddea552c7b37746fc87275a56e3bf0beaad2..ef0a81c3d86bc232b89b655a48fe57ba14741759 100644 |
| --- a/content/test/content_browser_test_utils_internal.h |
| +++ b/content/test/content_browser_test_utils_internal.h |
| @@ -14,8 +14,11 @@ |
| #include <vector> |
| #include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "cc/surfaces/surface_id.h" |
| +#include "content/public/browser/navigation_handle.h" |
| #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| +#include "content/public/browser/web_contents_observer.h" |
| #include "url/gurl.h" |
| namespace cc { |
| @@ -25,6 +28,7 @@ class SurfaceManager; |
| namespace content { |
| class FrameTreeNode; |
| +class MessageLoopRunner; |
| class RenderWidgetHostViewChildFrame; |
| class Shell; |
| class SiteInstance; |
| @@ -34,6 +38,10 @@ class ToRenderFrameHost; |
| // navigation finishes. |
| void NavigateFrameToURL(FrameTreeNode* node, const GURL& url); |
| +// Sets the DialogManager to proceed by default or not when showing a |
| +// BeforeUnload dialog. |
| +void SetProceedByDefaultOnBeforeUnload(Shell* shell, bool proceed); |
| + |
| // Creates compact textual representations of the state of the frame tree that |
| // is appropriate for use in assertions. |
| // |
| @@ -103,6 +111,39 @@ class NavigationStallDelegate : public ResourceDispatcherHostDelegate { |
| GURL url_; |
| }; |
| +// This class can be used to pause and resume navigations, based on a URL |
| +// match. Note that it only keeps track of one navigation at a time. |
| +class NavigationDelayer : public WebContentsObserver { |
|
Charlie Reis
2016/03/29 18:33:21
Nasko, can you review this part? I know you've be
nasko
2016/03/29 20:19:06
I'd call this something more generic, as it ideall
clamy
2016/03/30 13:31:11
I went with TestNavigationManager. I can switch to
|
| + public: |
| + NavigationDelayer(WebContents* web_contents, const GURL& url); |
|
nasko
2016/03/29 20:19:06
Is the goal for this class to monitor any frame in
clamy
2016/03/30 13:31:11
Precised it in a comment, + adde a TODO for a fram
|
| + ~NavigationDelayer() override; |
| + |
| + // Waits until the navigation has been paused. |
| + void WaitForNavigationPaused(); |
|
nasko
2016/03/29 20:19:06
At what point will navigation be paused? Let's use
clamy
2016/03/30 13:31:11
I renamed the method WaitForWillStartRequest since
|
| + |
| + // Waits until the navigation has been finished. This should be called after |
| + // WaitForNavigationPaused. |
|
Charlie Reis
2016/03/29 18:33:21
Do you also need to call ResumeNavigation before c
clamy
2016/03/30 13:31:11
Yes. I precised it in the comment. Added a TODO to
|
| + void WaitForNavigationFinished(); |
| + |
| + // Resumes the navigation if it was previously paused. |
| + void ResumeNavigation(); |
| + |
| + private: |
| + // WebContentsObserver implementation. |
| + void DidStartNavigation(NavigationHandle* handle) override; |
| + void DidFinishNavigation(NavigationHandle* handle) override; |
| + |
| + // Called when the NavigationThrottlePauses the navigation. |
|
nasko
2016/03/29 20:19:06
nit: s/NavigationThrottlePauses/NavigationThrottle
clamy
2016/03/30 13:31:11
Done.
|
| + void OnPausedNavigation(); |
| + |
| + const GURL url_; |
| + bool navigation_paused_; |
| + NavigationHandle* handle_; |
| + scoped_refptr<MessageLoopRunner> loop_runner_; |
| + |
| + base::WeakPtrFactory<NavigationDelayer> weak_factory_; |
| +}; |
| + |
| // Helper class to assist with hit testing surfaces in multiple processes. |
| // WaitForSurfaceReady() will only return after a Surface from |target_view| |
| // has been composited in the top-level frame's Surface. At that point, |