blob: b29fe2403753db11a99f0f005cc8f86758efa4a5 [file] [log] [blame]
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stddef.h>
#include "base/callback.h"
#include "build/build_config.h"
#include "content/common/content_export.h"
#include <windows.h>
namespace base {
namespace mac {
class ScopedNSAutoreleasePool;
namespace sandbox {
struct SandboxInterfaceInfo;
namespace content {
class BrowserMainParts;
class ContentMainDelegate;
class ContentMainRunner;
using CreatedMainPartsClosure = base::OnceCallback<void(BrowserMainParts*)>;
struct CONTENT_EXPORT ContentMainParams {
explicit ContentMainParams(ContentMainDelegate* delegate);
// Do not reuse the moved-from ContentMainParams after this call.
ContentMainParams& operator=(ContentMainParams&&);
ContentMainDelegate* delegate;
HINSTANCE instance = nullptr;
// |sandbox_info| should be initialized using InitializeSandboxInfo from
// content_main_win.h
sandbox::SandboxInterfaceInfo* sandbox_info = nullptr;
int argc = 0;
const char** argv = nullptr;
// Used by BrowserTestBase. If set, BrowserMainLoop runs this task instead of
// the main message loop.
base::OnceClosure ui_task;
// Used by BrowserTestBase. If set, this is invoked after BrowserMainParts has
// been created and before PreEarlyInitialization().
CreatedMainPartsClosure created_main_parts_closure;
// Indicates whether to run in a minimal browser mode where most subsystems
// are left uninitialized.
bool minimal_browser_mode = false;
// The outermost autorelease pool to pass to main entry points.
base::mac::ScopedNSAutoreleasePool* autorelease_pool = nullptr;
// Returns a copy of this ContentMainParams without the move-only data
// (which is expected to be null when calling this). Used by the TestLauncher
// to launch main multiple times under the same conditions.
ContentMainParams ShallowCopyForTesting() const {
ContentMainParams copy(delegate);
copy.instance = instance;
copy.sandbox_info = sandbox_info;
copy.argc = argc;
copy.argv = argv;
copy.minimal_browser_mode = minimal_browser_mode;
copy.autorelease_pool = autorelease_pool;
return copy;
CONTENT_EXPORT int RunContentProcess(ContentMainParams params,
ContentMainRunner* content_main_runner);
// In the Android, the content main starts from, This function
// provides a way to set the |delegate| as ContentMainDelegate for
// ContentMainRunner.
// This should only be called once before ContentMainRunner actually running.
// The ownership of |delegate| is transferred.
CONTENT_EXPORT void SetContentMainDelegate(ContentMainDelegate* delegate);
// In browser tests, is not run either, and the browser test
// harness does not run ContentMain() at all. It does need to make use of the
// delegate though while replacing ContentMain().
ContentMainDelegate* GetContentMainDelegate();
// ContentMain should be called from the embedder's main() function to do the
// initial setup for every process. The embedder has a chance to customize
// startup using the ContentMainDelegate interface. The embedder can also pass
// in null for |delegate| if they don't want to override default startup.
CONTENT_EXPORT int ContentMain(ContentMainParams params);
} // namespace content