Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/switch_utils.h" | 5 #include "chrome/common/switch_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "build/build_config.h" | |
| 10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 11 | 12 |
| 13 #if defined(OS_WIN) | |
| 14 #include "base/strings/string_util.h" | |
| 15 #endif // defined(OS_WIN) | |
| 16 | |
| 12 namespace switches { | 17 namespace switches { |
| 13 | 18 |
| 19 namespace { | |
| 20 | |
| 14 // Switches enumerated here will be removed when a background instance of | 21 // Switches enumerated here will be removed when a background instance of |
| 15 // Chrome restarts itself. If your key is designed to only be used once, | 22 // Chrome restarts itself. If your key is designed to only be used once, |
| 16 // or if it does not make sense when restarting a background instance to | 23 // or if it does not make sense when restarting a background instance to |
| 17 // pick up an automatic update, be sure to add it to this list. | 24 // pick up an automatic update, be sure to add it to this list. |
| 18 const char* const kSwitchesToRemoveOnAutorestart[] = { | 25 const char* const kSwitchesToRemoveOnAutorestart[] = { |
| 19 switches::kApp, | 26 switches::kApp, |
| 20 switches::kAppId, | 27 switches::kAppId, |
| 21 switches::kForceFirstRun, | 28 switches::kForceFirstRun, |
| 22 switches::kMakeDefaultBrowser, | 29 switches::kMakeDefaultBrowser, |
| 23 switches::kNoStartupWindow, | 30 switches::kNoStartupWindow, |
| 24 switches::kRestoreLastSession, | 31 switches::kRestoreLastSession, |
| 25 switches::kShowAppList, | 32 switches::kShowAppList, |
| 26 switches::kWinJumplistAction | 33 switches::kWinJumplistAction |
| 27 }; | 34 }; |
| 28 | 35 |
| 36 } // namespace | |
| 37 | |
| 29 void RemoveSwitchesForAutostart( | 38 void RemoveSwitchesForAutostart( |
| 30 std::map<std::string, base::CommandLine::StringType>* switch_list) { | 39 std::map<std::string, base::CommandLine::StringType>* switch_list) { |
| 31 for (size_t i = 0; i < arraysize(kSwitchesToRemoveOnAutorestart); ++i) | 40 for (size_t i = 0; i < arraysize(kSwitchesToRemoveOnAutorestart); ++i) |
| 32 switch_list->erase(kSwitchesToRemoveOnAutorestart[i]); | 41 switch_list->erase(kSwitchesToRemoveOnAutorestart[i]); |
| 42 | |
| 43 #if defined(OS_WIN) | |
| 44 // When Chrome is relaunched, the Windows prefetch profile to use can change | |
| 45 // (e.g. a process initially launched in background is relaunched in | |
| 46 // foreground). Therefore, always remove Windows prefetch switches from | |
| 47 // |switch_list| and let the code building the relaunch command line add a new | |
| 48 // one afterwards when appropriate. The format of a Windows prefetch switch is | |
| 49 // "/prefetch:#" where # is [1, 8]. | |
|
gab
2016/02/25 20:22:23
It's never appropriate to re-add one I think as we
fdoray
2016/02/26 18:10:36
Done. We do need to re-add a switch when a backgro
| |
| 50 static const char kPrefetchSwitchPrefix[] = "prefetch:"; | |
| 51 for (auto it = switch_list->lower_bound(kPrefetchSwitchPrefix); | |
| 52 it != switch_list->end();) { | |
| 53 if (base::StartsWith(it->first, kPrefetchSwitchPrefix, | |
| 54 base::CompareCase::SENSITIVE)) { | |
| 55 switch_list->erase(it++); | |
| 56 } else { | |
| 57 break; | |
| 58 } | |
| 59 } | |
|
gab
2016/02/25 20:22:23
This loop assumes there can be more than one prefe
fdoray
2016/02/26 18:10:36
Done.
| |
| 60 #endif // defined(OS_WIN) | |
| 33 } | 61 } |
| 34 | 62 |
| 35 } // namespace switches | 63 } // namespace switches |
| OLD | NEW |