Index: content/browser/frame_host/navigation_handle_factory.h |
diff --git a/content/browser/frame_host/navigation_handle_factory.h b/content/browser/frame_host/navigation_handle_factory.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1ded258904fe50806f2369c6e06be934af70a824 |
--- /dev/null |
+++ b/content/browser/frame_host/navigation_handle_factory.h |
@@ -0,0 +1,50 @@ |
+// 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_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_FACTORY_H_ |
+#define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_FACTORY_H_ |
+ |
+#include "base/memory/scoped_ptr.h" |
+#include "url/gurl.h" |
+ |
+namespace content { |
+ |
+class NavigationHandleImpl; |
+class NavigatorDelegate; |
+ |
+// This class is used to create NavigationHandles through a static method. |
+// Normally it creates regular NavigationHandleImpls. However, a global |
+// instance of this interface can be registered through SetFactoryForTesting. |
+// In that case, NavigationHandleFactory::Create will use the CreateHandle |
+// method of the registered interface to create NavigationHandles. This is used |
+// in tests to create TestNavigationHandles instead of plain |
+// NavigationHandleImpls. |
+class NavigationHandleFactory { |
Charlie Reis
2015/09/16 00:09:24
See my question in TestNavigationHandle about whet
|
+ public: |
+ // Returs a NavigationHandle. This is a plain NavigationHandleImpl, unless a |
+ // factory has been registered for testing. |
+ static scoped_ptr<NavigationHandleImpl> Create(const GURL& url, |
+ const GURL& validated_url, |
+ bool is_main_frame, |
+ NavigatorDelegate* delegate); |
+ |
+ // Registers a factory during tests. NavigationHandleFactory::Create will |
+ // then return the result of factory->CreateHandle, if |factory| is not null. |
+ // Otherwise it will continue returning plain NavigationHandleImpls. |
+ static void SetFactoryForTesting(NavigationHandleFactory* factory); |
+ |
+ virtual ~NavigationHandleFactory(); |
+ |
+ // When a factory is registered, this method will be used to create |
+ // NavigationHandles. |
+ virtual scoped_ptr<NavigationHandleImpl> CreateHandle( |
+ const GURL& url, |
+ const GURL& validated_url, |
+ bool is_main_frame, |
+ NavigatorDelegate* delegate) = 0; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_FACTORY_H_ |