OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_ |
6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 // TODO(jam): remove this file when all files have been converted. |
10 | 10 #include "content/browser/renderer_host/render_view_host_factory.h" |
11 class RenderViewHost; | |
12 class RenderViewHostDelegate; | |
13 class SessionStorageNamespace; | |
14 class SiteInstance; | |
15 | |
16 namespace base { | |
17 class WaitableEvent; | |
18 } // namespace base | |
19 | |
20 // A factory for creating RenderViewHosts. There is a global factory function | |
21 // that can be installed for the purposes of testing to provide a specialized | |
22 // RenderViewHost class. | |
23 class RenderViewHostFactory { | |
24 public: | |
25 // Creates a RenderViewHost using the currently registered factory, or the | |
26 // default one if no factory is registered. Ownership of the returned | |
27 // pointer will be passed to the caller. | |
28 static RenderViewHost* Create(SiteInstance* instance, | |
29 RenderViewHostDelegate* delegate, | |
30 int routing_id, | |
31 SessionStorageNamespace* session_storage); | |
32 | |
33 // Returns true if there is currently a globally-registered factory. | |
34 static bool has_factory() { | |
35 return !!factory_; | |
36 } | |
37 | |
38 protected: | |
39 RenderViewHostFactory() {} | |
40 virtual ~RenderViewHostFactory() {} | |
41 | |
42 // You can derive from this class and specify an implementation for this | |
43 // function to create a different kind of RenderViewHost for testing. | |
44 virtual RenderViewHost* CreateRenderViewHost( | |
45 SiteInstance* instance, | |
46 RenderViewHostDelegate* delegate, | |
47 int routing_id, | |
48 SessionStorageNamespace* session_storage_namespace) = 0; | |
49 | |
50 // Registers your factory to be called when new RenderViewHosts are created. | |
51 // We have only one global factory, so there must be no factory registered | |
52 // before the call. This class does NOT take ownership of the pointer. | |
53 static void RegisterFactory(RenderViewHostFactory* factory); | |
54 | |
55 // Unregister the previously registered factory. With no factory registered, | |
56 // the default RenderViewHosts will be created. | |
57 static void UnregisterFactory(); | |
58 | |
59 private: | |
60 // The current globally registered factory. This is NULL when we should | |
61 // create the default RenderViewHosts. | |
62 static RenderViewHostFactory* factory_; | |
63 | |
64 DISALLOW_COPY_AND_ASSIGN(RenderViewHostFactory); | |
65 }; | |
66 | |
67 | 11 |
68 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_ | 12 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_ |
OLD | NEW |