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