Rename gdata_errorcode.h to drive_api_error_codes.h
[chromium-blink-merge.git] / chrome / browser / chrome_browser_main_android.cc
blob979b296e14c18e683c61d37ee8e0fc81f731840f
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/path_service.h"
9 #include "base/trace_event/trace_event.h"
10 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h"
11 #include "chrome/browser/google/google_search_counter_android.h"
12 #include "chrome/browser/signin/signin_manager_factory.h"
13 #include "chrome/common/chrome_paths.h"
14 #include "chrome/common/chrome_switches.h"
15 #include "components/crash/app/breakpad_linux.h"
16 #include "components/crash/browser/crash_dump_manager_android.h"
17 #include "components/signin/core/browser/signin_manager.h"
18 #include "content/public/browser/android/compositor.h"
19 #include "content/public/common/main_function_params.h"
20 #include "net/android/network_change_notifier_factory_android.h"
21 #include "net/base/network_change_notifier.h"
22 #include "ui/base/ui_base_paths.h"
24 ChromeBrowserMainPartsAndroid::ChromeBrowserMainPartsAndroid(
25 const content::MainFunctionParams& parameters)
26 : ChromeBrowserMainParts(parameters) {
29 ChromeBrowserMainPartsAndroid::~ChromeBrowserMainPartsAndroid() {
32 void ChromeBrowserMainPartsAndroid::PreProfileInit() {
33 TRACE_EVENT0("startup", "ChromeBrowserMainPartsAndroid::PreProfileInit")
34 #if defined(GOOGLE_CHROME_BUILD)
35 // 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.
38 bool breakpad_enabled = true;
39 #else
40 bool breakpad_enabled = false;
41 #endif
43 // Allow Breakpad to be enabled in Chromium builds for testing purposes.
44 if (!breakpad_enabled)
45 breakpad_enabled = base::CommandLine::ForCurrentProcess()->HasSwitch(
46 switches::kEnableCrashReporterForTesting);
48 if (breakpad_enabled) {
49 base::FilePath crash_dump_dir;
50 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_dir);
51 crash_dump_manager_.reset(new breakpad::CrashDumpManager(crash_dump_dir));
54 ChromeBrowserMainParts::PreProfileInit();
57 void ChromeBrowserMainPartsAndroid::PostProfileInit() {
58 Profile* main_profile = profile();
59 search_counter_.reset(new GoogleSearchCounterAndroid(main_profile));
60 InitBookmarksExperimentState(main_profile);
62 ChromeBrowserMainParts::PostProfileInit();
65 void ChromeBrowserMainPartsAndroid::PreEarlyInitialization() {
66 TRACE_EVENT0("startup",
67 "ChromeBrowserMainPartsAndroid::PreEarlyInitialization")
68 net::NetworkChangeNotifier::SetFactory(
69 new net::NetworkChangeNotifierFactoryAndroid());
71 content::Compositor::Initialize();
73 // Chrome on Android does not use default MessageLoop. It has its own
74 // Android specific MessageLoop.
75 DCHECK(!main_message_loop_.get());
77 // Create and start the MessageLoop.
78 // This is a critical point in the startup process.
80 TRACE_EVENT0("startup",
81 "ChromeBrowserMainPartsAndroid::PreEarlyInitialization:CreateUiMsgLoop");
82 main_message_loop_.reset(new base::MessageLoopForUI);
86 TRACE_EVENT0("startup",
87 "ChromeBrowserMainPartsAndroid::PreEarlyInitialization:StartUiMsgLoop");
88 base::MessageLoopForUI::current()->Start();
91 ChromeBrowserMainParts::PreEarlyInitialization();
94 void ChromeBrowserMainPartsAndroid::ShowMissingLocaleMessageBox() {
95 NOTREACHED();