| 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" |
| 24 #include "crypto/sha2.h" | 25 #include "crypto/sha2.h" |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 // The prefix of the Chrome Auto-launch key under the Run key. | 29 // The prefix of the Chrome Auto-launch key under the Run key. |
| 29 const wchar_t kAutolaunchKeyValue[] = L"GoogleChromeAutoLaunch"; | 30 const wchar_t kAutolaunchKeyValue[] = L"GoogleChromeAutoLaunch"; |
| 30 | 31 |
| 31 // Builds a registry key name to use when deciding where to read/write the auto- | 32 // Builds a registry key name to use when deciding where to read/write the auto- |
| 32 // launch value to/from. It takes into account the path of the profile so that | 33 // launch value to/from. It takes into account the path of the profile so that |
| 33 // different installations of Chrome don't conflict. | 34 // different installations of Chrome don't conflict. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 52 namespace auto_launch_util { | 53 namespace auto_launch_util { |
| 53 | 54 |
| 54 void EnableBackgroundStartAtLogin() { | 55 void EnableBackgroundStartAtLogin() { |
| 55 base::FilePath application_dir; | 56 base::FilePath application_dir; |
| 56 if (!PathService::Get(base::DIR_EXE, &application_dir)) | 57 if (!PathService::Get(base::DIR_EXE, &application_dir)) |
| 57 NOTREACHED(); | 58 NOTREACHED(); |
| 58 | 59 |
| 59 base::CommandLine cmd_line(application_dir.Append(installer::kChromeExe)); | 60 base::CommandLine cmd_line(application_dir.Append(installer::kChromeExe)); |
| 60 cmd_line.AppendSwitch(switches::kNoStartupWindow); | 61 cmd_line.AppendSwitch(switches::kNoStartupWindow); |
| 61 | 62 |
| 63 if (startup_metric_utils::GetPreReadOptions().prefetch_argument) |
| 64 cmd_line.AppendArg(switches::kPrefetchArgumentBrowserBackground); |
| 65 |
| 62 base::win::AddCommandToAutoRun(HKEY_CURRENT_USER, GetAutoLaunchKeyName(), | 66 base::win::AddCommandToAutoRun(HKEY_CURRENT_USER, GetAutoLaunchKeyName(), |
| 63 cmd_line.GetCommandLineString()); | 67 cmd_line.GetCommandLineString()); |
| 64 } | 68 } |
| 65 | 69 |
| 66 void DisableBackgroundStartAtLogin() { | 70 void DisableBackgroundStartAtLogin() { |
| 67 base::win::RemoveCommandFromAutoRun(HKEY_CURRENT_USER, | 71 base::win::RemoveCommandFromAutoRun(HKEY_CURRENT_USER, |
| 68 GetAutoLaunchKeyName()); | 72 GetAutoLaunchKeyName()); |
| 69 } | 73 } |
| 70 | 74 |
| 71 } // namespace auto_launch_util | 75 } // namespace auto_launch_util |
| OLD | NEW |