Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / chrome_browser_main_android.cc
blob9f977fc83f481ccddc7c1b7e1bb9377a8fa2b536
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/android/seccomp_support_detector.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/browser/browser_thread.h"
20 #include "content/public/common/main_function_params.h"
21 #include "net/android/network_change_notifier_factory_android.h"
22 #include "net/base/network_change_notifier.h"
23 #include "ui/base/ui_base_paths.h"
25 ChromeBrowserMainPartsAndroid::ChromeBrowserMainPartsAndroid(
26 const content::MainFunctionParams& parameters)
27 : ChromeBrowserMainParts(parameters) {
30 ChromeBrowserMainPartsAndroid::~ChromeBrowserMainPartsAndroid() {
33 int ChromeBrowserMainPartsAndroid::PreCreateThreads() {
34 TRACE_EVENT0("startup", "ChromeBrowserMainPartsAndroid::PreCreateThreads")
36 // The CrashDumpManager must be initialized before any child process is
37 // created (as they need to access it during creation). Such processes
38 // are created on the PROCESS_LAUNCHER thread, and so the manager is
39 // initialized before that thread is created.
40 #if defined(GOOGLE_CHROME_BUILD)
41 // TODO(jcivelli): we should not initialize the crash-reporter when it was not
42 // enabled. Right now if it is disabled we still generate the minidumps but we
43 // do not upload them.
44 bool breakpad_enabled = true;
45 #else
46 bool breakpad_enabled = false;
47 #endif
49 // Allow Breakpad to be enabled in Chromium builds for testing purposes.
50 if (!breakpad_enabled)
51 breakpad_enabled = base::CommandLine::ForCurrentProcess()->HasSwitch(
52 switches::kEnableCrashReporterForTesting);
54 if (breakpad_enabled) {
55 base::FilePath crash_dump_dir;
56 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_dir);
57 crash_dump_manager_.reset(new breakpad::CrashDumpManager(crash_dump_dir));
60 return ChromeBrowserMainParts::PreCreateThreads();
63 void ChromeBrowserMainPartsAndroid::PostProfileInit() {
64 Profile* main_profile = profile();
65 search_counter_.reset(new GoogleSearchCounterAndroid(main_profile));
67 ChromeBrowserMainParts::PostProfileInit();
70 void ChromeBrowserMainPartsAndroid::PreEarlyInitialization() {
71 TRACE_EVENT0("startup",
72 "ChromeBrowserMainPartsAndroid::PreEarlyInitialization")
73 net::NetworkChangeNotifier::SetFactory(
74 new net::NetworkChangeNotifierFactoryAndroid());
76 content::Compositor::Initialize();
78 // Chrome on Android does not use default MessageLoop. It has its own
79 // Android specific MessageLoop.
80 DCHECK(!main_message_loop_.get());
82 // Create and start the MessageLoop.
83 // This is a critical point in the startup process.
85 TRACE_EVENT0("startup",
86 "ChromeBrowserMainPartsAndroid::PreEarlyInitialization:CreateUiMsgLoop");
87 main_message_loop_.reset(new base::MessageLoopForUI);
91 TRACE_EVENT0("startup",
92 "ChromeBrowserMainPartsAndroid::PreEarlyInitialization:StartUiMsgLoop");
93 base::MessageLoopForUI::current()->Start();
96 ChromeBrowserMainParts::PreEarlyInitialization();
99 void ChromeBrowserMainPartsAndroid::PostBrowserStart() {
100 ChromeBrowserMainParts::PostBrowserStart();
102 content::BrowserThread::GetBlockingPool()->PostDelayedTask(FROM_HERE,
103 base::Bind(&SeccompSupportDetector::StartDetection),
104 base::TimeDelta::FromMinutes(1));
107 void ChromeBrowserMainPartsAndroid::ShowMissingLocaleMessageBox() {
108 NOTREACHED();