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.
5 #ifndef XWALK_RUNTIME_BROWSER_XWALK_BROWSER_MAIN_PARTS_H_
6 #define XWALK_RUNTIME_BROWSER_XWALK_BROWSER_MAIN_PARTS_H_
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"
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"
20 class RenderProcessHost;
25 class RemoteDebuggingServer;
28 namespace extensions {
29 class XWalkExtensionService;
32 class XWalkBrowserMainParts : public content::BrowserMainParts {
34 explicit XWalkBrowserMainParts(
35 const content::MainFunctionParams& parameters);
37 virtual ~XWalkBrowserMainParts();
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;
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);
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);
67 void RegisterExternalExtensions();
69 XWalkRunner* xwalk_runner_;
71 extensions::XWalkExtensionService* extension_service_;
73 // Should be about:blank If no URL is specified in command line arguments.
76 // The main function parameters passed to BrowserMain.
77 const content::MainFunctionParams& parameters_;
79 // True if we need to run the default message loop defined in content.
80 bool run_default_message_loop_;
82 // Remote debugger server.
83 scoped_ptr<RemoteDebuggingServer> remote_debugging_server_;
86 DISALLOW_COPY_AND_ASSIGN(XWalkBrowserMainParts);
91 #endif // XWALK_RUNTIME_BROWSER_XWALK_BROWSER_MAIN_PARTS_H_