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 // The relaunched browser process shouldn't reuse the /prefetch:# switch of |
| 45 // the current process because the process type can change (e.g. a process |
| 46 // initially launched in background can be relaunched in foreground). |
| 47 static const char kPrefetchSwitchPrefix[] = "prefetch:"; |
| 48 auto it = switch_list->lower_bound(kPrefetchSwitchPrefix); |
| 49 if (it != switch_list->end() && |
| 50 base::StartsWith(it->first, kPrefetchSwitchPrefix, |
| 51 base::CompareCase::SENSITIVE)) { |
| 52 switch_list->erase(it); |
| 53 } |
| 54 #endif // defined(OS_WIN) |
33 } | 55 } |
34 | 56 |
35 } // namespace switches | 57 } // namespace switches |
OLD | NEW |