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/app/breakpad_win.h" | 5 #include "chrome/app/breakpad_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 #include <tchar.h> | 9 #include <tchar.h> |
| 10 #include <userenv.h> |
10 | 11 |
11 #include <algorithm> | 12 #include <algorithm> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/base_switches.h" | 15 #include "base/base_switches.h" |
15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
16 #include "base/environment.h" | 17 #include "base/environment.h" |
17 #include "base/file_util.h" | 18 #include "base/file_util.h" |
18 #include "base/file_version_info.h" | 19 #include "base/file_version_info.h" |
19 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 size_t chunk_length = std::min(kChunkSize, path.size() - chunk_start); | 215 size_t chunk_length = std::min(kChunkSize, path.size() - chunk_start); |
215 | 216 |
216 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( | 217 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( |
217 base::StringPrintf(L"plugin-path-chunk-%i", chunk_index + 1).c_str(), | 218 base::StringPrintf(L"plugin-path-chunk-%i", chunk_index + 1).c_str(), |
218 path.substr(chunk_start, chunk_length).c_str())); | 219 path.substr(chunk_start, chunk_length).c_str())); |
219 | 220 |
220 chunk_start += chunk_length; | 221 chunk_start += chunk_length; |
221 } | 222 } |
222 } | 223 } |
223 | 224 |
| 225 // Returns a string containing a list of all modifiers for the loaded profile. |
| 226 std::wstring GetProfileType() { |
| 227 std::wstring profile_type; |
| 228 DWORD profile_bits = 0; |
| 229 if (::GetProfileType(&profile_bits)) { |
| 230 static const struct { |
| 231 DWORD bit; |
| 232 const wchar_t* name; |
| 233 } kBitNames[] = { |
| 234 { PT_MANDATORY, L"mandatory" }, |
| 235 { PT_ROAMING, L"roaming" }, |
| 236 { PT_TEMPORARY, L"temporary" }, |
| 237 }; |
| 238 for (size_t i = 0; i < arraysize(kBitNames); ++i) { |
| 239 const DWORD this_bit = kBitNames[i].bit; |
| 240 if ((profile_bits & this_bit) != 0) { |
| 241 profile_type.append(kBitNames[i].name); |
| 242 profile_bits &= ~this_bit; |
| 243 if (profile_bits != 0) |
| 244 profile_type.append(L", "); |
| 245 } |
| 246 } |
| 247 } else { |
| 248 DWORD last_error = ::GetLastError(); |
| 249 base::SStringPrintf(&profile_type, L"error %u", last_error); |
| 250 } |
| 251 return profile_type; |
| 252 } |
| 253 |
224 // Returns the custom info structure based on the dll in parameter and the | 254 // Returns the custom info structure based on the dll in parameter and the |
225 // process type. | 255 // process type. |
226 google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& exe_path, | 256 google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& exe_path, |
227 const std::wstring& type, | 257 const std::wstring& type, |
228 const std::wstring& channel) { | 258 const std::wstring& channel) { |
229 scoped_ptr<FileVersionInfo> | 259 scoped_ptr<FileVersionInfo> |
230 version_info(FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); | 260 version_info(FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); |
231 | 261 |
232 std::wstring version, product; | 262 std::wstring version, product; |
233 std::wstring special_build; | 263 std::wstring special_build; |
(...skipping 25 matching lines...) Expand all Loading... |
259 g_custom_entries->push_back( | 289 g_custom_entries->push_back( |
260 google_breakpad::CustomInfoEntry(L"ver", version.c_str())); | 290 google_breakpad::CustomInfoEntry(L"ver", version.c_str())); |
261 g_custom_entries->push_back( | 291 g_custom_entries->push_back( |
262 google_breakpad::CustomInfoEntry(L"prod", product.c_str())); | 292 google_breakpad::CustomInfoEntry(L"prod", product.c_str())); |
263 g_custom_entries->push_back( | 293 g_custom_entries->push_back( |
264 google_breakpad::CustomInfoEntry(L"plat", L"Win32")); | 294 google_breakpad::CustomInfoEntry(L"plat", L"Win32")); |
265 g_custom_entries->push_back( | 295 g_custom_entries->push_back( |
266 google_breakpad::CustomInfoEntry(L"ptype", type.c_str())); | 296 google_breakpad::CustomInfoEntry(L"ptype", type.c_str())); |
267 g_custom_entries->push_back( | 297 g_custom_entries->push_back( |
268 google_breakpad::CustomInfoEntry(L"channel", channel.c_str())); | 298 google_breakpad::CustomInfoEntry(L"channel", channel.c_str())); |
| 299 g_custom_entries->push_back( |
| 300 google_breakpad::CustomInfoEntry(L"profile-type", |
| 301 GetProfileType().c_str())); |
269 | 302 |
270 if (!special_build.empty()) | 303 if (!special_build.empty()) |
271 g_custom_entries->push_back( | 304 g_custom_entries->push_back( |
272 google_breakpad::CustomInfoEntry(L"special", special_build.c_str())); | 305 google_breakpad::CustomInfoEntry(L"special", special_build.c_str())); |
273 | 306 |
274 g_num_of_extensions_offset = g_custom_entries->size(); | 307 g_num_of_extensions_offset = g_custom_entries->size(); |
275 g_custom_entries->push_back( | 308 g_custom_entries->push_back( |
276 google_breakpad::CustomInfoEntry(L"num-extensions", L"N/A")); | 309 google_breakpad::CustomInfoEntry(L"num-extensions", L"N/A")); |
277 | 310 |
278 g_extension_ids_offset = g_custom_entries->size(); | 311 g_extension_ids_offset = g_custom_entries->size(); |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 previous_filter = SetUnhandledExceptionFilter(filter); | 881 previous_filter = SetUnhandledExceptionFilter(filter); |
849 } | 882 } |
850 | 883 |
851 void StringVectorToCStringVector(const std::vector<std::wstring>& wstrings, | 884 void StringVectorToCStringVector(const std::vector<std::wstring>& wstrings, |
852 std::vector<const wchar_t*>* cstrings) { | 885 std::vector<const wchar_t*>* cstrings) { |
853 cstrings->clear(); | 886 cstrings->clear(); |
854 cstrings->reserve(wstrings.size()); | 887 cstrings->reserve(wstrings.size()); |
855 for (size_t i = 0; i < wstrings.size(); ++i) | 888 for (size_t i = 0; i < wstrings.size(); ++i) |
856 cstrings->push_back(wstrings[i].c_str()); | 889 cstrings->push_back(wstrings[i].c_str()); |
857 } | 890 } |
OLD | NEW |