[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / content / browser / frame_host / render_frame_host_factory.h
blob07b8ffb702477c32ef259d025e63c421e8852692
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_FACTORY_H_
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_FACTORY_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "content/common/content_export.h"
12 namespace content {
14 class FrameTree;
15 class FrameTreeNode;
16 class RenderFrameHostDelegate;
17 class RenderFrameHostImpl;
18 class RenderViewHostImpl;
19 class RenderWidgetHostDelegate;
20 class SiteInstance;
22 // A factory for creating RenderFrameHosts. There is a global factory function
23 // that can be installed for the purposes of testing to provide a specialized
24 // RenderFrameHostImpl class.
25 class CONTENT_EXPORT RenderFrameHostFactory {
26 public:
27 // Creates a new RenderFrameHostImpl using the currently registered factory,
28 // or a regular RenderFrameHostImpl if no factory is registered.
29 static scoped_ptr<RenderFrameHostImpl> Create(
30 SiteInstance* site_instance,
31 RenderViewHostImpl* render_view_host,
32 RenderFrameHostDelegate* delegate,
33 RenderWidgetHostDelegate* rwh_delegate,
34 FrameTree* frame_tree,
35 FrameTreeNode* frame_tree_node,
36 int routing_id,
37 int flags);
39 // Returns true if there is currently a globally-registered factory.
40 static bool has_factory() { return !!factory_; }
42 protected:
43 RenderFrameHostFactory() {}
44 virtual ~RenderFrameHostFactory() {}
46 // You can derive from this class and specify an implementation for this
47 // function to create an alternate kind of RenderFrameHostImpl for testing.
48 virtual scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(
49 SiteInstance* site_instance,
50 RenderViewHostImpl* render_view_host,
51 RenderFrameHostDelegate* delegate,
52 RenderWidgetHostDelegate* rwh_delegate,
53 FrameTree* frame_tree,
54 FrameTreeNode* frame_tree_node,
55 int routing_id,
56 int flags) = 0;
58 // Registers a factory to be called when new RenderFrameHostImpls are created.
59 // We have only one global factory, so there must be no factory registered
60 // before the call. This class does NOT take ownership of the pointer.
61 static void RegisterFactory(RenderFrameHostFactory* factory);
63 // Unregister the previously registered factory. With no factory registered,
64 // regular RenderFrameHostImpls will be created.
65 static void UnregisterFactory();
67 private:
68 // The current globally registered factory. This is NULL when we should create
69 // regular RenderFrameHostImpls.
70 static RenderFrameHostFactory* factory_;
72 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostFactory);
75 } // namespace content
77 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_FACTORY_H_