summaryrefslogtreecommitdiff
path: root/chromium/fuchsia/engine/web_engine_main.cc
blob: f583ec11c6e4b5e2bcac02bc76e68182feaf6e67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <zircon/process.h>

#include "base/command_line.h"
#include "content/public/app/content_main.h"
#include "content/public/common/content_switches.h"
#include "fuchsia/engine/context_provider_impl.h"
#include "fuchsia/engine/context_provider_main.h"
#include "fuchsia/engine/web_engine_main_delegate.h"

int main(int argc, const char** argv) {
  base::CommandLine::Init(argc, argv);

  std::string process_type =
      base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
          switches::kProcessType);
  fidl::InterfaceRequest<fuchsia::web::Context> context;

  if (process_type.empty()) {
    // zx_take_startup_handle() is called only when process_type is empty (i.e.
    // for Browser and ContextProvider processes). Renderer and other child
    // processes may use the same handle id for other handles.
    context.set_channel(zx::channel(
        zx_take_startup_handle(ContextProviderImpl::kContextRequestHandleId)));

    // If |process_type| is empty then this may be a Browser process, or the
    // main ContextProvider process. Browser processes will have a
    // |context_channel| set
    if (!context)
      return ContextProviderMain();
  }

  WebEngineMainDelegate delegate(std::move(context));
  content::ContentMainParams params(&delegate);

  // Repeated base::CommandLine::Init() is ignored, so it's safe to pass null
  // args here.
  params.argc = 0;
  params.argv = nullptr;

  return content::ContentMain(params);
}