OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/helper.h" | 5 #include "chrome/installer/util/helper.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 | 34 |
35 return install_path; | 35 return install_path; |
36 } | 36 } |
37 | 37 |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 namespace installer { | 40 namespace installer { |
41 | 41 |
42 bool IsInstalledAsMulti(bool system_install, BrowserDistribution* dist) { | 42 bool IsInstalledAsMulti(bool system_install, BrowserDistribution* dist) { |
43 bool installed_as_multi = false; | 43 bool installed_as_multi = false; |
44 HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 44 CommandLine cmd(CommandLine::NO_PROGRAM); |
45 RegKey key(root, dist->GetStateKey().c_str(), KEY_READ); | 45 if (GetUninstallSwitches(system_install, dist, &cmd)) |
46 if (key.Valid()) { | 46 installed_as_multi = cmd.HasSwitch(installer::switches::kMultiInstall); |
47 std::wstring args; | |
48 key.ReadValue(installer::kUninstallArgumentsField, &args); | |
49 if (!args.empty()) { | |
50 args.insert(0, L"fake.exe "); | |
51 CommandLine cmd(CommandLine::FromString(args)); | |
52 installed_as_multi = cmd.HasSwitch(installer::switches::kMultiInstall); | |
53 } | |
54 } | |
55 return installed_as_multi; | 47 return installed_as_multi; |
56 } | 48 } |
57 | 49 |
50 bool GetUninstallSwitches(bool system_install, BrowserDistribution* dist, | |
51 CommandLine* cmd_line_switches) { | |
52 scoped_ptr<Version> installed(InstallUtil::GetChromeVersion(dist, | |
53 system_install)); | |
54 if (installed.get()) { | |
55 HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | |
56 RegKey key(root, dist->GetStateKey().c_str(), KEY_READ); | |
57 if (key.Valid()) { | |
58 std::wstring args; | |
59 key.ReadValue(installer::kUninstallArgumentsField, &args); | |
60 if (!args.empty()) { | |
61 args.insert(0, L"foo.exe "); | |
62 *cmd_line_switches = CommandLine::FromString(args); | |
63 } else { | |
64 LOG(ERROR) << "No uninstallation arguments for " | |
grt (UTC plus 2)
2010/12/29 16:51:50
Are these two ERROR conditions bad enough that we
tommi (sloooow) - chröme
2010/12/29 17:30:09
I was thinking the same but in the end opted on th
| |
65 << dist->GetApplicationName(); | |
66 installed.reset(); | |
67 } | |
68 } else { | |
69 LOG(ERROR) << "Product looks to be installed but we can't access the " | |
70 "state key: " << dist->GetApplicationName(); | |
71 installed.reset(); | |
72 } | |
73 } | |
74 | |
75 return installed.get() != NULL; | |
76 } | |
77 | |
58 FilePath GetChromeInstallPath(bool system_install, BrowserDistribution* dist) { | 78 FilePath GetChromeInstallPath(bool system_install, BrowserDistribution* dist) { |
59 return GetChromeInstallBasePath(system_install, dist, | 79 return GetChromeInstallBasePath(system_install, dist, |
60 installer::kInstallBinaryDir); | 80 installer::kInstallBinaryDir); |
61 } | 81 } |
62 | 82 |
63 FilePath GetChromeUserDataPath(BrowserDistribution* dist) { | 83 FilePath GetChromeUserDataPath(BrowserDistribution* dist) { |
64 return GetChromeInstallBasePath(false, dist, kInstallUserDataDir); | 84 return GetChromeInstallBasePath(false, dist, kInstallUserDataDir); |
65 } | 85 } |
66 | 86 |
67 FilePath GetChromeFrameInstallPath(bool multi_install, bool system_install, | 87 FilePath GetChromeFrameInstallPath(bool multi_install, bool system_install, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 // Return Chrome's installation folder. | 120 // Return Chrome's installation folder. |
101 VLOG(1) << "Chrome Frame will be installed as 'multi'"; | 121 VLOG(1) << "Chrome Frame will be installed as 'multi'"; |
102 const MasterPreferences& prefs = MasterPreferences::ForCurrentProcess(); | 122 const MasterPreferences& prefs = MasterPreferences::ForCurrentProcess(); |
103 BrowserDistribution* chrome = | 123 BrowserDistribution* chrome = |
104 BrowserDistribution::GetSpecificDistribution( | 124 BrowserDistribution::GetSpecificDistribution( |
105 BrowserDistribution::CHROME_BROWSER, prefs); | 125 BrowserDistribution::CHROME_BROWSER, prefs); |
106 return GetChromeInstallPath(system_install, chrome); | 126 return GetChromeInstallPath(system_install, chrome); |
107 } | 127 } |
108 | 128 |
109 } // namespace installer. | 129 } // namespace installer. |
OLD | NEW |