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

Side by Side Diff: chrome/installer/launcher_support/chrome_launcher_support.cc

Issue 12294008: Fix more remaining FilePath -> base::FilePath. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months 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
OLDNEW
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 27 matching lines...) Expand all
38 const wchar_t kBrowserAppGuid[] = L"{8A69D345-D564-463c-AFF1-A69D9E530F96}"; 38 const wchar_t kBrowserAppGuid[] = L"{8A69D345-D564-463c-AFF1-A69D9E530F96}";
39 39
40 // Copied from util_constants.cc. 40 // Copied from util_constants.cc.
41 const wchar_t kChromeAppHostExe[] = L"app_host.exe"; 41 const wchar_t kChromeAppHostExe[] = L"app_host.exe";
42 const char kChromeAppLauncher[] = "app-launcher"; 42 const char kChromeAppLauncher[] = "app-launcher";
43 const wchar_t kChromeExe[] = L"chrome.exe"; 43 const wchar_t kChromeExe[] = L"chrome.exe";
44 const wchar_t kUninstallArgumentsField[] = L"UninstallArguments"; 44 const wchar_t kUninstallArgumentsField[] = L"UninstallArguments";
45 const wchar_t kUninstallStringField[] = L"UninstallString"; 45 const wchar_t kUninstallStringField[] = L"UninstallString";
46 46
47 #ifndef OFFICIAL_BUILD 47 #ifndef OFFICIAL_BUILD
48 FilePath GetDevelopmentExe(const wchar_t* exe_file) { 48 base::FilePath GetDevelopmentExe(const wchar_t* exe_file) {
49 base::FilePath current_directory; 49 base::FilePath current_directory;
50 if (PathService::Get(base::DIR_EXE, &current_directory)) { 50 if (PathService::Get(base::DIR_EXE, &current_directory)) {
51 base::FilePath chrome_exe_path(current_directory.Append(exe_file)); 51 base::FilePath chrome_exe_path(current_directory.Append(exe_file));
52 if (file_util::PathExists(chrome_exe_path)) 52 if (file_util::PathExists(chrome_exe_path))
53 return chrome_exe_path; 53 return chrome_exe_path;
54 } 54 }
55 return base::FilePath(); 55 return base::FilePath();
56 } 56 }
57 #endif 57 #endif
58 58
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 return CommandLine::FromString(L"dummy.exe " + uninstall_arguments) 100 return CommandLine::FromString(L"dummy.exe " + uninstall_arguments)
101 .HasSwitch(kChromeAppLauncher) && 101 .HasSwitch(kChromeAppLauncher) &&
102 !GetAppHostPathForInstallationLevel(level).empty(); 102 !GetAppHostPathForInstallationLevel(level).empty();
103 } 103 }
104 return false; 104 return false;
105 } 105 }
106 106
107 // Reads the path to setup.exe from the value "UninstallString" within the 107 // Reads the path to setup.exe from the value "UninstallString" within the
108 // specified product's "ClientState" registry key. Returns an empty FilePath if 108 // specified product's "ClientState" registry key. Returns an empty FilePath if
109 // an error occurs or the product is not installed at the specified level. 109 // an error occurs or the product is not installed at the specified level.
110 FilePath GetSetupExeFromRegistry(InstallationLevel level, 110 base::FilePath GetSetupExeFromRegistry(InstallationLevel level,
111 const wchar_t* app_guid) { 111 const wchar_t* app_guid) {
112 string16 uninstall; 112 string16 uninstall;
113 if (GetClientStateValue(level, app_guid, kUninstallStringField, &uninstall)) { 113 if (GetClientStateValue(level, app_guid, kUninstallStringField, &uninstall)) {
114 base::FilePath setup_exe_path(uninstall); 114 base::FilePath setup_exe_path(uninstall);
115 if (file_util::PathExists(setup_exe_path)) 115 if (file_util::PathExists(setup_exe_path))
116 return setup_exe_path; 116 return setup_exe_path;
117 } 117 }
118 return base::FilePath(); 118 return base::FilePath();
119 } 119 }
120 120
121 // Returns the path to an installed |exe_file| (e.g. chrome.exe, app_host.exe) 121 // Returns the path to an installed |exe_file| (e.g. chrome.exe, app_host.exe)
122 // at the specified level, given |setup_exe_path| from Omaha client state. 122 // at the specified level, given |setup_exe_path| from Omaha client state.
123 // Returns empty base::FilePath if none found, or if |setup_exe_path| is empty. 123 // Returns empty base::FilePath if none found, or if |setup_exe_path| is empty.
124 FilePath FindExeRelativeToSetupExe(const base::FilePath setup_exe_path, 124 base::FilePath FindExeRelativeToSetupExe(const base::FilePath setup_exe_path,
125 const wchar_t* exe_file) { 125 const wchar_t* exe_file) {
126 if (!setup_exe_path.empty()) { 126 if (!setup_exe_path.empty()) {
127 // The uninstall path contains the path to setup.exe, which is two levels 127 // The uninstall path contains the path to setup.exe, which is two levels
128 // down from |exe_file|. Move up two levels (plus one to drop the file 128 // down from |exe_file|. Move up two levels (plus one to drop the file
129 // name) and look for chrome.exe from there. 129 // name) and look for chrome.exe from there.
130 base::FilePath exe_path( 130 base::FilePath exe_path(
131 setup_exe_path.DirName().DirName().DirName().Append(exe_file)); 131 setup_exe_path.DirName().DirName().DirName().Append(exe_file));
132 if (file_util::PathExists(exe_path)) 132 if (file_util::PathExists(exe_path))
133 return exe_path; 133 return exe_path;
134 // By way of mild future proofing, look up one to see if there's a 134 // By way of mild future proofing, look up one to see if there's a
135 // |exe_file| in the version directory 135 // |exe_file| in the version directory
136 exe_path = setup_exe_path.DirName().DirName().Append(exe_file); 136 exe_path = setup_exe_path.DirName().DirName().Append(exe_file);
137 if (file_util::PathExists(exe_path)) 137 if (file_util::PathExists(exe_path))
138 return exe_path; 138 return exe_path;
139 } 139 }
140 return base::FilePath(); 140 return base::FilePath();
141 } 141 }
142 142
143 } // namespace 143 } // namespace
144 144
145 FilePath GetSetupExeForInstallationLevel(InstallationLevel level) { 145 base::FilePath GetSetupExeForInstallationLevel(InstallationLevel level) {
146 // Look in the registry for Chrome Binaries first. 146 // Look in the registry for Chrome Binaries first.
147 base::FilePath setup_exe_path( 147 base::FilePath setup_exe_path(
148 GetSetupExeFromRegistry(level, kBinariesAppGuid)); 148 GetSetupExeFromRegistry(level, kBinariesAppGuid));
149 // If the above fails, look in the registry for Chrome next. 149 // If the above fails, look in the registry for Chrome next.
150 if (setup_exe_path.empty()) 150 if (setup_exe_path.empty())
151 setup_exe_path = GetSetupExeFromRegistry(level, kBrowserAppGuid); 151 setup_exe_path = GetSetupExeFromRegistry(level, kBrowserAppGuid);
152 // If we fail again, then setup_exe_path would be empty. 152 // If we fail again, then setup_exe_path would be empty.
153 return setup_exe_path; 153 return setup_exe_path;
154 } 154 }
155 155
156 FilePath GetChromePathForInstallationLevel(InstallationLevel level) { 156 base::FilePath GetChromePathForInstallationLevel(InstallationLevel level) {
157 return FindExeRelativeToSetupExe( 157 return FindExeRelativeToSetupExe(
158 GetSetupExeForInstallationLevel(level), kChromeExe); 158 GetSetupExeForInstallationLevel(level), kChromeExe);
159 } 159 }
160 160
161 FilePath GetAppHostPathForInstallationLevel(InstallationLevel level) { 161 base::FilePath GetAppHostPathForInstallationLevel(InstallationLevel level) {
162 return FindExeRelativeToSetupExe( 162 return FindExeRelativeToSetupExe(
163 GetSetupExeFromRegistry(level, kAppHostAppId), kChromeAppHostExe); 163 GetSetupExeFromRegistry(level, kAppHostAppId), kChromeAppHostExe);
164 } 164 }
165 165
166 FilePath GetAnyChromePath() { 166 base::FilePath GetAnyChromePath() {
167 base::FilePath chrome_path; 167 base::FilePath chrome_path;
168 #ifndef OFFICIAL_BUILD 168 #ifndef OFFICIAL_BUILD
169 // For development mode, chrome.exe should be in same dir as the stub. 169 // For development mode, chrome.exe should be in same dir as the stub.
170 chrome_path = GetDevelopmentExe(kChromeExe); 170 chrome_path = GetDevelopmentExe(kChromeExe);
171 #endif 171 #endif
172 if (chrome_path.empty()) 172 if (chrome_path.empty())
173 chrome_path = GetChromePathForInstallationLevel(SYSTEM_LEVEL_INSTALLATION); 173 chrome_path = GetChromePathForInstallationLevel(SYSTEM_LEVEL_INSTALLATION);
174 if (chrome_path.empty()) 174 if (chrome_path.empty())
175 chrome_path = GetChromePathForInstallationLevel(USER_LEVEL_INSTALLATION); 175 chrome_path = GetChromePathForInstallationLevel(USER_LEVEL_INSTALLATION);
176 return chrome_path; 176 return chrome_path;
177 } 177 }
178 178
179 FilePath GetAnyAppHostPath() { 179 base::FilePath GetAnyAppHostPath() {
180 base::FilePath app_host_path; 180 base::FilePath app_host_path;
181 #ifndef OFFICIAL_BUILD 181 #ifndef OFFICIAL_BUILD
182 // For development mode, app_host.exe should be in same dir as chrome.exe. 182 // For development mode, app_host.exe should be in same dir as chrome.exe.
183 app_host_path = GetDevelopmentExe(kChromeAppHostExe); 183 app_host_path = GetDevelopmentExe(kChromeAppHostExe);
184 #endif 184 #endif
185 if (app_host_path.empty()) { 185 if (app_host_path.empty()) {
186 app_host_path = GetAppHostPathForInstallationLevel( 186 app_host_path = GetAppHostPathForInstallationLevel(
187 SYSTEM_LEVEL_INSTALLATION); 187 SYSTEM_LEVEL_INSTALLATION);
188 } 188 }
189 if (app_host_path.empty()) 189 if (app_host_path.empty())
(...skipping 10 matching lines...) Expand all
200 return IsAppLauncherEnabledAtLevel(USER_LEVEL_INSTALLATION) || 200 return IsAppLauncherEnabledAtLevel(USER_LEVEL_INSTALLATION) ||
201 IsAppLauncherEnabledAtLevel(SYSTEM_LEVEL_INSTALLATION); 201 IsAppLauncherEnabledAtLevel(SYSTEM_LEVEL_INSTALLATION);
202 } 202 }
203 203
204 bool IsChromeBrowserPresent() { 204 bool IsChromeBrowserPresent() {
205 return IsProductInstalled(USER_LEVEL_INSTALLATION, kBrowserAppGuid) || 205 return IsProductInstalled(USER_LEVEL_INSTALLATION, kBrowserAppGuid) ||
206 IsProductInstalled(SYSTEM_LEVEL_INSTALLATION, kBrowserAppGuid); 206 IsProductInstalled(SYSTEM_LEVEL_INSTALLATION, kBrowserAppGuid);
207 } 207 }
208 208
209 } // namespace chrome_launcher_support 209 } // namespace chrome_launcher_support
OLDNEW
« no previous file with comments | « chrome/browser/web_applications/web_app_mac.mm ('k') | chrome/installer/util/delete_after_reboot_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698