Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Unified Diff: content/test/content_browser_test_utils_internal.h

Issue 1825523002: Do not reset navigation state when BeforeUnload is cancelled by a commit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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,

Powered by Google App Engine
This is Rietveld 408576698