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
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_APP_CONTENT_MAIN_DELEGATE_H_
6 #define CONTENT_PUBLIC_APP_CONTENT_MAIN_DELEGATE_H_
10 #include "build/build_config.h"
11 #include "content/common/content_export.h"
18 class ContentBrowserClient
;
19 class ContentPluginClient
;
20 class ContentRendererClient
;
21 class ContentUtilityClient
;
22 class ZygoteForkDelegate
;
23 struct MainFunctionParams
;
25 class CONTENT_EXPORT ContentMainDelegate
{
27 virtual ~ContentMainDelegate() {}
29 // Tells the embedder that the absolute basic startup has been done, i.e.
30 // it's now safe to create singletons and check the command line. Return true
31 // if the process should exit afterwards, and if so, |exit_code| should be
32 // set. This is the place for embedder to do the things that must happen at
33 // the start. Most of its startup code should be in the methods below.
34 virtual bool BasicStartupComplete(int* exit_code
);
36 // This is where the embedder puts all of its startup code that needs to run
37 // before the sandbox is engaged.
38 virtual void PreSandboxStartup() {}
40 // This is where the embedder can add startup code to run after the sandbox
41 // has been initialized.
42 virtual void SandboxInitialized(const std::string
& process_type
) {}
44 // Asks the embedder to start a process. Return -1 for the default behavior.
45 virtual int RunProcess(
46 const std::string
& process_type
,
47 const MainFunctionParams
& main_function_params
);
49 // Called right before the process exits.
50 virtual void ProcessExiting(const std::string
& process_type
) {}
52 #if defined(OS_MACOSX) && !defined(OS_IOS)
53 // Returns true if the process registers with the system monitor, so that we
54 // can allocate an IO port for it before the sandbox is initialized. Embedders
55 // are called only for process types that content doesn't know about.
56 virtual bool ProcessRegistersWithSystemProcess(
57 const std::string
& process_type
);
59 // Used to determine if we should send the mach port to the parent process or
60 // not. The embedder usually sends it for all child processes, use this to
61 // override this behavior.
62 virtual bool ShouldSendMachPort(const std::string
& process_type
);
64 // Allows the embedder to override initializing the sandbox. This is needed
65 // because some processes might not want to enable it right away or might not
67 virtual bool DelaySandboxInitialization(const std::string
& process_type
);
69 #elif defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_IOS)
70 // Tells the embedder that the zygote process is starting, and allows it to
71 // specify one or more zygote delegates if it wishes by storing them in
73 virtual void ZygoteStarting(ScopedVector
<ZygoteForkDelegate
>* delegates
);
75 // Called every time the zygote process forks.
76 virtual void ZygoteForked() {}
79 // TODO(vadimt, yiyaoliu): Remove this function once crbug.com/453640 is
81 // Returns whether or not profiler recording should be enabled.
82 virtual bool ShouldEnableProfilerRecording();
85 friend class ContentClientInitializer
;
87 // Called once per relevant process type to allow the embedder to customize
88 // content. If an embedder wants the default (empty) implementation, don't
90 virtual ContentBrowserClient
* CreateContentBrowserClient();
91 virtual ContentPluginClient
* CreateContentPluginClient();
92 virtual ContentRendererClient
* CreateContentRendererClient();
93 virtual ContentUtilityClient
* CreateContentUtilityClient();
96 } // namespace content
98 #endif // CONTENT_PUBLIC_APP_CONTENT_MAIN_DELEGATE_H_