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