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

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
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& executable) {
22 string16 autolaunch;
23 if (!base::win::ReadCommandFromAutoRun(
24 HKEY_CURRENT_USER, kAutolaunchKeyValue, &autolaunch)) {
25 return false;
26 }
27
28 FilePath chrome_exe = executable;
grt (UTC plus 2) 2011/12/13 17:08:55 i think this style is preferred: FilePath chrome_e
29 if (chrome_exe.empty()) {
30 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
31 NOTREACHED();
32 return false;
33 }
34 }
35
36 return autolaunch.find(chrome_exe.value()) != string16::npos;
37 }
38
39 void SetWillLaunchAtLogin(bool auto_launch, const FilePath& application_path) {
40 // TODO(finnur): Convert this into a shortcut, instead of using the Run key.
41 if (auto_launch) {
42 FilePath path = application_path;
grt (UTC plus 2) 2011/12/13 17:08:55 same comment as above
43 if (path.empty()) {
44 if (!PathService::Get(base::DIR_EXE, &path)) {
45 NOTREACHED();
46 return;
47 }
48 }
49 string16 cmd_line = ASCIIToUTF16("\"");
50 cmd_line += path.value();
51 cmd_line += ASCIIToUTF16("\\");
52 cmd_line += installer::kChromeExe;
53 cmd_line += ASCIIToUTF16("\" --");
54 cmd_line += ASCIIToUTF16(switches::kAutoLaunchAtStartup);
55
56 base::win::AddCommandToAutoRun(
57 HKEY_CURRENT_USER, kAutolaunchKeyValue, cmd_line);
58 } else {
59 base::win::RemoveCommandFromAutoRun(HKEY_CURRENT_USER, kAutolaunchKeyValue);
60 }
61 }
62
63 } // namespace auto_launch_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698