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" |
21 #include "base/string_number_conversions.h" | |
20 #include "base/string_split.h" | 22 #include "base/string_split.h" |
21 #include "base/string_util.h" | 23 #include "base/string_util.h" |
22 #include "base/string16.h" | 24 #include "base/string16.h" |
23 #include "base/stringprintf.h" | 25 #include "base/stringprintf.h" |
24 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
25 #include "base/win/registry.h" | 27 #include "base/win/registry.h" |
26 #include "base/win/win_util.h" | 28 #include "base/win/win_util.h" |
27 #include "breakpad/src/client/windows/handler/exception_handler.h" | 29 #include "breakpad/src/client/windows/handler/exception_handler.h" |
28 #include "chrome/app/breakpad_field_trial_win.h" | 30 #include "chrome/app/breakpad_field_trial_win.h" |
29 #include "chrome/app/hard_error_handler_win.h" | 31 #include "chrome/app/hard_error_handler_win.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 size_t chunk_length = std::min(kChunkSize, path.size() - chunk_start); | 216 size_t chunk_length = std::min(kChunkSize, path.size() - chunk_start); |
215 | 217 |
216 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( | 218 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( |
217 base::StringPrintf(L"plugin-path-chunk-%i", chunk_index + 1).c_str(), | 219 base::StringPrintf(L"plugin-path-chunk-%i", chunk_index + 1).c_str(), |
218 path.substr(chunk_start, chunk_length).c_str())); | 220 path.substr(chunk_start, chunk_length).c_str())); |
219 | 221 |
220 chunk_start += chunk_length; | 222 chunk_start += chunk_length; |
221 } | 223 } |
222 } | 224 } |
223 | 225 |
226 // Returns a string containing a list of all modifiers for the loaded profile. | |
227 std::wstring GetProfileType() { | |
228 std::wstring profile_type; | |
229 DWORD profile_bits = 0; | |
230 if (::GetProfileType(&profile_bits)) { | |
231 static const struct { | |
232 DWORD bit; | |
233 const wchar_t* name; | |
234 } kBitNames[] = { | |
235 { PT_MANDATORY, L"mandatory" }, | |
236 { PT_ROAMING, L"roaming" }, | |
237 { PT_TEMPORARY, L"temporary" }, | |
238 }; | |
239 for (size_t i = 0; i < arraysize(kBitNames); ++i) { | |
240 const DWORD this_bit = kBitNames[i].bit; | |
241 if ((profile_bits & this_bit) != 0) { | |
242 profile_type.append(kBitNames[i].name); | |
243 profile_bits &= ~this_bit; | |
244 if (profile_bits != 0) | |
245 profile_type.append(L", "); | |
246 } | |
247 } | |
248 } else { | |
249 profile_type.assign(L"error "); | |
Sigurður Ásgeirsson
2012/07/10 10:11:14
ubernit: I'd grab GLE to a temp at the very top of
grt (UTC plus 2)
2012/07/10 12:13:48
top of the file? do you mean the top of this bloc
| |
250 profile_type.append(base::UintToString16(::GetLastError())); | |
251 } | |
252 return profile_type; | |
253 } | |
254 | |
224 // Returns the custom info structure based on the dll in parameter and the | 255 // Returns the custom info structure based on the dll in parameter and the |
225 // process type. | 256 // process type. |
226 google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& exe_path, | 257 google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& exe_path, |
227 const std::wstring& type, | 258 const std::wstring& type, |
228 const std::wstring& channel) { | 259 const std::wstring& channel) { |
229 scoped_ptr<FileVersionInfo> | 260 scoped_ptr<FileVersionInfo> |
230 version_info(FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); | 261 version_info(FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); |
231 | 262 |
232 std::wstring version, product; | 263 std::wstring version, product; |
233 std::wstring special_build; | 264 std::wstring special_build; |
(...skipping 25 matching lines...) Expand all Loading... | |
259 g_custom_entries->push_back( | 290 g_custom_entries->push_back( |
260 google_breakpad::CustomInfoEntry(L"ver", version.c_str())); | 291 google_breakpad::CustomInfoEntry(L"ver", version.c_str())); |
261 g_custom_entries->push_back( | 292 g_custom_entries->push_back( |
262 google_breakpad::CustomInfoEntry(L"prod", product.c_str())); | 293 google_breakpad::CustomInfoEntry(L"prod", product.c_str())); |
263 g_custom_entries->push_back( | 294 g_custom_entries->push_back( |
264 google_breakpad::CustomInfoEntry(L"plat", L"Win32")); | 295 google_breakpad::CustomInfoEntry(L"plat", L"Win32")); |
265 g_custom_entries->push_back( | 296 g_custom_entries->push_back( |
266 google_breakpad::CustomInfoEntry(L"ptype", type.c_str())); | 297 google_breakpad::CustomInfoEntry(L"ptype", type.c_str())); |
267 g_custom_entries->push_back( | 298 g_custom_entries->push_back( |
268 google_breakpad::CustomInfoEntry(L"channel", channel.c_str())); | 299 google_breakpad::CustomInfoEntry(L"channel", channel.c_str())); |
300 g_custom_entries->push_back( | |
301 google_breakpad::CustomInfoEntry(L"profile-type", | |
302 GetProfileType().c_str())); | |
269 | 303 |
270 if (!special_build.empty()) | 304 if (!special_build.empty()) |
271 g_custom_entries->push_back( | 305 g_custom_entries->push_back( |
272 google_breakpad::CustomInfoEntry(L"special", special_build.c_str())); | 306 google_breakpad::CustomInfoEntry(L"special", special_build.c_str())); |
273 | 307 |
274 g_num_of_extensions_offset = g_custom_entries->size(); | 308 g_num_of_extensions_offset = g_custom_entries->size(); |
275 g_custom_entries->push_back( | 309 g_custom_entries->push_back( |
276 google_breakpad::CustomInfoEntry(L"num-extensions", L"N/A")); | 310 google_breakpad::CustomInfoEntry(L"num-extensions", L"N/A")); |
277 | 311 |
278 g_extension_ids_offset = g_custom_entries->size(); | 312 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); | 882 previous_filter = SetUnhandledExceptionFilter(filter); |
849 } | 883 } |
850 | 884 |
851 void StringVectorToCStringVector(const std::vector<std::wstring>& wstrings, | 885 void StringVectorToCStringVector(const std::vector<std::wstring>& wstrings, |
852 std::vector<const wchar_t*>* cstrings) { | 886 std::vector<const wchar_t*>* cstrings) { |
853 cstrings->clear(); | 887 cstrings->clear(); |
854 cstrings->reserve(wstrings.size()); | 888 cstrings->reserve(wstrings.size()); |
855 for (size_t i = 0; i < wstrings.size(); ++i) | 889 for (size_t i = 0; i < wstrings.size(); ++i) |
856 cstrings->push_back(wstrings[i].c_str()); | 890 cstrings->push_back(wstrings[i].c_str()); |
857 } | 891 } |
OLD | NEW |