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 unit tests to create TestNavigationHandles instead of plain |
| 22 // NavigationHandleImpls. |
| 23 class NavigationHandleFactory { |
| 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 bool is_main_frame, |
| 29 NavigatorDelegate* delegate); |
| 30 |
| 31 // Registers a factory during tests. NavigationHandleFactory::Create will |
| 32 // then return the result of factory->CreateHandle, if |factory| is not null. |
| 33 // Otherwise it will continue returning plain NavigationHandleImpls. |
| 34 static void SetFactoryForTesting(NavigationHandleFactory* factory); |
| 35 |
| 36 virtual ~NavigationHandleFactory(); |
| 37 |
| 38 // When a factory is registered, this method will be used to create |
| 39 // NavigationHandles. |
| 40 virtual scoped_ptr<NavigationHandleImpl> CreateHandle( |
| 41 const GURL& url, |
| 42 bool is_main_frame, |
| 43 NavigatorDelegate* delegate) = 0; |
| 44 }; |
| 45 |
| 46 } // namespace content |
| 47 |
| 48 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_FACTORY_H_ |
OLD | NEW |