- add sources.
[platform/framework/web/crosswalk.git] / src / content / public / app / content_main_delegate.h
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.
4
5 #ifndef CONTENT_PUBLIC_APP_CONTENT_MAIN_DELEGATE_H_
6 #define CONTENT_PUBLIC_APP_CONTENT_MAIN_DELEGATE_H_
7
8 #include <string>
9
10 #include "build/build_config.h"
11 #include "content/common/content_export.h"
12
13 namespace content {
14
15 class ContentBrowserClient;
16 class ContentPluginClient;
17 class ContentRendererClient;
18 class ContentUtilityClient;
19 class ZygoteForkDelegate;
20 struct MainFunctionParams;
21
22 class CONTENT_EXPORT ContentMainDelegate {
23  public:
24   virtual ~ContentMainDelegate() {}
25
26   // Tells the embedder that the absolute basic startup has been done, i.e.
27   // it's now safe to create singletons and check the command line. Return true
28   // if the process should exit afterwards, and if so, |exit_code| should be
29   // set. This is the place for embedder to do the things that must happen at
30   // the start. Most of its startup code should be in the methods below.
31   virtual bool BasicStartupComplete(int* exit_code);
32
33   // This is where the embedder puts all of its startup code that needs to run
34   // before the sandbox is engaged.
35   virtual void PreSandboxStartup() {}
36
37   // This is where the embedder can add startup code to run after the sandbox
38   // has been initialized.
39   virtual void SandboxInitialized(const std::string& process_type) {}
40
41   // Asks the embedder to start a process. Return -1 for the default behavior.
42   virtual int RunProcess(
43       const std::string& process_type,
44       const MainFunctionParams& main_function_params);
45
46   // Called right before the process exits.
47   virtual void ProcessExiting(const std::string& process_type) {}
48
49 #if defined(OS_MACOSX) && !defined(OS_IOS)
50   // Returns true if the process registers with the system monitor, so that we
51   // can allocate an IO port for it before the sandbox is initialized. Embedders
52   // are called only for process types that content doesn't know about.
53   virtual bool ProcessRegistersWithSystemProcess(
54       const std::string& process_type);
55
56   // Used to determine if we should send the mach port to the parent process or
57   // not. The embedder usually sends it for all child processes, use this to
58   // override this behavior.
59   virtual bool ShouldSendMachPort(const std::string& process_type);
60
61   // Allows the embedder to override initializing the sandbox. This is needed
62   // because some processes might not want to enable it right away or might not
63   // want it at all.
64   virtual bool DelaySandboxInitialization(const std::string& process_type);
65
66 #elif defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_IOS)
67   // Tells the embedder that the zygote process is starting, and allows it to
68   // specify a zygote delegate if it wishes.
69   virtual ZygoteForkDelegate* ZygoteStarting();
70
71   // Called every time the zygote process forks.
72   virtual void ZygoteForked() {}
73 #endif  // OS_MACOSX
74
75  protected:
76   friend class ContentClientInitializer;
77
78   // Called once per relevant process type to allow the embedder to customize
79   // content. If an embedder wants the default (empty) implementation, don't
80   // override this.
81   virtual ContentBrowserClient* CreateContentBrowserClient();
82   virtual ContentPluginClient* CreateContentPluginClient();
83   virtual ContentRendererClient* CreateContentRendererClient();
84   virtual ContentUtilityClient* CreateContentUtilityClient();
85 };
86
87 }  // namespace content
88
89 #endif  // CONTENT_PUBLIC_APP_CONTENT_MAIN_DELEGATE_H_