Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_FACTORY_H_ | |
| 6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_FACTORY_H_ | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "url/gurl.h" | |
| 10 | |
| 11 namespace content { | |
| 12 | |
| 13 class NavigationHandleImpl; | |
| 14 class NavigatorDelegate; | |
| 15 | |
| 16 // This class is used to create NavigationHandles through a static method. | |
| 17 // Normally it creates regular NavigationHandleImpls. However, a global | |
| 18 // instance of this interface can be registered through SetFactoryForTesting. | |
| 19 // In that case, NavigationHandleFactory::Create will use the CreateHandle | |
| 20 // method of the registered interface to create NavigationHandles. This is used | |
| 21 // in tests to create TestNavigationHandles instead of plain | |
| 22 // NavigationHandleImpls. | |
| 23 class NavigationHandleFactory { | |
|
Charlie Reis
2015/09/16 00:09:24
See my question in TestNavigationHandle about whet
| |
| 24 public: | |
| 25 // Returs a NavigationHandle. This is a plain NavigationHandleImpl, unless a | |
| 26 // factory has been registered for testing. | |
| 27 static scoped_ptr<NavigationHandleImpl> Create(const GURL& url, | |
| 28 const GURL& validated_url, | |
| 29 bool is_main_frame, | |
| 30 NavigatorDelegate* delegate); | |
| 31 | |
| 32 // Registers a factory during tests. NavigationHandleFactory::Create will | |
| 33 // then return the result of factory->CreateHandle, if |factory| is not null. | |
| 34 // Otherwise it will continue returning plain NavigationHandleImpls. | |
| 35 static void SetFactoryForTesting(NavigationHandleFactory* factory); | |
| 36 | |
| 37 virtual ~NavigationHandleFactory(); | |
| 38 | |
| 39 // When a factory is registered, this method will be used to create | |
| 40 // NavigationHandles. | |
| 41 virtual scoped_ptr<NavigationHandleImpl> CreateHandle( | |
| 42 const GURL& url, | |
| 43 const GURL& validated_url, | |
| 44 bool is_main_frame, | |
| 45 NavigatorDelegate* delegate) = 0; | |
| 46 }; | |
| 47 | |
| 48 } // namespace content | |
| 49 | |
| 50 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_FACTORY_H_ | |
| OLD | NEW |