| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chrome_browser_main_android.h" | 5 #include "chrome/browser/chrome_browser_main_android.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/memory/ptr_util.h" | |
| 12 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 13 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 14 #include "chrome/browser/android/seccomp_support_detector.h" | 13 #include "chrome/browser/android/seccomp_support_detector.h" |
| 15 #include "chrome/browser/signin/signin_manager_factory.h" | 14 #include "chrome/browser/signin/signin_manager_factory.h" |
| 16 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
| 17 #include "chrome/common/descriptors_android.h" | |
| 18 #include "components/crash/content/app/breakpad_linux.h" | 16 #include "components/crash/content/app/breakpad_linux.h" |
| 19 #include "components/crash/content/browser/crash_dump_manager_android.h" | 17 #include "components/crash/content/browser/crash_dump_manager_android.h" |
| 20 #include "components/signin/core/browser/signin_manager.h" | 18 #include "components/signin/core/browser/signin_manager.h" |
| 21 #include "content/public/browser/android/compositor.h" | 19 #include "content/public/browser/android/compositor.h" |
| 22 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/common/main_function_params.h" | 21 #include "content/public/common/main_function_params.h" |
| 24 #include "net/android/network_change_notifier_factory_android.h" | 22 #include "net/android/network_change_notifier_factory_android.h" |
| 25 #include "net/base/network_change_notifier.h" | 23 #include "net/base/network_change_notifier.h" |
| 26 #include "ui/base/resource/resource_bundle_android.h" | 24 #include "ui/base/resource/resource_bundle_android.h" |
| 27 #include "ui/base/ui_base_paths.h" | 25 #include "ui/base/ui_base_paths.h" |
| 28 | 26 |
| 29 namespace { | 27 namespace { |
| 30 | 28 |
| 31 void DeleteFileTask( | 29 void DeleteFileTask( |
| 32 const base::FilePath& file_path) { | 30 const base::FilePath& file_path) { |
| 33 if (base::PathExists(file_path)) | 31 if (base::PathExists(file_path)) |
| 34 base::DeleteFile(file_path, false); | 32 base::DeleteFile(file_path, false); |
| 35 } | 33 } |
| 36 | 34 |
| 37 } // namespace | 35 } // namespace |
| 38 | 36 |
| 39 ChromeBrowserMainPartsAndroid::ChromeBrowserMainPartsAndroid( | 37 ChromeBrowserMainPartsAndroid::ChromeBrowserMainPartsAndroid( |
| 40 const content::MainFunctionParams& parameters) | 38 const content::MainFunctionParams& parameters) |
| 41 : ChromeBrowserMainParts(parameters) { | 39 : ChromeBrowserMainParts(parameters) { |
| 42 } | 40 } |
| 43 | 41 |
| 44 ChromeBrowserMainPartsAndroid::~ChromeBrowserMainPartsAndroid() { | 42 ChromeBrowserMainPartsAndroid::~ChromeBrowserMainPartsAndroid() { |
| 45 breakpad::CrashDumpObserver::GetInstance()->UnregisterClient( | |
| 46 crash_dump_manager_.get()); | |
| 47 } | 43 } |
| 48 | 44 |
| 49 int ChromeBrowserMainPartsAndroid::PreCreateThreads() { | 45 int ChromeBrowserMainPartsAndroid::PreCreateThreads() { |
| 50 TRACE_EVENT0("startup", "ChromeBrowserMainPartsAndroid::PreCreateThreads") | 46 TRACE_EVENT0("startup", "ChromeBrowserMainPartsAndroid::PreCreateThreads") |
| 51 | 47 |
| 52 // The CrashDumpManager must be initialized before any child | 48 // The CrashDumpManager must be initialized before any child process is |
| 53 // process is created (as they need to access it during | 49 // created (as they need to access it during creation). Such processes |
| 54 // creation). Such processes are created on the PROCESS_LAUNCHER | 50 // are created on the PROCESS_LAUNCHER thread, and so the manager is |
| 55 // thread, and so the manager is initialized before that thread is | 51 // initialized before that thread is created. |
| 56 // created. | |
| 57 #if defined(GOOGLE_CHROME_BUILD) | 52 #if defined(GOOGLE_CHROME_BUILD) |
| 58 // TODO(jcivelli): we should not initialize the crash-reporter when it was not | 53 // TODO(jcivelli): we should not initialize the crash-reporter when it was not |
| 59 // enabled. Right now if it is disabled we still generate the minidumps but we | 54 // enabled. Right now if it is disabled we still generate the minidumps but we |
| 60 // do not upload them. | 55 // do not upload them. |
| 61 bool breakpad_enabled = true; | 56 bool breakpad_enabled = true; |
| 62 #else | 57 #else |
| 63 bool breakpad_enabled = false; | 58 bool breakpad_enabled = false; |
| 64 #endif | 59 #endif |
| 65 | 60 |
| 66 // Allow Breakpad to be enabled in Chromium builds for testing purposes. | 61 // Allow Breakpad to be enabled in Chromium builds for testing purposes. |
| 67 if (!breakpad_enabled) | 62 if (!breakpad_enabled) |
| 68 breakpad_enabled = base::CommandLine::ForCurrentProcess()->HasSwitch( | 63 breakpad_enabled = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 69 switches::kEnableCrashReporterForTesting); | 64 switches::kEnableCrashReporterForTesting); |
| 70 | 65 |
| 71 if (breakpad_enabled) { | 66 if (breakpad_enabled) { |
| 72 base::FilePath crash_dump_dir; | 67 base::FilePath crash_dump_dir; |
| 73 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_dir); | 68 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_dir); |
| 74 crash_dump_manager_ = base::MakeUnique<breakpad::CrashDumpManager>( | 69 crash_dump_manager_.reset(new breakpad::CrashDumpManager(crash_dump_dir)); |
| 75 crash_dump_dir, kAndroidMinidumpDescriptor); | |
| 76 breakpad::CrashDumpObserver::GetInstance()->RegisterClient( | |
| 77 crash_dump_manager_.get()); | |
| 78 } | 70 } |
| 79 | 71 |
| 80 ui::SetLocalePaksStoredInApk(false); | 72 ui::SetLocalePaksStoredInApk(false); |
| 81 | 73 |
| 82 return ChromeBrowserMainParts::PreCreateThreads(); | 74 return ChromeBrowserMainParts::PreCreateThreads(); |
| 83 } | 75 } |
| 84 | 76 |
| 85 void ChromeBrowserMainPartsAndroid::PostProfileInit() { | 77 void ChromeBrowserMainPartsAndroid::PostProfileInit() { |
| 86 ChromeBrowserMainParts::PostProfileInit(); | 78 ChromeBrowserMainParts::PostProfileInit(); |
| 87 | 79 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 ChromeBrowserMainParts::PostBrowserStart(); | 121 ChromeBrowserMainParts::PostBrowserStart(); |
| 130 | 122 |
| 131 content::BrowserThread::GetBlockingPool()->PostDelayedTask(FROM_HERE, | 123 content::BrowserThread::GetBlockingPool()->PostDelayedTask(FROM_HERE, |
| 132 base::Bind(&SeccompSupportDetector::StartDetection), | 124 base::Bind(&SeccompSupportDetector::StartDetection), |
| 133 base::TimeDelta::FromMinutes(1)); | 125 base::TimeDelta::FromMinutes(1)); |
| 134 } | 126 } |
| 135 | 127 |
| 136 void ChromeBrowserMainPartsAndroid::ShowMissingLocaleMessageBox() { | 128 void ChromeBrowserMainPartsAndroid::ShowMissingLocaleMessageBox() { |
| 137 NOTREACHED(); | 129 NOTREACHED(); |
| 138 } | 130 } |
| OLD | NEW |