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 { |
clamy
2016/03/22 16:33:46
Since I need to pause a navigation and then have i
|
+ public: |
+ NavigationDelayer(WebContents* web_contents, const GURL& url); |
+ ~NavigationDelayer() override; |
+ |
+ // Waits until the navigation has been paused. |
+ void WaitForNavigationPaused(); |
+ |
+ // Waits until the navigation has been finished. This should be called after |
+ // WaitForNavigationPaused. |
+ 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. |
+ 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, |