Chromium Code Reviews| Index: chrome/installer/util/auto_launch_util.cc |
| =================================================================== |
| --- chrome/installer/util/auto_launch_util.cc (revision 0) |
| +++ chrome/installer/util/auto_launch_util.cc (revision 0) |
| @@ -0,0 +1,59 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/installer/util/auto_launch_util.h" |
| + |
| +#include "base/file_path.h" |
| +#include "base/logging.h" |
| +#include "base/path_service.h" |
| +#include "base/string16.h" |
| +#include "base/utf_string_conversions.h" |
| +#include "base/win/win_util.h" |
| +#include "chrome/common/chrome_switches.h" |
| +#include "chrome/installer/util/util_constants.h" |
| + |
| +namespace auto_launch_util { |
| + |
| +// The name of the Chrome Auto-launch key under the Run key. |
| +const wchar_t kAutolaunchKeyValue[] = L"GoogleChromeAutoLaunch"; |
| + |
| +bool WillLaunchAtLogin() { |
| + string16 autolaunch; |
| + if (!base::win::ReadCommandFromAutoRun( |
| + HKEY_CURRENT_USER, kAutolaunchKeyValue, &autolaunch)) { |
| + return false; |
| + } |
| + |
| + FilePath chrome_exe; |
| + if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
| + NOTREACHED(); |
| + return false; |
| + } |
| + |
| + return autolaunch.find(chrome_exe.value()) != string16::npos; |
| +} |
| + |
| +void SetWillLaunchAtLogin(bool auto_launch, FilePath application_path) { |
|
grt (UTC plus 2)
2011/12/03 04:43:38
const FilePath&
Finnur
2011/12/13 15:53:24
Done.
|
| + if (auto_launch) { |
| + if (application_path.empty()) { |
| + if (!PathService::Get(base::DIR_EXE, &application_path)) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + } |
| + string16 cmd_line = ASCIIToUTF16("\""); |
| + cmd_line += application_path.value(); |
| + cmd_line += ASCIIToUTF16("\\"); |
| + cmd_line += installer::kChromeExe; |
| + cmd_line += ASCIIToUTF16("\" --"); |
| + cmd_line += ASCIIToUTF16(switches::kAutoLaunchAtStartup); |
| + |
| + base::win::AddCommandToAutoRun( |
| + HKEY_CURRENT_USER, kAutolaunchKeyValue, cmd_line); |
| + } else { |
| + base::win::RemoveCommandFromAutoRun(HKEY_CURRENT_USER, kAutolaunchKeyValue); |
| + } |
| +} |
| + |
| +} // namespace auto_launch_util |
| Property changes on: chrome\installer\util\auto_launch_util.cc |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |