summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chrome_browser_main_android.cc
blob: 1c8459d91546e00ebc22781d5830a32320058a3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/chrome_browser_main_android.h"

#include "base/command_line.h"
#include "base/path_service.h"
#include "chrome/app/breakpad_linux.h"
#include "chrome/browser/android/crash_dump_manager.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/android/compositor.h"
#include "content/public/common/main_function_params.h"
#include "net/android/network_change_notifier_factory_android.h"
#include "net/base/network_change_notifier.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"

ChromeBrowserMainPartsAndroid::ChromeBrowserMainPartsAndroid(
    const content::MainFunctionParams& parameters)
    : ChromeBrowserMainParts(parameters) {
}

ChromeBrowserMainPartsAndroid::~ChromeBrowserMainPartsAndroid() {
}

void ChromeBrowserMainPartsAndroid::PreProfileInit() {
#if defined(USE_LINUX_BREAKPAD)
#if defined(GOOGLE_CHROME_BUILD)
  // TODO(jcivelli): we should not initialize the crash-reporter when it was not
  // enabled. Right now if it is disabled we still generate the minidumps but we
  // do not upload them.
  bool breakpad_enabled = true;
#else
  bool breakpad_enabled = false;
#endif

  // Allow Breakpad to be enabled in Chromium builds for testing purposes.
  if (!breakpad_enabled)
    breakpad_enabled = CommandLine::ForCurrentProcess()->HasSwitch(
          switches::kEnableCrashReporterForTesting);

  if (breakpad_enabled) {
    InitCrashReporter();
    crash_dump_manager_.reset(new CrashDumpManager());
  }
#endif

  ChromeBrowserMainParts::PreProfileInit();
}

void ChromeBrowserMainPartsAndroid::PreEarlyInitialization() {
  net::NetworkChangeNotifier::SetFactory(
      new net::NetworkChangeNotifierFactoryAndroid());

  content::Compositor::Initialize();

  // Chrome on Android does not use default MessageLoop. It has its own
  // Android specific MessageLoop.
  DCHECK(!main_message_loop_.get());
  main_message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI));
  MessageLoopForUI::current()->Start();

  ChromeBrowserMainParts::PreEarlyInitialization();
}

int ChromeBrowserMainPartsAndroid::PreCreateThreads() {
  // PreCreateThreads initializes ResourceBundle instance.
  const int result = ChromeBrowserMainParts::PreCreateThreads();

  // Add devtools_resources.pak which is used in Chromium TestShell.
  base::FilePath paks_path;
  PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &paks_path);
  ResourceBundle::GetSharedInstance().AddOptionalDataPackFromPath(
      paks_path.Append(FILE_PATH_LITERAL("devtools_resources.pak")),
      ui::SCALE_FACTOR_NONE);

  return result;
}

void ChromeBrowserMainPartsAndroid::ShowMissingLocaleMessageBox() {
  NOTREACHED();
}

void RecordBreakpadStatusUMA(MetricsService* metrics) {
  // TODO: crbug.com/139023
  NOTIMPLEMENTED();
}

void WarnAboutMinimumSystemRequirements() {
}