15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_PUBLIC_APP_CONTENT_MAIN_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_PUBLIC_APP_CONTENT_MAIN_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include <stddef.h>
9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "base/callback_forward.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "build/build_config.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <windows.h>
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace sandbox {
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct SandboxInterfaceInfo;
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ContentMainDelegate;
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)struct ContentMainParams {
26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  explicit ContentMainParams(ContentMainDelegate* delegate)
2723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)      : delegate(delegate),
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
2923730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)        instance(NULL),
3023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)        sandbox_info(NULL),
31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#elif !defined(OS_ANDROID)
3223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)        argc(0),
3323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)        argv(NULL),
34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif
3523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)        ui_task(NULL) {
36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  ContentMainDelegate* delegate;
39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
40a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#if defined(OS_WIN)
41a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  HINSTANCE instance;
42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // |sandbox_info| should be initialized using InitializeSandboxInfo from
44a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // content_main_win.h
45a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  sandbox::SandboxInterfaceInfo* sandbox_info;
46a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#elif !defined(OS_ANDROID)
47a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  int argc;
48a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  const char** argv;
49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif
5023730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)
5123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // Used by browser_tests. If non-null BrowserMain schedules this task to run
5223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  // on the MessageLoop. It's owned by the test code.
5323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  base::Closure* ui_task;
54a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)};
55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
56a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#if defined(OS_ANDROID)
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// In the Android, the content main starts from ContentMain.java, This function
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// provides a way to set the |delegate| as ContentMainDelegate for
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// ContentMainRunner.
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This should only be called once before ContentMainRunner actually running.
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The ownership of |delegate| is transferred.
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)CONTENT_EXPORT void SetContentMainDelegate(ContentMainDelegate* delegate);
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
64a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// ContentMain should be called from the embedder's main() function to do the
65a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// initial setup for every process. The embedder has a chance to customize
66a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// startup using the ContentMainDelegate interface. The embedder can also pass
67a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// in NULL for |delegate| if they don't want to override default startup.
68a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)CONTENT_EXPORT int ContentMain(const ContentMainParams& params);
69a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace content
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CONTENT_PUBLIC_APP_CONTENT_MAIN_H_
74