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,47 @@ |
| +// 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/string16.h" |
| +#include "base/utf_string_conversions.h" |
| +#include "base/win/registry.h" |
| +#include "chrome/common/chrome_switches.h" |
| +#include "chrome/installer/util/util_constants.h" |
| + |
| +namespace auto_launch_util { |
| + |
| +static const wchar_t kRunKey[] = |
|
grt (UTC plus 2)
2011/11/29 18:55:45
can you use base::win::*AutoRun methods instead of
grt (UTC plus 2)
2011/11/29 18:55:45
prefer the unnamed namespace over "static". for e
|
| + L"Software\\Microsoft\\Windows\\CurrentVersion\\Run"; |
| + |
| +static const wchar_t kAutolaunchKeyValue[] = L"GoogleChromeAutoLaunch"; |
| + |
| +bool IsAutoLaunched() { |
| + base::win::RegKey key(HKEY_CURRENT_USER, kRunKey, KEY_QUERY_VALUE); |
| + |
| + string16 autolaunch; |
| + if (ERROR_SUCCESS != key.ReadValue(kAutolaunchKeyValue, &autolaunch)) |
| + return false; |
| + |
| + return autolaunch.find( |
| + ASCIIToUTF16(switches::kAutoLaunchAtStartup)) != string16::npos; |
| +} |
| + |
| +void SetIsAutoLaunched(bool auto_launch, const FilePath& application_path) { |
| + base::win::RegKey key(HKEY_CURRENT_USER, kRunKey, KEY_SET_VALUE); |
| + if (auto_launch) { |
| + string16 cmd_line = L"\""; |
| + cmd_line += application_path.value(); |
| + cmd_line += L"\\"; |
| + cmd_line += installer::kChromeExe; |
| + cmd_line += L"\" --"; |
| + cmd_line += ASCIIToUTF16(switches::kAutoLaunchAtStartup); |
| + key.WriteValue(kAutolaunchKeyValue, cmd_line.c_str()); |
| + } else { |
| + key.DeleteValue(kAutolaunchKeyValue); |
| + } |
| +} |
| + |
| +} // namespace |
|
grt (UTC plus 2)
2011/11/29 18:55:45
} // namespace auto_launch_util
|
| Property changes on: chrome\installer\util\auto_launch_util.cc |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |