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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 int32_t routing_id, | 32 int32_t routing_id, |
33 int32_t main_frame_routing_id, | 33 int32_t main_frame_routing_id, |
34 bool swapped_out, | 34 bool swapped_out, |
35 bool hidden); | 35 bool hidden); |
36 | 36 |
37 // Returns true if there is currently a globally-registered factory. | 37 // Returns true if there is currently a globally-registered factory. |
38 static bool has_factory() { | 38 static bool has_factory() { |
39 return !!factory_; | 39 return !!factory_; |
40 } | 40 } |
41 | 41 |
| 42 // Returns true if the RenderViewHost instance is not a test instance. |
| 43 CONTENT_EXPORT static bool is_real_render_view_host() { |
| 44 return is_real_render_view_host_; |
| 45 } |
| 46 |
| 47 // Sets the is_real_render_view_host flag which indicates that the |
| 48 // RenderViewHost instance is not a test instance. |
| 49 CONTENT_EXPORT static void set_is_real_render_view_host( |
| 50 bool is_real_render_view_host) { |
| 51 is_real_render_view_host_ = is_real_render_view_host; |
| 52 } |
| 53 |
42 protected: | 54 protected: |
43 RenderViewHostFactory() {} | 55 RenderViewHostFactory() {} |
44 virtual ~RenderViewHostFactory() {} | 56 virtual ~RenderViewHostFactory() {} |
45 | 57 |
46 // You can derive from this class and specify an implementation for this | 58 // You can derive from this class and specify an implementation for this |
47 // function to create a different kind of RenderViewHost for testing. | 59 // function to create a different kind of RenderViewHost for testing. |
48 virtual RenderViewHost* CreateRenderViewHost( | 60 virtual RenderViewHost* CreateRenderViewHost( |
49 SiteInstance* instance, | 61 SiteInstance* instance, |
50 RenderViewHostDelegate* delegate, | 62 RenderViewHostDelegate* delegate, |
51 RenderWidgetHostDelegate* widget_delegate, | 63 RenderWidgetHostDelegate* widget_delegate, |
52 int32_t routing_id, | 64 int32_t routing_id, |
53 int32_t main_frame_routing_id, | 65 int32_t main_frame_routing_id, |
54 bool swapped_out) = 0; | 66 bool swapped_out) = 0; |
55 | 67 |
56 // Registers your factory to be called when new RenderViewHosts are created. | 68 // Registers your factory to be called when new RenderViewHosts are created. |
57 // We have only one global factory, so there must be no factory registered | 69 // We have only one global factory, so there must be no factory registered |
58 // before the call. This class does NOT take ownership of the pointer. | 70 // before the call. This class does NOT take ownership of the pointer. |
59 CONTENT_EXPORT static void RegisterFactory(RenderViewHostFactory* factory); | 71 CONTENT_EXPORT static void RegisterFactory(RenderViewHostFactory* factory); |
60 | 72 |
61 // Unregister the previously registered factory. With no factory registered, | 73 // Unregister the previously registered factory. With no factory registered, |
62 // the default RenderViewHosts will be created. | 74 // the default RenderViewHosts will be created. |
63 CONTENT_EXPORT static void UnregisterFactory(); | 75 CONTENT_EXPORT static void UnregisterFactory(); |
64 | 76 |
65 private: | 77 private: |
66 // The current globally registered factory. This is NULL when we should | 78 // The current globally registered factory. This is NULL when we should |
67 // create the default RenderViewHosts. | 79 // create the default RenderViewHosts. |
68 CONTENT_EXPORT static RenderViewHostFactory* factory_; | 80 CONTENT_EXPORT static RenderViewHostFactory* factory_; |
69 | 81 |
| 82 // Set to true if the RenderViewHost is not a test instance. Defaults to |
| 83 // false. |
| 84 CONTENT_EXPORT static bool is_real_render_view_host_; |
| 85 |
70 DISALLOW_COPY_AND_ASSIGN(RenderViewHostFactory); | 86 DISALLOW_COPY_AND_ASSIGN(RenderViewHostFactory); |
71 }; | 87 }; |
72 | 88 |
73 } // namespace content | 89 } // namespace content |
74 | 90 |
75 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_ | 91 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_ |
OLD | NEW |