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