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/installer/util/auto_launch_util.h" | 5 #include "chrome/installer/util/auto_launch_util.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "base/win/win_util.h" | 19 #include "base/win/win_util.h" |
20 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
23 #include "chrome/installer/util/util_constants.h" | 23 #include "chrome/installer/util/util_constants.h" |
24 #include "components/startup_metric_utils/common/pre_read_field_trial_utils_win.
h" | |
25 #include "crypto/sha2.h" | 24 #include "crypto/sha2.h" |
26 | 25 |
27 namespace { | 26 namespace { |
28 | 27 |
29 // The prefix of the Chrome Auto-launch key under the Run key. | 28 // The prefix of the Chrome Auto-launch key under the Run key. |
30 const wchar_t kAutolaunchKeyValue[] = L"GoogleChromeAutoLaunch"; | 29 const wchar_t kAutolaunchKeyValue[] = L"GoogleChromeAutoLaunch"; |
31 | 30 |
32 // Builds a registry key name to use when deciding where to read/write the auto- | 31 // Builds a registry key name to use when deciding where to read/write the auto- |
33 // launch value to/from. It takes into account the path of the profile so that | 32 // launch value to/from. It takes into account the path of the profile so that |
34 // different installations of Chrome don't conflict. | 33 // different installations of Chrome don't conflict. |
(...skipping 17 matching lines...) Expand all Loading... |
52 | 51 |
53 namespace auto_launch_util { | 52 namespace auto_launch_util { |
54 | 53 |
55 void EnableBackgroundStartAtLogin() { | 54 void EnableBackgroundStartAtLogin() { |
56 base::FilePath application_dir; | 55 base::FilePath application_dir; |
57 if (!PathService::Get(base::DIR_EXE, &application_dir)) | 56 if (!PathService::Get(base::DIR_EXE, &application_dir)) |
58 NOTREACHED(); | 57 NOTREACHED(); |
59 | 58 |
60 base::CommandLine cmd_line(application_dir.Append(installer::kChromeExe)); | 59 base::CommandLine cmd_line(application_dir.Append(installer::kChromeExe)); |
61 cmd_line.AppendSwitch(switches::kNoStartupWindow); | 60 cmd_line.AppendSwitch(switches::kNoStartupWindow); |
62 | 61 cmd_line.AppendArg(switches::kPrefetchArgumentBrowserBackground); |
63 if (startup_metric_utils::GetPreReadOptions().use_prefetch_argument) | |
64 cmd_line.AppendArg(switches::kPrefetchArgumentBrowserBackground); | |
65 | 62 |
66 base::win::AddCommandToAutoRun(HKEY_CURRENT_USER, GetAutoLaunchKeyName(), | 63 base::win::AddCommandToAutoRun(HKEY_CURRENT_USER, GetAutoLaunchKeyName(), |
67 cmd_line.GetCommandLineString()); | 64 cmd_line.GetCommandLineString()); |
68 } | 65 } |
69 | 66 |
70 void DisableBackgroundStartAtLogin() { | 67 void DisableBackgroundStartAtLogin() { |
71 base::win::RemoveCommandFromAutoRun(HKEY_CURRENT_USER, | 68 base::win::RemoveCommandFromAutoRun(HKEY_CURRENT_USER, |
72 GetAutoLaunchKeyName()); | 69 GetAutoLaunchKeyName()); |
73 } | 70 } |
74 | 71 |
75 } // namespace auto_launch_util | 72 } // namespace auto_launch_util |
OLD | NEW |