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