Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: chrome/installer/util/auto_launch_util.cc

Issue 8729009: Implement an AutoLaunch experiment for Chrome for certain brand codes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/installer/util/auto_launch_util.h ('k') | chrome/installer/util/install_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/installer/util/auto_launch_util.h"
6
7 #include "base/file_path.h"
8 #include "base/logging.h"
9 #include "base/path_service.h"
10 #include "base/string16.h"
11 #include "base/utf_string_conversions.h"
12 #include "base/win/win_util.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/installer/util/util_constants.h"
15
16 namespace auto_launch_util {
17
18 // The name of the Chrome Auto-launch key under the Run key.
19 const wchar_t kAutolaunchKeyValue[] = L"GoogleChromeAutoLaunch";
20
21 bool WillLaunchAtLogin(const FilePath& application_path) {
22 string16 autolaunch;
23 if (!base::win::ReadCommandFromAutoRun(
24 HKEY_CURRENT_USER, kAutolaunchKeyValue, &autolaunch)) {
25 return false;
26 }
27
28 FilePath chrome_exe(application_path);
29 if (chrome_exe.empty()) {
30 if (!PathService::Get(base::DIR_EXE, &chrome_exe)) {
31 NOTREACHED();
32 return false;
33 }
34 }
35 chrome_exe = chrome_exe.Append(installer::kChromeExe);
36
37 return autolaunch.find(chrome_exe.value()) != string16::npos;
38 }
39
40 void SetWillLaunchAtLogin(bool auto_launch, const FilePath& application_path) {
41 // TODO(finnur): Convert this into a shortcut, instead of using the Run key.
42 if (auto_launch) {
43 FilePath path(application_path);
44 if (path.empty()) {
45 if (!PathService::Get(base::DIR_EXE, &path)) {
46 NOTREACHED();
47 return;
48 }
49 }
50 string16 cmd_line = ASCIIToUTF16("\"");
51 cmd_line += path.value();
52 cmd_line += ASCIIToUTF16("\\");
53 cmd_line += installer::kChromeExe;
54 cmd_line += ASCIIToUTF16("\" --");
55 cmd_line += ASCIIToUTF16(switches::kAutoLaunchAtStartup);
56
57 base::win::AddCommandToAutoRun(
58 HKEY_CURRENT_USER, kAutolaunchKeyValue, cmd_line);
59 } else {
60 base::win::RemoveCommandFromAutoRun(HKEY_CURRENT_USER, kAutolaunchKeyValue);
61 }
62 }
63
64 } // namespace auto_launch_util
OLDNEW
« no previous file with comments | « chrome/installer/util/auto_launch_util.h ('k') | chrome/installer/util/install_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698