| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // Implementation of wrapper around common crash reporting. | 5 // Implementation of wrapper around common crash reporting. |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
| 10 #include "base/win_util.h" | 10 #include "base/win_util.h" |
| 11 #include "chrome/installer/util/google_update_settings.h" | 11 #include "chrome/installer/util/google_update_settings.h" |
| 12 #include "chrome/installer/util/install_util.h" | 12 #include "chrome/installer/util/install_util.h" |
| 13 #include "chrome_frame/chrome_frame_reporting.h" | 13 #include "chrome_frame/chrome_frame_reporting.h" |
| 14 #include "chrome_frame/utils.h" |
| 14 | 15 |
| 15 // Well known SID for the system principal. | 16 // Well known SID for the system principal. |
| 16 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; | 17 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; |
| 17 | 18 |
| 18 // Returns the custom info structure based on the dll in parameter | 19 // Returns the custom info structure based on the dll in parameter |
| 19 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* dll_path) { | 20 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* dll_path) { |
| 20 std::wstring product; | 21 std::wstring product; |
| 21 std::wstring version; | 22 std::wstring version; |
| 22 scoped_ptr<FileVersionInfo> | 23 scoped_ptr<FileVersionInfo> |
| 23 version_info(FileVersionInfo::CreateFileVersionInfo(dll_path)); | 24 version_info(FileVersionInfo::CreateFileVersionInfo(dll_path)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 39 static google_breakpad::CustomInfoEntry entries[] = { | 40 static google_breakpad::CustomInfoEntry entries[] = { |
| 40 ver_entry, prod_entry, plat_entry, type_entry }; | 41 ver_entry, prod_entry, plat_entry, type_entry }; |
| 41 static google_breakpad::CustomClientInfo custom_info = { | 42 static google_breakpad::CustomClientInfo custom_info = { |
| 42 entries, arraysize(entries) }; | 43 entries, arraysize(entries) }; |
| 43 return &custom_info; | 44 return &custom_info; |
| 44 } | 45 } |
| 45 | 46 |
| 46 extern "C" IMAGE_DOS_HEADER __ImageBase; | 47 extern "C" IMAGE_DOS_HEADER __ImageBase; |
| 47 | 48 |
| 48 bool InitializeCrashReporting() { | 49 bool InitializeCrashReporting() { |
| 49 // We want to use the Google Update crash reporting. We need to check if the | 50 // In headless mode we want crashes to be reported back. |
| 50 // user allows it first. | 51 if (!IsHeadlessMode()) { |
| 51 if (!GoogleUpdateSettings::GetCollectStatsConsent()) | 52 // We want to use the Google Update crash reporting. We need to check if the |
| 52 return true; | 53 // user allows it first. |
| 53 | 54 if (!GoogleUpdateSettings::GetCollectStatsConsent()) |
| 55 return true; |
| 56 } |
| 54 // Build the pipe name. It can be either: | 57 // Build the pipe name. It can be either: |
| 55 // System-wide install: "NamedPipe\GoogleCrashServices\S-1-5-18" | 58 // System-wide install: "NamedPipe\GoogleCrashServices\S-1-5-18" |
| 56 // Per-user install: "NamedPipe\GoogleCrashServices\<user SID>" | 59 // Per-user install: "NamedPipe\GoogleCrashServices\<user SID>" |
| 57 wchar_t dll_path[MAX_PATH * 2] = {0}; | 60 wchar_t dll_path[MAX_PATH * 2] = {0}; |
| 58 GetModuleFileName(reinterpret_cast<HMODULE>(&__ImageBase), dll_path, | 61 GetModuleFileName(reinterpret_cast<HMODULE>(&__ImageBase), dll_path, |
| 59 arraysize(dll_path)); | 62 arraysize(dll_path)); |
| 60 | 63 |
| 61 std::wstring user_sid; | 64 std::wstring user_sid; |
| 62 if (InstallUtil::IsPerUserInstall(dll_path)) { | 65 if (InstallUtil::IsPerUserInstall(dll_path)) { |
| 63 if (!win_util::GetUserSidString(&user_sid)) { | 66 if (!win_util::GetUserSidString(&user_sid)) { |
| 64 return false; | 67 return false; |
| 65 } | 68 } |
| 66 } else { | 69 } else { |
| 67 user_sid = kSystemPrincipalSid; | 70 user_sid = kSystemPrincipalSid; |
| 68 } | 71 } |
| 69 | 72 |
| 70 // Get the alternate dump directory. We use the temp path. | 73 // Get the alternate dump directory. We use the temp path. |
| 71 FilePath temp_directory; | 74 FilePath temp_directory; |
| 72 if (!file_util::GetTempDir(&temp_directory) || temp_directory.empty()) { | 75 if (!file_util::GetTempDir(&temp_directory) || temp_directory.empty()) { |
| 73 return false; | 76 return false; |
| 74 } | 77 } |
| 75 | 78 |
| 76 return InitializeVectoredCrashReporting(false, user_sid.c_str(), | 79 return InitializeVectoredCrashReporting(false, user_sid.c_str(), |
| 77 temp_directory.value(), GetCustomInfo(dll_path)); | 80 temp_directory.value(), GetCustomInfo(dll_path)); |
| 78 } | 81 } |
| 79 | 82 |
| 80 bool ShutdownCrashReporting() { | 83 bool ShutdownCrashReporting() { |
| 81 return ShutdownVectoredCrashReporting(); | 84 return ShutdownVectoredCrashReporting(); |
| 82 } | 85 } |
| OLD | NEW |