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.
5 #include "chrome/browser/chrome_browser_main_android.h"
7 #include "base/command_line.h"
8 #include "base/debug/trace_event.h"
9 #include "base/path_service.h"
10 #include "cc/base/switches.h"
11 #include "chrome/app/breakpad_linux.h"
12 #include "chrome/browser/android/crash_dump_manager.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "content/public/browser/android/compositor.h"
15 #include "content/public/common/main_function_params.h"
16 #include "net/android/network_change_notifier_factory_android.h"
17 #include "net/base/network_change_notifier.h"
18 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/base/ui_base_paths.h"
21 ChromeBrowserMainPartsAndroid::ChromeBrowserMainPartsAndroid(
22 const content::MainFunctionParams
& parameters
)
23 : ChromeBrowserMainParts(parameters
) {
26 ChromeBrowserMainPartsAndroid::~ChromeBrowserMainPartsAndroid() {
29 void ChromeBrowserMainPartsAndroid::PreProfileInit() {
30 TRACE_EVENT0("startup", "ChromeBrowserMainPartsAndroid::PreProfileInit")
31 #if defined(USE_LINUX_BREAKPAD)
32 #if defined(GOOGLE_CHROME_BUILD)
33 // TODO(jcivelli): we should not initialize the crash-reporter when it was not
34 // enabled. Right now if it is disabled we still generate the minidumps but we
35 // do not upload them.
36 bool breakpad_enabled
= true;
38 bool breakpad_enabled
= false;
41 // Allow Breakpad to be enabled in Chromium builds for testing purposes.
42 if (!breakpad_enabled
)
43 breakpad_enabled
= CommandLine::ForCurrentProcess()->HasSwitch(
44 switches::kEnableCrashReporterForTesting
);
46 if (breakpad_enabled
) {
48 crash_dump_manager_
.reset(new CrashDumpManager());
52 ChromeBrowserMainParts::PreProfileInit();
55 void ChromeBrowserMainPartsAndroid::PreEarlyInitialization() {
56 TRACE_EVENT0("startup",
57 "ChromeBrowserMainPartsAndroid::PreEarlyInitialization")
58 net::NetworkChangeNotifier::SetFactory(
59 new net::NetworkChangeNotifierFactoryAndroid());
61 content::Compositor::Initialize();
63 // Chrome on Android does not use default MessageLoop. It has its own
64 // Android specific MessageLoop.
65 DCHECK(!main_message_loop_
.get());
67 // Create and start the MessageLoop.
68 // This is a critical point in the startup process.
70 TRACE_EVENT0("startup",
71 "ChromeBrowserMainPartsAndroid::PreEarlyInitialization:CreateUiMsgLoop");
72 main_message_loop_
.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI
));
76 TRACE_EVENT0("startup",
77 "ChromeBrowserMainPartsAndroid::PreEarlyInitialization:StartUiMsgLoop");
78 base::MessageLoopForUI::current()->Start();
81 CommandLine::ForCurrentProcess()->AppendSwitch(
82 cc::switches::kCompositeToMailbox
);
84 ChromeBrowserMainParts::PreEarlyInitialization();
87 int ChromeBrowserMainPartsAndroid::PreCreateThreads() {
88 TRACE_EVENT0("startup", "ChromeBrowserMainPartsAndroid::PreCreateThreads")
89 // PreCreateThreads initializes ResourceBundle instance.
90 const int result
= ChromeBrowserMainParts::PreCreateThreads();
92 // Add devtools_resources.pak which is used in Chromium TestShell.
93 base::FilePath paks_path
;
94 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID
, &paks_path
);
95 ResourceBundle::GetSharedInstance().AddOptionalDataPackFromPath(
96 paks_path
.Append(FILE_PATH_LITERAL("devtools_resources.pak")),
97 ui::SCALE_FACTOR_NONE
);
102 void ChromeBrowserMainPartsAndroid::ShowMissingLocaleMessageBox() {
106 void RecordBreakpadStatusUMA(MetricsService
* metrics
) {
107 // TODO: crbug.com/139023
111 void WarnAboutMinimumSystemRequirements() {