[M85 Dev][EFL] Fix errors to generate ninja files
[platform/framework/web/chromium-efl.git] / chrome / browser / chrome_browser_main_android.cc
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 #include "chrome/browser/chrome_browser_main_android.h"
6
7 #include "base/bind.h"
8 #include "base/message_loop/message_loop_current.h"
9 #include "base/path_service.h"
10 #include "base/task/post_task.h"
11 #include "base/task/thread_pool.h"
12 #include "base/trace_event/trace_event.h"
13 #include "chrome/browser/android/mojo/chrome_interface_registrar_android.h"
14 #include "chrome/browser/android/preferences/clipboard_android.h"
15 #include "chrome/browser/android/seccomp_support_detector.h"
16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/profiles/profile_manager.h"
18 #include "components/crash/content/browser/child_exit_observer_android.h"
19 #include "components/crash/content/browser/child_process_crash_observer_android.h"
20 #include "components/metrics/stability_metrics_helper.h"
21 #include "content/public/browser/android/compositor.h"
22 #include "content/public/browser/browser_thread.h"
23 #include "content/public/common/main_function_params.h"
24 #include "net/base/network_change_notifier.h"
25 #include "ui/base/resource/resource_bundle.h"
26 #include "ui/base/resource/resource_bundle_android.h"
27 #include "ui/base/ui_base_paths.h"
28
29 ChromeBrowserMainPartsAndroid::ChromeBrowserMainPartsAndroid(
30     const content::MainFunctionParams& parameters,
31     StartupData* startup_data)
32     : ChromeBrowserMainParts(parameters, startup_data) {}
33
34 ChromeBrowserMainPartsAndroid::~ChromeBrowserMainPartsAndroid() {
35 }
36
37 int ChromeBrowserMainPartsAndroid::PreCreateThreads() {
38   TRACE_EVENT0("startup", "ChromeBrowserMainPartsAndroid::PreCreateThreads")
39
40   int result_code = ChromeBrowserMainParts::PreCreateThreads();
41
42   // The ChildExitObserver needs to be created before any child process is
43   // created because it needs to be notified during process creation.
44   crash_reporter::ChildExitObserver::Create();
45   crash_reporter::ChildExitObserver::GetInstance()->RegisterClient(
46       std::make_unique<crash_reporter::ChildProcessCrashObserver>());
47
48   return result_code;
49 }
50
51 void ChromeBrowserMainPartsAndroid::PostProfileInit() {
52   ChromeBrowserMainParts::PostProfileInit();
53
54   // Idempotent.  Needs to be called once on startup.  If
55   // InitializeClipboardAndroidFromLocalState() is called multiple times (e.g.,
56   // once per profile load), that's okay; the additional calls don't change
57   // anything.
58   android::InitClipboardAndroidFromLocalState(g_browser_process->local_state());
59
60   // Start watching the preferences that need to be backed up backup using
61   // Android backup, so that we create a new backup if they change.
62   backup_watcher_.reset(new android::ChromeBackupWatcher(profile()));
63 }
64
65 int ChromeBrowserMainPartsAndroid::PreEarlyInitialization() {
66   TRACE_EVENT0("startup",
67     "ChromeBrowserMainPartsAndroid::PreEarlyInitialization")
68   content::Compositor::Initialize();
69
70   CHECK(base::MessageLoopCurrent::IsSet());
71
72   return ChromeBrowserMainParts::PreEarlyInitialization();
73 }
74
75 void ChromeBrowserMainPartsAndroid::PostEarlyInitialization() {
76   profile_manager_android_.reset(new ProfileManagerAndroid());
77   g_browser_process->profile_manager()->AddObserver(
78       profile_manager_android_.get());
79   ChromeBrowserMainParts::PostEarlyInitialization();
80 }
81
82 void ChromeBrowserMainPartsAndroid::PostBrowserStart() {
83   ChromeBrowserMainParts::PostBrowserStart();
84
85   base::ThreadPool::PostDelayedTask(
86       FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
87       base::BindOnce(&ReportSeccompSupport), base::TimeDelta::FromMinutes(1));
88
89   RegisterChromeJavaMojoInterfaces();
90 }
91
92 void ChromeBrowserMainPartsAndroid::ShowMissingLocaleMessageBox() {
93   NOTREACHED();
94 }