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

Unified Diff: content/browser/frame_host/navigation_handle_factory.h

Issue 1269813002: Add a NavigationThrottle to the public content/ interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@navigation-api
Patch Set: Addressed comments Created 5 years, 3 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/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
nasko 2015/09/14 22:00:04 nit: Which type of tests? unit, browser, or both?
clamy 2015/09/16 01:03:21 Done.
+// NavigationHandleImpls.
+class NavigationHandleFactory {
+ 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_

Powered by Google App Engine
This is Rietveld 408576698