Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / browser / xwalk_browser_main_parts.h
1 // Copyright (c) 2013 Intel Corporation. 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 XWALK_RUNTIME_BROWSER_XWALK_BROWSER_MAIN_PARTS_H_
6 #define XWALK_RUNTIME_BROWSER_XWALK_BROWSER_MAIN_PARTS_H_
7
8 #include <string>
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h"
12 #include "content/public/browser/browser_main_parts.h"
13 #include "content/public/common/main_function_params.h"
14 #include "url/gurl.h"
15 #include "xwalk/extensions/browser/xwalk_extension_service.h"
16 #include "xwalk/extensions/common/xwalk_extension_permission_types.h"
17 #include "xwalk/extensions/common/xwalk_extension_vector.h"
18
19 namespace content {
20 class RenderProcessHost;
21 }
22
23 namespace xwalk {
24
25 class RemoteDebuggingServer;
26 class XWalkRunner;
27
28 namespace extensions {
29 class XWalkExtensionService;
30 }
31
32 class XWalkBrowserMainParts : public content::BrowserMainParts {
33  public:
34   explicit XWalkBrowserMainParts(
35       const content::MainFunctionParams& parameters);
36
37   virtual ~XWalkBrowserMainParts();
38
39   // BrowserMainParts overrides.
40   virtual void PreEarlyInitialization() OVERRIDE;
41   virtual int PreCreateThreads() OVERRIDE;
42   virtual void PreMainMessageLoopStart() OVERRIDE;
43   virtual void PostMainMessageLoopStart() OVERRIDE;
44   virtual void PreMainMessageLoopRun() OVERRIDE;
45   virtual bool MainMessageLoopRun(int* result_code) OVERRIDE;
46   virtual void PostMainMessageLoopRun() OVERRIDE;
47
48   // Create all the extensions to be hooked into a new
49   // RenderProcessHost. Base class implementation should be called by
50   // subclasses overriding this..
51   virtual void CreateInternalExtensionsForUIThread(
52       content::RenderProcessHost* host,
53       extensions::XWalkExtensionVector* extensions);
54   virtual void CreateInternalExtensionsForExtensionThread(
55       content::RenderProcessHost* host,
56       extensions::XWalkExtensionVector* extensions);
57
58 #if defined(OS_ANDROID)
59   // XWalkExtensionAndroid needs to register its extensions on
60   // XWalkBrowserMainParts so they get correctly registered on-demand
61   // by XWalkExtensionService each time a in_process Server is created.
62   void RegisterExtension(scoped_ptr<extensions::XWalkExtension> extension);
63   void UnregisterExtension(scoped_ptr<extensions::XWalkExtension> extension);
64 #endif
65
66  protected:
67   void RegisterExternalExtensions();
68
69   XWalkRunner* xwalk_runner_;
70
71   extensions::XWalkExtensionService* extension_service_;
72
73   // Should be about:blank If no URL is specified in command line arguments.
74   GURL startup_url_;
75
76   // The main function parameters passed to BrowserMain.
77   const content::MainFunctionParams& parameters_;
78
79   // True if we need to run the default message loop defined in content.
80   bool run_default_message_loop_;
81
82   // Remote debugger server.
83   scoped_ptr<RemoteDebuggingServer> remote_debugging_server_;
84
85  private:
86   DISALLOW_COPY_AND_ASSIGN(XWalkBrowserMainParts);
87 };
88
89 }  // namespace xwalk
90
91 #endif  // XWALK_RUNTIME_BROWSER_XWALK_BROWSER_MAIN_PARTS_H_