| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_FRAME_HOST_RENDER_FRAME_HOST_FACTORY_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_FACTORY_H_ |
| 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_FACTORY_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_FACTORY_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 class FrameTree; | 14 class FrameTree; |
| 15 class FrameTreeNode; |
| 15 class RenderFrameHostImpl; | 16 class RenderFrameHostImpl; |
| 16 class RenderViewHostImpl; | 17 class RenderViewHostImpl; |
| 17 | 18 |
| 18 // A factory for creating RenderFrameHosts. There is a global factory function | 19 // A factory for creating RenderFrameHosts. There is a global factory function |
| 19 // 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 |
| 20 // RenderFrameHostImpl class. | 21 // RenderFrameHostImpl class. |
| 21 class CONTENT_EXPORT RenderFrameHostFactory { | 22 class CONTENT_EXPORT RenderFrameHostFactory { |
| 22 public: | 23 public: |
| 23 // Creates a new RenderFrameHostImpl using the currently registered factory, | 24 // Creates a new RenderFrameHostImpl using the currently registered factory, |
| 24 // or a regular RenderFrameHostImpl if no factory is registered. | 25 // or a regular RenderFrameHostImpl if no factory is registered. |
| 25 static scoped_ptr<RenderFrameHostImpl> Create( | 26 static scoped_ptr<RenderFrameHostImpl> Create( |
| 26 RenderViewHostImpl* render_view_host, | 27 RenderViewHostImpl* render_view_host, |
| 27 FrameTree* frame_tree, | 28 FrameTree* frame_tree, |
| 29 FrameTreeNode* frame_tree_node, |
| 28 int routing_id, | 30 int routing_id, |
| 29 bool is_swapped_out); | 31 bool is_swapped_out); |
| 30 | 32 |
| 31 // Returns true if there is currently a globally-registered factory. | 33 // Returns true if there is currently a globally-registered factory. |
| 32 static bool has_factory() { return !!factory_; } | 34 static bool has_factory() { return !!factory_; } |
| 33 | 35 |
| 34 protected: | 36 protected: |
| 35 RenderFrameHostFactory() {} | 37 RenderFrameHostFactory() {} |
| 36 virtual ~RenderFrameHostFactory() {} | 38 virtual ~RenderFrameHostFactory() {} |
| 37 | 39 |
| 38 // You can derive from this class and specify an implementation for this | 40 // You can derive from this class and specify an implementation for this |
| 39 // function to create an alternate kind of RenderFrameHostImpl for testing. | 41 // function to create an alternate kind of RenderFrameHostImpl for testing. |
| 40 virtual scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost( | 42 virtual scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost( |
| 41 RenderViewHostImpl* render_view_host, | 43 RenderViewHostImpl* render_view_host, |
| 42 FrameTree* frame_tree, | 44 FrameTree* frame_tree, |
| 45 FrameTreeNode* frame_tree_node, |
| 43 int routing_id, | 46 int routing_id, |
| 44 bool is_swapped_out) = 0; | 47 bool is_swapped_out) = 0; |
| 45 | 48 |
| 46 // Registers a factory to be called when new RenderFrameHostImpls are created. | 49 // Registers a factory to be called when new RenderFrameHostImpls are created. |
| 47 // We have only one global factory, so there must be no factory registered | 50 // We have only one global factory, so there must be no factory registered |
| 48 // before the call. This class does NOT take ownership of the pointer. | 51 // before the call. This class does NOT take ownership of the pointer. |
| 49 static void RegisterFactory(RenderFrameHostFactory* factory); | 52 static void RegisterFactory(RenderFrameHostFactory* factory); |
| 50 | 53 |
| 51 // Unregister the previously registered factory. With no factory registered, | 54 // Unregister the previously registered factory. With no factory registered, |
| 52 // regular RenderViewHostImpls will be created. | 55 // regular RenderViewHostImpls will be created. |
| 53 static void UnregisterFactory(); | 56 static void UnregisterFactory(); |
| 54 | 57 |
| 55 private: | 58 private: |
| 56 // The current globally registered factory. This is NULL when we should create | 59 // The current globally registered factory. This is NULL when we should create |
| 57 // regular RenderFrameHostImpls. | 60 // regular RenderFrameHostImpls. |
| 58 static RenderFrameHostFactory* factory_; | 61 static RenderFrameHostFactory* factory_; |
| 59 | 62 |
| 60 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostFactory); | 63 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostFactory); |
| 61 }; | 64 }; |
| 62 | 65 |
| 63 } // namespace content | 66 } // namespace content |
| 64 | 67 |
| 65 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_FACTORY_H_ | 68 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_FACTORY_H_ |
| OLD | NEW |