OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/launcher_support/chrome_launcher_support.h" | 5 #include "chrome/installer/launcher_support/chrome_launcher_support.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <tchar.h> | 8 #include <tchar.h> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 const char kChromeAppLauncher[] = "app-launcher"; | 43 const char kChromeAppLauncher[] = "app-launcher"; |
44 const wchar_t kChromeExe[] = L"chrome.exe"; | 44 const wchar_t kChromeExe[] = L"chrome.exe"; |
45 const wchar_t kUninstallArgumentsField[] = L"UninstallArguments"; | 45 const wchar_t kUninstallArgumentsField[] = L"UninstallArguments"; |
46 const wchar_t kUninstallStringField[] = L"UninstallString"; | 46 const wchar_t kUninstallStringField[] = L"UninstallString"; |
47 | 47 |
48 #ifndef OFFICIAL_BUILD | 48 #ifndef OFFICIAL_BUILD |
49 base::FilePath GetDevelopmentExe(const wchar_t* exe_file) { | 49 base::FilePath GetDevelopmentExe(const wchar_t* exe_file) { |
50 base::FilePath current_directory; | 50 base::FilePath current_directory; |
51 if (PathService::Get(base::DIR_EXE, ¤t_directory)) { | 51 if (PathService::Get(base::DIR_EXE, ¤t_directory)) { |
52 base::FilePath chrome_exe_path(current_directory.Append(exe_file)); | 52 base::FilePath chrome_exe_path(current_directory.Append(exe_file)); |
53 if (file_util::PathExists(chrome_exe_path)) | 53 if (base::PathExists(chrome_exe_path)) |
54 return chrome_exe_path; | 54 return chrome_exe_path; |
55 } | 55 } |
56 return base::FilePath(); | 56 return base::FilePath(); |
57 } | 57 } |
58 #endif | 58 #endif |
59 | 59 |
60 // Reads a string value from the specified product's "ClientState" registry key. | 60 // Reads a string value from the specified product's "ClientState" registry key. |
61 // Returns true iff the value is present and successfully read. | 61 // Returns true iff the value is present and successfully read. |
62 bool GetClientStateValue(InstallationLevel level, | 62 bool GetClientStateValue(InstallationLevel level, |
63 const wchar_t* app_guid, | 63 const wchar_t* app_guid, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 106 } |
107 | 107 |
108 // Reads the path to setup.exe from the value "UninstallString" within the | 108 // Reads the path to setup.exe from the value "UninstallString" within the |
109 // specified product's "ClientState" registry key. Returns an empty FilePath if | 109 // specified product's "ClientState" registry key. Returns an empty FilePath if |
110 // an error occurs or the product is not installed at the specified level. | 110 // an error occurs or the product is not installed at the specified level. |
111 base::FilePath GetSetupExeFromRegistry(InstallationLevel level, | 111 base::FilePath GetSetupExeFromRegistry(InstallationLevel level, |
112 const wchar_t* app_guid) { | 112 const wchar_t* app_guid) { |
113 string16 uninstall; | 113 string16 uninstall; |
114 if (GetClientStateValue(level, app_guid, kUninstallStringField, &uninstall)) { | 114 if (GetClientStateValue(level, app_guid, kUninstallStringField, &uninstall)) { |
115 base::FilePath setup_exe_path(uninstall); | 115 base::FilePath setup_exe_path(uninstall); |
116 if (file_util::PathExists(setup_exe_path)) | 116 if (base::PathExists(setup_exe_path)) |
117 return setup_exe_path; | 117 return setup_exe_path; |
118 } | 118 } |
119 return base::FilePath(); | 119 return base::FilePath(); |
120 } | 120 } |
121 | 121 |
122 // Returns the path to an installed |exe_file| (e.g. chrome.exe, app_host.exe) | 122 // Returns the path to an installed |exe_file| (e.g. chrome.exe, app_host.exe) |
123 // at the specified level, given |setup_exe_path| from Omaha client state. | 123 // at the specified level, given |setup_exe_path| from Omaha client state. |
124 // Returns empty base::FilePath if none found, or if |setup_exe_path| is empty. | 124 // Returns empty base::FilePath if none found, or if |setup_exe_path| is empty. |
125 base::FilePath FindExeRelativeToSetupExe(const base::FilePath setup_exe_path, | 125 base::FilePath FindExeRelativeToSetupExe(const base::FilePath setup_exe_path, |
126 const wchar_t* exe_file) { | 126 const wchar_t* exe_file) { |
127 if (!setup_exe_path.empty()) { | 127 if (!setup_exe_path.empty()) { |
128 // The uninstall path contains the path to setup.exe, which is two levels | 128 // The uninstall path contains the path to setup.exe, which is two levels |
129 // down from |exe_file|. Move up two levels (plus one to drop the file | 129 // down from |exe_file|. Move up two levels (plus one to drop the file |
130 // name) and look for chrome.exe from there. | 130 // name) and look for chrome.exe from there. |
131 base::FilePath exe_path( | 131 base::FilePath exe_path( |
132 setup_exe_path.DirName().DirName().DirName().Append(exe_file)); | 132 setup_exe_path.DirName().DirName().DirName().Append(exe_file)); |
133 if (file_util::PathExists(exe_path)) | 133 if (base::PathExists(exe_path)) |
134 return exe_path; | 134 return exe_path; |
135 // By way of mild future proofing, look up one to see if there's a | 135 // By way of mild future proofing, look up one to see if there's a |
136 // |exe_file| in the version directory | 136 // |exe_file| in the version directory |
137 exe_path = setup_exe_path.DirName().DirName().Append(exe_file); | 137 exe_path = setup_exe_path.DirName().DirName().Append(exe_file); |
138 if (file_util::PathExists(exe_path)) | 138 if (base::PathExists(exe_path)) |
139 return exe_path; | 139 return exe_path; |
140 } | 140 } |
141 return base::FilePath(); | 141 return base::FilePath(); |
142 } | 142 } |
143 | 143 |
144 } // namespace | 144 } // namespace |
145 | 145 |
146 void UninstallLegacyAppLauncher(InstallationLevel level) { | 146 void UninstallLegacyAppLauncher(InstallationLevel level) { |
147 base::FilePath setup_exe(GetSetupExeFromRegistry(level, kAppHostAppId)); | 147 base::FilePath setup_exe(GetSetupExeFromRegistry(level, kAppHostAppId)); |
148 if (setup_exe.empty()) | 148 if (setup_exe.empty()) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 bool IsAppLauncherPresent() { | 228 bool IsAppLauncherPresent() { |
229 return GetAppLauncherInstallationState() != NOT_INSTALLED; | 229 return GetAppLauncherInstallationState() != NOT_INSTALLED; |
230 } | 230 } |
231 | 231 |
232 bool IsChromeBrowserPresent() { | 232 bool IsChromeBrowserPresent() { |
233 return IsProductInstalled(USER_LEVEL_INSTALLATION, kBrowserAppGuid) || | 233 return IsProductInstalled(USER_LEVEL_INSTALLATION, kBrowserAppGuid) || |
234 IsProductInstalled(SYSTEM_LEVEL_INSTALLATION, kBrowserAppGuid); | 234 IsProductInstalled(SYSTEM_LEVEL_INSTALLATION, kBrowserAppGuid); |
235 } | 235 } |
236 | 236 |
237 } // namespace chrome_launcher_support | 237 } // namespace chrome_launcher_support |
OLD | NEW |