Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/common/crash_keys.h" | 5 #include "chrome/common/crash_keys.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/common/chrome_switches.h" | |
| 15 #include "content/public/common/content_switches.h" | |
| 16 #include "ipc/ipc_switches.h" | |
| 14 | 17 |
| 15 #if defined(OS_MACOSX) | 18 #if defined(OS_MACOSX) |
| 16 #include "breakpad/src/common/simple_string_dictionary.h" | 19 #include "breakpad/src/common/simple_string_dictionary.h" |
| 17 #elif defined(OS_WIN) | 20 #elif defined(OS_WIN) |
| 18 #include "breakpad/src/client/windows/common/ipc_protocol.h" | 21 #include "breakpad/src/client/windows/common/ipc_protocol.h" |
| 19 #elif defined(OS_CHROMEOS) | 22 #elif defined(OS_CHROMEOS) |
| 20 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 21 #include "gpu/command_buffer/service/gpu_switches.h" | 24 #include "gpu/command_buffer/service/gpu_switches.h" |
| 22 #include "ui/gl/gl_switches.h" | 25 #include "ui/gl/gl_switches.h" |
| 23 #endif | 26 #endif |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 // | 277 // |
| 275 // Breakpad cannot be enabled or disabled without an application restart, and | 278 // Breakpad cannot be enabled or disabled without an application restart, and |
| 276 // it needs to use the metrics client ID as its stable crash client ID, so | 279 // it needs to use the metrics client ID as its stable crash client ID, so |
| 277 // leave its client ID intact even when metrics reporting is disabled while | 280 // leave its client ID intact even when metrics reporting is disabled while |
| 278 // the application is running. | 281 // the application is running. |
| 279 base::debug::ClearCrashKey(kMetricsClientId); | 282 base::debug::ClearCrashKey(kMetricsClientId); |
| 280 #endif | 283 #endif |
| 281 } | 284 } |
| 282 | 285 |
| 283 static bool IsBoringSwitch(const std::string& flag) { | 286 static bool IsBoringSwitch(const std::string& flag) { |
| 287 static const char* const kIgnoreSwitches[] = { | |
| 288 switches::kEnableLogging, | |
| 289 switches::kFlagSwitchesBegin, | |
| 290 switches::kFlagSwitchesEnd, | |
| 291 switches::kLoggingLevel, | |
| 292 switches::kProcessChannelID, | |
| 293 switches::kProcessType, | |
| 294 switches::kV, | |
| 295 switches::kVModule, | |
| 284 #if defined(OS_WIN) | 296 #if defined(OS_WIN) |
| 285 return StartsWithASCII(flag, "--channel=", true) || | 297 switches::kForceFieldTrials, |
| 286 | 298 switches::kPluginPath, |
| 287 // No point to including this since we already have a ptype field. | |
| 288 StartsWithASCII(flag, "--type=", true) || | |
| 289 | |
| 290 // Not particularly interesting | |
| 291 StartsWithASCII(flag, "--flash-broker=", true) || | |
| 292 | |
| 293 // Just about everything has this, don't bother. | |
| 294 StartsWithASCII(flag, "/prefetch:", true) || | |
| 295 | |
| 296 // We handle the plugin path separately since it is usually too big | |
| 297 // to fit in the switches (limited to 63 characters). | |
| 298 StartsWithASCII(flag, "--plugin-path=", true) || | |
| 299 | |
| 300 // This is too big so we end up truncating it anyway. | |
| 301 StartsWithASCII(flag, "--force-fieldtrials=", true) || | |
| 302 | |
| 303 // These surround the flags that were added by about:flags, it lets | |
| 304 // you distinguish which flags were added manually via the command | |
| 305 // line versus those added through about:flags. For the most part | |
| 306 // we don't care how an option was enabled, so we strip these. | |
| 307 // (If you need to know can always look at the PEB). | |
| 308 flag == "--flag-switches-begin" || | |
| 309 flag == "--flag-switches-end"; | |
| 310 #elif defined(OS_MACOSX) | 299 #elif defined(OS_MACOSX) |
| 311 // These are carried in their own fields. | 300 switches::kMetricsClientId, |
| 312 return StartsWithASCII(flag, "--channel=", true) || | |
| 313 StartsWithASCII(flag, "--type=", true) || | |
| 314 StartsWithASCII(flag, "--metrics-client-id=", true); | |
| 315 #elif defined(OS_CHROMEOS) | 301 #elif defined(OS_CHROMEOS) |
| 316 static const char* const kIgnoreSwitches[] = { | 302 switches::kPpapiFlashArgs, |
| 317 ::switches::kEnableLogging, | 303 switches::kPpapiFlashPath, |
| 318 ::switches::kFlagSwitchesBegin, | 304 switches::kRegisterPepperPlugins, |
| 319 ::switches::kFlagSwitchesEnd, | 305 switches::kUIPrioritizeInGpuProcess, |
| 320 ::switches::kLoggingLevel, | 306 switches::kUseGL, |
| 321 ::switches::kPpapiFlashArgs, | 307 switches::kUserDataDir, |
| 322 ::switches::kPpapiFlashPath, | |
| 323 ::switches::kRegisterPepperPlugins, | |
| 324 ::switches::kUIPrioritizeInGpuProcess, | |
| 325 ::switches::kUseGL, | |
| 326 ::switches::kUserDataDir, | |
| 327 ::switches::kV, | |
| 328 ::switches::kVModule, | |
| 329 // Cros/CC flgas are specified as raw strings to avoid dependency. | 308 // Cros/CC flgas are specified as raw strings to avoid dependency. |
| 330 "child-wallpaper-large", | 309 "child-wallpaper-large", |
| 331 "child-wallpaper-small", | 310 "child-wallpaper-small", |
| 332 "default-wallpaper-large", | 311 "default-wallpaper-large", |
| 333 "default-wallpaper-small", | 312 "default-wallpaper-small", |
| 334 "guest-wallpaper-large", | 313 "guest-wallpaper-large", |
| 335 "guest-wallpaper-small", | 314 "guest-wallpaper-small", |
| 336 "enterprise-enable-forced-re-enrollment", | 315 "enterprise-enable-forced-re-enrollment", |
| 337 "enterprise-enrollment-initial-modulus", | 316 "enterprise-enrollment-initial-modulus", |
| 338 "enterprise-enrollment-modulus-limit", | 317 "enterprise-enrollment-modulus-limit", |
| 339 "login-profile", | 318 "login-profile", |
| 340 "login-user", | 319 "login-user", |
| 341 "max-tiles-for-interest-area", | 320 "max-tiles-for-interest-area", |
| 342 "max-unused-resource-memory-usage-percentage", | 321 "max-unused-resource-memory-usage-percentage", |
| 343 "termination-message-file", | 322 "termination-message-file", |
| 344 "use-cras", | 323 "use-cras", |
| 324 #endif | |
| 345 }; | 325 }; |
| 326 | |
| 327 #if defined(OS_WIN) | |
| 328 // Just about everything has this, don't bother. | |
| 329 if (StartsWithASCII("/prefetch:")) | |
|
Lei Zhang
2015/04/16 18:24:32
err, looks like you are missing a couple arguments
Robert Sesek
2015/04/16 22:00:29
Oops, got a bit aggressive with the deleting there
| |
| 330 return true; | |
| 331 #endif | |
| 332 | |
| 346 if (!StartsWithASCII(flag, "--", true)) | 333 if (!StartsWithASCII(flag, "--", true)) |
| 347 return false; | 334 return false; |
| 348 std::size_t end = flag.find("="); | 335 size_t end = flag.find("="); |
| 349 int len = (end == std::string::npos) ? flag.length() - 2 : end - 2; | 336 int len = (end == std::string::npos) ? flag.length() - 2 : end - 2; |
|
Lei Zhang
2015/04/16 18:24:32
and this probably needs to be a size_t
Robert Sesek
2015/04/16 22:00:29
Done.
| |
| 350 for (size_t i = 0; i < arraysize(kIgnoreSwitches); ++i) { | 337 for (size_t i = 0; i < arraysize(kIgnoreSwitches); ++i) { |
| 351 if (flag.compare(2, len, kIgnoreSwitches[i]) == 0) | 338 if (flag.compare(2, len, kIgnoreSwitches[i]) == 0) |
| 352 return true; | 339 return true; |
| 353 } | 340 } |
| 354 return false; | 341 return false; |
| 355 #else | |
| 356 return false; | |
| 357 #endif | |
| 358 } | 342 } |
| 359 | 343 |
| 360 void SetSwitchesFromCommandLine(const base::CommandLine* command_line) { | 344 void SetSwitchesFromCommandLine(const base::CommandLine* command_line) { |
| 361 DCHECK(command_line); | 345 DCHECK(command_line); |
| 362 if (!command_line) | 346 if (!command_line) |
| 363 return; | 347 return; |
| 364 | 348 |
| 365 const base::CommandLine::StringVector& argv = command_line->argv(); | 349 const base::CommandLine::StringVector& argv = command_line->argv(); |
| 366 | 350 |
| 367 // Set the number of switches in case size > kNumSwitches. | 351 // Set the number of switches in case size > kNumSwitches. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 } | 428 } |
| 445 | 429 |
| 446 ScopedPrinterInfo::~ScopedPrinterInfo() { | 430 ScopedPrinterInfo::~ScopedPrinterInfo() { |
| 447 for (size_t i = 0; i < kPrinterInfoCount; ++i) { | 431 for (size_t i = 0; i < kPrinterInfoCount; ++i) { |
| 448 std::string key = base::StringPrintf(kPrinterInfo, i + 1); | 432 std::string key = base::StringPrintf(kPrinterInfo, i + 1); |
| 449 base::debug::ClearCrashKey(key); | 433 base::debug::ClearCrashKey(key); |
| 450 } | 434 } |
| 451 } | 435 } |
| 452 | 436 |
| 453 } // namespace crash_keys | 437 } // namespace crash_keys |
| OLD | NEW |