| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/crash/app/crash_keys_win.h" | 5 #include "components/crash/app/crash_keys_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 14 #include "base/strings/utf_string_conversions.h" | |
| 15 #include "components/crash/app/crash_reporter_client.h" | 15 #include "components/crash/app/crash_reporter_client.h" |
| 16 | 16 |
| 17 namespace breakpad { | 17 namespace breakpad { |
| 18 | 18 |
| 19 using crash_reporter::CrashReporterClient; | 19 using crash_reporter::CrashReporterClient; |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 const size_t kMaxPluginPathLength = 256; | 23 const size_t kMaxPluginPathLength = 256; |
| 24 const size_t kMaxDynamicEntries = 256; | 24 const size_t kMaxDynamicEntries = 256; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 crash_client->GetProductNameAndVersion( | 88 crash_client->GetProductNameAndVersion( |
| 89 base::FilePath(exe_path), | 89 base::FilePath(exe_path), |
| 90 &product, | 90 &product, |
| 91 &version, | 91 &version, |
| 92 &special_build, | 92 &special_build, |
| 93 &channel_name); | 93 &channel_name); |
| 94 | 94 |
| 95 // We only expect this method to be called once per process. | 95 // We only expect this method to be called once per process. |
| 96 // Common enties | 96 // Common enties |
| 97 custom_entries_.push_back( | 97 custom_entries_.push_back( |
| 98 google_breakpad::CustomInfoEntry(L"ver", | 98 google_breakpad::CustomInfoEntry(L"ver", version.c_str())); |
| 99 base::UTF16ToWide(version).c_str())); | |
| 100 custom_entries_.push_back( | 99 custom_entries_.push_back( |
| 101 google_breakpad::CustomInfoEntry(L"prod", | 100 google_breakpad::CustomInfoEntry(L"prod", product.c_str())); |
| 102 base::UTF16ToWide(product).c_str())); | |
| 103 custom_entries_.push_back( | 101 custom_entries_.push_back( |
| 104 google_breakpad::CustomInfoEntry(L"plat", L"Win32")); | 102 google_breakpad::CustomInfoEntry(L"plat", L"Win32")); |
| 105 custom_entries_.push_back( | 103 custom_entries_.push_back( |
| 106 google_breakpad::CustomInfoEntry(L"ptype", type.c_str())); | 104 google_breakpad::CustomInfoEntry(L"ptype", type.c_str())); |
| 107 custom_entries_.push_back(google_breakpad::CustomInfoEntry( | 105 custom_entries_.push_back( |
| 108 L"pid", base::StringPrintf(L"%d", ::GetCurrentProcessId()).c_str())); | 106 google_breakpad::CustomInfoEntry( |
| 109 custom_entries_.push_back(google_breakpad::CustomInfoEntry( | 107 L"pid", base::IntToString16(::GetCurrentProcessId()).c_str())); |
| 110 L"channel", base::UTF16ToWide(channel_name).c_str())); | 108 custom_entries_.push_back( |
| 111 custom_entries_.push_back(google_breakpad::CustomInfoEntry( | 109 google_breakpad::CustomInfoEntry(L"channel", channel_name.c_str())); |
| 112 L"profile-type", profile_type.c_str())); | 110 custom_entries_.push_back( |
| 111 google_breakpad::CustomInfoEntry(L"profile-type", profile_type.c_str())); |
| 113 | 112 |
| 114 if (!special_build.empty()) | 113 if (!special_build.empty()) { |
| 115 custom_entries_.push_back(google_breakpad::CustomInfoEntry( | 114 custom_entries_.push_back( |
| 116 L"special", base::UTF16ToWide(special_build).c_str())); | 115 google_breakpad::CustomInfoEntry(L"special", special_build.c_str())); |
| 116 } |
| 117 | 117 |
| 118 if (type == L"plugin" || type == L"ppapi") { | 118 if (type == L"plugin" || type == L"ppapi") { |
| 119 std::wstring plugin_path = cmd_line->GetSwitchValueNative("plugin-path"); | 119 std::wstring plugin_path = cmd_line->GetSwitchValueNative("plugin-path"); |
| 120 if (!plugin_path.empty()) | 120 if (!plugin_path.empty()) |
| 121 SetPluginPath(plugin_path); | 121 SetPluginPath(plugin_path); |
| 122 } | 122 } |
| 123 | 123 |
| 124 | |
| 125 // Check whether configuration management controls crash reporting. | 124 // Check whether configuration management controls crash reporting. |
| 126 bool crash_reporting_enabled = true; | 125 bool crash_reporting_enabled = true; |
| 127 bool controlled_by_policy = crash_client->ReportingIsEnforcedByPolicy( | 126 bool controlled_by_policy = crash_client->ReportingIsEnforcedByPolicy( |
| 128 &crash_reporting_enabled); | 127 &crash_reporting_enabled); |
| 129 bool use_crash_service = !controlled_by_policy && | 128 bool use_crash_service = !controlled_by_policy && |
| 130 (cmd_line->HasSwitch(switches::kNoErrorDialogs) || | 129 (cmd_line->HasSwitch(switches::kNoErrorDialogs) || |
| 131 crash_client->IsRunningUnattended()); | 130 crash_client->IsRunningUnattended()); |
| 132 if (use_crash_service) | 131 if (use_crash_service) |
| 133 SetBreakpadDumpPath(crash_client); | 132 SetBreakpadDumpPath(crash_client); |
| 134 | 133 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 183 |
| 185 std::wstring key_string(key); | 184 std::wstring key_string(key); |
| 186 DynamicEntriesMap::iterator it = dynamic_entries_.find(key_string); | 185 DynamicEntriesMap::iterator it = dynamic_entries_.find(key_string); |
| 187 if (it == dynamic_entries_.end()) | 186 if (it == dynamic_entries_.end()) |
| 188 return; | 187 return; |
| 189 | 188 |
| 190 it->second->set_value(NULL); | 189 it->second->set_value(NULL); |
| 191 } | 190 } |
| 192 | 191 |
| 193 } // namespace breakpad | 192 } // namespace breakpad |
| OLD | NEW |