Index: content/public/test/navigation_handle_tester.h |
diff --git a/content/public/test/navigation_handle_tester.h b/content/public/test/navigation_handle_tester.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8abadae22142df2a7abf78eb3eda260278e33643 |
--- /dev/null |
+++ b/content/public/test/navigation_handle_tester.h |
@@ -0,0 +1,53 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_PUBLIC_TEST_NAVIGATION_HANDLE_TESTER_H_ |
+#define CONTENT_PUBLIC_TEST_NAVIGATION_HANDLE_TESTER_H_ |
+ |
+#include "content/public/browser/navigation_throttle.h" |
+#include "content/public/common/referrer.h" |
+#include "ui/base/page_transition_types.h" |
+#include "url/gurl.h" |
+ |
+namespace content { |
+class NavigationHandle; |
+class NavigationThrottle; |
+class WebContents; |
+ |
+// This interface allows embedders of content/ to write tests that depend on a |
+// test version of NavigationHandle, in particular unit tests that require |
+// registering NavigationThrottles. In order to create a |
+// NavigationHandleTester, use the static methods provided. |
nasko
2015/09/04 23:36:49
nit: s/methods/method/ as there is only one.
clamy
2015/09/08 16:27:19
Done.
|
+class NavigationHandleTester { |
+ public: |
+ // Returns the NavigationHandleTester for |handle|. |
+ static NavigationHandleTester* For(NavigationHandle* handle); |
+ |
+ // Creates a NavigationHandle enabled for testing. |
+ static NavigationHandle* CreateTestNavigationHandle( |
+ const GURL& url, |
+ const GURL& validated_url, |
+ bool is_main_frame, |
+ WebContents* web_contents); |
+ |
+ // Simulates the network request starting. |
+ virtual NavigationThrottle::ThrottleCheckResult SimulateWillStartRequest( |
+ bool is_post, |
+ const Referrer& sanitized_referrer, |
+ bool has_user_gesture, |
+ ui::PageTransition transition, |
+ bool is_external_protocol) = 0; |
+ |
+ // Simulates the network request being redirected. |
+ virtual NavigationThrottle::ThrottleCheckResult SimulateWillRedirectRequest( |
+ const GURL& new_url, |
+ const GURL& new_validated_url, |
+ bool new_method_is_post, |
+ const GURL& new_referrer_url, |
+ bool new_is_external_protocol) = 0; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_PUBLIC_TEST_NAVIGATION_HANDLE_TESTER_H_ |