blob: a39f51f4325544833030837a417f92931505cebb [file] [log] [blame]
[email protected]82d2c332012-08-07 22:46:311// 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
[email protected]82174aa2013-01-22 21:53:437#include "base/command_line.h"
[email protected]aa328c72013-05-03 10:55:438#include "base/debug/trace_event.h"
[email protected]eb650082012-11-29 12:05:169#include "base/path_service.h"
kkimlabs948ce92d2014-09-09 09:06:4210#include "chrome/browser/bookmarks/enhanced_bookmarks_features.h"
[email protected]cfcec9c42014-06-20 22:32:0311#include "chrome/browser/google/google_search_counter_android.h"
kkimlabs948ce92d2014-09-09 09:06:4212#include "chrome/browser/signin/signin_manager_factory.h"
[email protected]d9250fa72013-10-20 05:26:1413#include "chrome/common/chrome_paths.h"
[email protected]82174aa2013-01-22 21:53:4314#include "chrome/common/chrome_switches.h"
Robert Sesekabcd8102014-08-27 16:12:4415#include "components/crash/app/breakpad_linux.h"
16#include "components/crash/browser/crash_dump_manager_android.h"
kkimlabs948ce92d2014-09-09 09:06:4217#include "components/signin/core/browser/signin_manager.h"
[email protected]3d979262012-11-27 20:18:4018#include "content/public/browser/android/compositor.h"
[email protected]82d2c332012-08-07 22:46:3119#include "content/public/common/main_function_params.h"
[email protected]ab3309da2012-09-20 02:27:1420#include "net/android/network_change_notifier_factory_android.h"
[email protected]82d2c332012-08-07 22:46:3121#include "net/base/network_change_notifier.h"
[email protected]eb650082012-11-29 12:05:1622#include "ui/base/ui_base_paths.h"
[email protected]82d2c332012-08-07 22:46:3123
24ChromeBrowserMainPartsAndroid::ChromeBrowserMainPartsAndroid(
25 const content::MainFunctionParams& parameters)
26 : ChromeBrowserMainParts(parameters) {
27}
28
29ChromeBrowserMainPartsAndroid::~ChromeBrowserMainPartsAndroid() {
30}
31
[email protected]40da3e0c2012-10-24 22:03:3832void ChromeBrowserMainPartsAndroid::PreProfileInit() {
[email protected]aa328c72013-05-03 10:55:4333 TRACE_EVENT0("startup", "ChromeBrowserMainPartsAndroid::PreProfileInit")
[email protected]ce4367d2013-01-15 16:13:1034#if defined(GOOGLE_CHROME_BUILD)
[email protected]40da3e0c2012-10-24 22:03:3835 // TODO(jcivelli): we should not initialize the crash-reporter when it was not
36 // enabled. Right now if it is disabled we still generate the minidumps but we
37 // do not upload them.
[email protected]ce4367d2013-01-15 16:13:1038 bool breakpad_enabled = true;
39#else
40 bool breakpad_enabled = false;
41#endif
[email protected]82174aa2013-01-22 21:53:4342
[email protected]ce4367d2013-01-15 16:13:1043 // Allow Breakpad to be enabled in Chromium builds for testing purposes.
44 if (!breakpad_enabled)
[email protected]82174aa2013-01-22 21:53:4345 breakpad_enabled = CommandLine::ForCurrentProcess()->HasSwitch(
46 switches::kEnableCrashReporterForTesting);
[email protected]ce4367d2013-01-15 16:13:1047
[email protected]49373c92013-01-16 09:02:5248 if (breakpad_enabled) {
[email protected]d9250fa72013-10-20 05:26:1449 base::FilePath crash_dump_dir;
50 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_dir);
[email protected]0b818f72013-10-22 00:11:0351 crash_dump_manager_.reset(new breakpad::CrashDumpManager(crash_dump_dir));
[email protected]49373c92013-01-16 09:02:5252 }
[email protected]40da3e0c2012-10-24 22:03:3853
54 ChromeBrowserMainParts::PreProfileInit();
55}
56
[email protected]cfcec9c42014-06-20 22:32:0357void ChromeBrowserMainPartsAndroid::PostProfileInit() {
kkimlabs948ce92d2014-09-09 09:06:4258 Profile* main_profile = profile();
59 search_counter_.reset(new GoogleSearchCounterAndroid(main_profile));
60 InitBookmarksExperimentState(main_profile);
61
[email protected]cfcec9c42014-06-20 22:32:0362 ChromeBrowserMainParts::PostProfileInit();
63}
64
[email protected]82d2c332012-08-07 22:46:3165void ChromeBrowserMainPartsAndroid::PreEarlyInitialization() {
[email protected]aa328c72013-05-03 10:55:4366 TRACE_EVENT0("startup",
67 "ChromeBrowserMainPartsAndroid::PreEarlyInitialization")
[email protected]82d2c332012-08-07 22:46:3168 net::NetworkChangeNotifier::SetFactory(
[email protected]ab3309da2012-09-20 02:27:1469 new net::NetworkChangeNotifierFactoryAndroid());
[email protected]82d2c332012-08-07 22:46:3170
[email protected]3d979262012-11-27 20:18:4071 content::Compositor::Initialize();
72
[email protected]82d2c332012-08-07 22:46:3173 // Chrome on Android does not use default MessageLoop. It has its own
74 // Android specific MessageLoop.
75 DCHECK(!main_message_loop_.get());
[email protected]aa328c72013-05-03 10:55:4376
77 // Create and start the MessageLoop.
78 // This is a critical point in the startup process.
79 {
80 TRACE_EVENT0("startup",
81 "ChromeBrowserMainPartsAndroid::PreEarlyInitialization:CreateUiMsgLoop");
[email protected]166f2ed2013-12-19 19:34:0082 main_message_loop_.reset(new base::MessageLoopForUI);
[email protected]aa328c72013-05-03 10:55:4383 }
84
85 {
86 TRACE_EVENT0("startup",
87 "ChromeBrowserMainPartsAndroid::PreEarlyInitialization:StartUiMsgLoop");
[email protected]b3a25092013-05-28 22:08:1688 base::MessageLoopForUI::current()->Start();
[email protected]aa328c72013-05-03 10:55:4389 }
[email protected]82d2c332012-08-07 22:46:3190
91 ChromeBrowserMainParts::PreEarlyInitialization();
92}
93
[email protected]82d2c332012-08-07 22:46:3194void ChromeBrowserMainPartsAndroid::ShowMissingLocaleMessageBox() {
95 NOTREACHED();
96}