File: render_widget_host_factory.h

package info (click to toggle)
chromium-browser 70.0.3538.110-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,619,476 kB
  • sloc: cpp: 13,024,755; ansic: 1,349,823; python: 916,672; xml: 314,489; java: 280,047; asm: 276,936; perl: 75,771; objc: 66,634; sh: 45,860; cs: 28,354; php: 11,064; makefile: 10,911; yacc: 9,109; tcl: 8,403; ruby: 4,065; lex: 1,779; pascal: 1,411; lisp: 1,055; awk: 41; jsp: 39; sed: 17; sql: 3
file content (69 lines) | stat: -rw-r--r-- 2,731 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_FACTORY_H_
#define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_FACTORY_H_

#include <stdint.h>

#include "base/macros.h"
#include "content/common/content_export.h"
#include "content/common/widget.mojom.h"

namespace content {
class RenderProcessHost;
class RenderWidgetHostDelegate;
class RenderWidgetHostImpl;

// A factory for creating RenderWidgetHostImpls. There is a global factory
// function that can be installed for the purposes of testing to provide a
// specialized RenderWidgetHostImpl class.
class RenderWidgetHostFactory {
 public:
  // Creates a RenderWidgetHostImpl using the currently registered factory, or
  // the default one if no factory is registered. Ownership of the returned
  // pointer will be passed to the caller.
  static RenderWidgetHostImpl* Create(RenderWidgetHostDelegate* delegate,
                                      RenderProcessHost* process,
                                      int32_t routing_id,
                                      mojom::WidgetPtr widget_interface,
                                      bool hidden);

  // Returns true if there is currently a globally-registered factory.
  static bool has_factory() { return !!factory_; }

 protected:
  RenderWidgetHostFactory() {}
  virtual ~RenderWidgetHostFactory() {}

  // You can derive from this class and specify an implementation for this
  // function to create a different kind of RenderWidgetHostImpl for testing.
  virtual RenderWidgetHostImpl* CreateRenderWidgetHost(
      RenderWidgetHostDelegate* delegate,
      RenderProcessHost* process,
      int32_t routing_id,
      mojom::WidgetPtr widget_interface,
      bool hidden) = 0;

  // Registers your factory to be called when new RenderWidgetHostImpls are
  // created. We have only one global factory, so there must be no factory
  // registered before the call. This class does NOT take ownership of the
  // pointer.
  CONTENT_EXPORT static void RegisterFactory(RenderWidgetHostFactory* factory);

  // Unregister the previously registered factory. With no factory registered,
  // the default RenderWidgetHostImpls will be created.
  CONTENT_EXPORT static void UnregisterFactory();

 private:
  // The current globally registered factory. This is NULL when we should
  // create the default RenderWidgetHostImpls.
  CONTENT_EXPORT static RenderWidgetHostFactory* factory_;

  DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostFactory);
};

}  // namespace content

#endif  // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_FACTORY_H_