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_H_ 6#define CONTENT_PUBLIC_APP_CONTENT_MAIN_H_ 7 8#include <stddef.h> 9 10#include "base/callback_forward.h" 11#include "build/build_config.h" 12#include "content/common/content_export.h" 13 14#if defined(OS_WIN) 15#include <windows.h> 16#endif 17 18namespace sandbox { 19struct SandboxInterfaceInfo; 20} 21 22namespace content { 23class ContentMainDelegate; 24 25struct ContentMainParams { 26 explicit ContentMainParams(ContentMainDelegate* delegate) 27 : delegate(delegate), 28#if defined(OS_WIN) 29 instance(NULL), 30 sandbox_info(NULL), 31#elif !defined(OS_ANDROID) 32 argc(0), 33 argv(NULL), 34#endif 35 ui_task(NULL) { 36 } 37 38 ContentMainDelegate* delegate; 39 40#if defined(OS_WIN) 41 HINSTANCE instance; 42 43 // |sandbox_info| should be initialized using InitializeSandboxInfo from 44 // content_main_win.h 45 sandbox::SandboxInterfaceInfo* sandbox_info; 46#elif !defined(OS_ANDROID) 47 int argc; 48 const char** argv; 49#endif 50 51 // Used by browser_tests. If non-null BrowserMain schedules this task to run 52 // on the MessageLoop. It's owned by the test code. 53 base::Closure* ui_task; 54}; 55 56#if defined(OS_ANDROID) 57// In the Android, the content main starts from ContentMain.java, This function 58// provides a way to set the |delegate| as ContentMainDelegate for 59// ContentMainRunner. 60// This should only be called once before ContentMainRunner actually running. 61// The ownership of |delegate| is transferred. 62CONTENT_EXPORT void SetContentMainDelegate(ContentMainDelegate* delegate); 63#else 64// ContentMain should be called from the embedder's main() function to do the 65// initial setup for every process. The embedder has a chance to customize 66// startup using the ContentMainDelegate interface. The embedder can also pass 67// in NULL for |delegate| if they don't want to override default startup. 68CONTENT_EXPORT int ContentMain(const ContentMainParams& params); 69#endif 70 71} // namespace content 72 73#endif // CONTENT_PUBLIC_APP_CONTENT_MAIN_H_ 74