main.cc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2019 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. #include "weblayer/public/main.h"
  5. #include "build/build_config.h"
  6. #include "content/public/app/content_main.h"
  7. #include "weblayer/app/content_main_delegate_impl.h"
  8. #if BUILDFLAG(IS_WIN)
  9. #include "base/win/win_util.h"
  10. #include "content/public/app/sandbox_helper_win.h"
  11. #include "sandbox/win/src/sandbox_types.h"
  12. #endif
  13. namespace weblayer {
  14. MainParams::MainParams() = default;
  15. MainParams::MainParams(const MainParams& other) = default;
  16. MainParams::~MainParams() = default;
  17. #if !BUILDFLAG(IS_ANDROID)
  18. int Main(MainParams params
  19. #if BUILDFLAG(IS_WIN)
  20. #if !defined(WIN_CONSOLE_APP)
  21. ,
  22. HINSTANCE instance
  23. #endif
  24. #else
  25. ,
  26. int argc,
  27. const char** argv
  28. #endif
  29. ) {
  30. ContentMainDelegateImpl delegate(std::move(params));
  31. content::ContentMainParams content_params(&delegate);
  32. #if BUILDFLAG(IS_WIN)
  33. #if defined(WIN_CONSOLE_APP)
  34. HINSTANCE instance = GetModuleHandle(nullptr);
  35. #endif
  36. sandbox::SandboxInterfaceInfo sandbox_info = {nullptr};
  37. content::InitializeSandboxInfo(&sandbox_info);
  38. content_params.instance = instance;
  39. content_params.sandbox_info = &sandbox_info;
  40. #else
  41. content_params.argc = argc;
  42. content_params.argv = argv;
  43. #endif
  44. return content::ContentMain(std::move(content_params));
  45. }
  46. #endif // !BUILDFLAG(IS_ANDROID)
  47. } // namespace weblayer