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

Side by Side Diff: chrome/installer/setup/install.cc

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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/setup/install.h" 5 #include "chrome/installer/setup/install.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shlobj.h> 8 #include <shlobj.h>
9 #include <time.h> 9 #include <time.h>
10 10
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 install_list.get()); 194 install_list.get());
195 195
196 base::FilePath new_chrome_exe( 196 base::FilePath new_chrome_exe(
197 installer_state.target_path().Append(installer::kChromeNewExe)); 197 installer_state.target_path().Append(installer::kChromeNewExe));
198 198
199 installer_state.UpdateStage(installer::EXECUTING); 199 installer_state.UpdateStage(installer::EXECUTING);
200 200
201 if (!install_list->Do()) { 201 if (!install_list->Do()) {
202 installer_state.UpdateStage(installer::ROLLINGBACK); 202 installer_state.UpdateStage(installer::ROLLINGBACK);
203 installer::InstallStatus result = 203 installer::InstallStatus result =
204 file_util::PathExists(new_chrome_exe) && current_version->get() && 204 base::PathExists(new_chrome_exe) && current_version->get() &&
205 new_version.Equals(*current_version->get()) ? 205 new_version.Equals(*current_version->get()) ?
206 installer::SAME_VERSION_REPAIR_FAILED : 206 installer::SAME_VERSION_REPAIR_FAILED :
207 installer::INSTALL_FAILED; 207 installer::INSTALL_FAILED;
208 LOG(ERROR) << "Install failed, rolling back... result: " << result; 208 LOG(ERROR) << "Install failed, rolling back... result: " << result;
209 install_list->Rollback(); 209 install_list->Rollback();
210 LOG(ERROR) << "Rollback complete. "; 210 LOG(ERROR) << "Rollback complete. ";
211 return result; 211 return result;
212 } 212 }
213 213
214 installer_state.UpdateStage(installer::REFRESHING_POLICY); 214 installer_state.UpdateStage(installer::REFRESHING_POLICY);
215 215
216 installer::RefreshElevationPolicy(); 216 installer::RefreshElevationPolicy();
217 217
218 if (!current_version->get()) { 218 if (!current_version->get()) {
219 VLOG(1) << "First install of version " << new_version.GetString(); 219 VLOG(1) << "First install of version " << new_version.GetString();
220 return installer::FIRST_INSTALL_SUCCESS; 220 return installer::FIRST_INSTALL_SUCCESS;
221 } 221 }
222 222
223 if (new_version.Equals(**current_version)) { 223 if (new_version.Equals(**current_version)) {
224 VLOG(1) << "Install repaired of version " << new_version.GetString(); 224 VLOG(1) << "Install repaired of version " << new_version.GetString();
225 return installer::INSTALL_REPAIRED; 225 return installer::INSTALL_REPAIRED;
226 } 226 }
227 227
228 if (new_version.CompareTo(**current_version) > 0) { 228 if (new_version.CompareTo(**current_version) > 0) {
229 if (file_util::PathExists(new_chrome_exe)) { 229 if (base::PathExists(new_chrome_exe)) {
230 VLOG(1) << "Version updated to " << new_version.GetString() 230 VLOG(1) << "Version updated to " << new_version.GetString()
231 << " while running " << (*current_version)->GetString(); 231 << " while running " << (*current_version)->GetString();
232 return installer::IN_USE_UPDATED; 232 return installer::IN_USE_UPDATED;
233 } 233 }
234 VLOG(1) << "Version updated to " << new_version.GetString(); 234 VLOG(1) << "Version updated to " << new_version.GetString();
235 return installer::NEW_VERSION_UPDATED; 235 return installer::NEW_VERSION_UPDATED;
236 } 236 }
237 237
238 LOG(ERROR) << "Not sure how we got here while updating" 238 LOG(ERROR) << "Not sure how we got here while updating"
239 << ", new version: " << new_version.GetString() 239 << ", new version: " << new_version.GetString()
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 bool CreateVisualElementsManifest(const base::FilePath& src_path, 296 bool CreateVisualElementsManifest(const base::FilePath& src_path,
297 const Version& version) { 297 const Version& version) {
298 // Construct the relative path to the versioned VisualElements directory. 298 // Construct the relative path to the versioned VisualElements directory.
299 string16 elements_dir(ASCIIToUTF16(version.GetString())); 299 string16 elements_dir(ASCIIToUTF16(version.GetString()));
300 elements_dir.push_back(base::FilePath::kSeparators[0]); 300 elements_dir.push_back(base::FilePath::kSeparators[0]);
301 elements_dir.append(installer::kVisualElements); 301 elements_dir.append(installer::kVisualElements);
302 302
303 // Some distributions of Chromium may not include visual elements. Only 303 // Some distributions of Chromium may not include visual elements. Only
304 // proceed if this distribution does. 304 // proceed if this distribution does.
305 if (!file_util::PathExists(src_path.Append(elements_dir))) { 305 if (!base::PathExists(src_path.Append(elements_dir))) {
306 VLOG(1) << "No visual elements found, not writing " 306 VLOG(1) << "No visual elements found, not writing "
307 << installer::kVisualElementsManifest << " to " << src_path.value(); 307 << installer::kVisualElementsManifest << " to " << src_path.value();
308 return true; 308 return true;
309 } else { 309 } else {
310 // A printf_p-style format string for generating the visual elements 310 // A printf_p-style format string for generating the visual elements
311 // manifest. Required arguments, in order, are: 311 // manifest. Required arguments, in order, are:
312 // - Localized display name for the product. 312 // - Localized display name for the product.
313 // - Relative path to the VisualElements directory. 313 // - Relative path to the VisualElements directory.
314 static const char kManifestTemplate[] = 314 static const char kManifestTemplate[] =
315 "<Application>\r\n" 315 "<Application>\r\n"
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 // present for this user (as some shortcuts used to be installed on first 666 // present for this user (as some shortcuts used to be installed on first
667 // run and this could otherwise re-install shortcuts for users that have 667 // run and this could otherwise re-install shortcuts for users that have
668 // already deleted them in the past). 668 // already deleted them in the past).
669 base::FilePath first_run_sentinel; 669 base::FilePath first_run_sentinel;
670 InstallUtil::GetSentinelFilePath( 670 InstallUtil::GetSentinelFilePath(
671 chrome::kFirstRunSentinel, chrome.distribution(), &first_run_sentinel); 671 chrome::kFirstRunSentinel, chrome.distribution(), &first_run_sentinel);
672 // Decide whether to create the shortcuts or simply replace existing 672 // Decide whether to create the shortcuts or simply replace existing
673 // shortcuts; if the decision is to create them, only shortcuts whose matching 673 // shortcuts; if the decision is to create them, only shortcuts whose matching
674 // all-users shortcut isn't present on the system will be created. 674 // all-users shortcut isn't present on the system will be created.
675 InstallShortcutOperation install_operation = 675 InstallShortcutOperation install_operation =
676 (!force && file_util::PathExists(first_run_sentinel) ? 676 (!force && base::PathExists(first_run_sentinel) ?
677 INSTALL_SHORTCUT_REPLACE_EXISTING : 677 INSTALL_SHORTCUT_REPLACE_EXISTING :
678 INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL); 678 INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL);
679 679
680 // Read master_preferences copied beside chrome.exe at install. 680 // Read master_preferences copied beside chrome.exe at install.
681 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); 681 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs));
682 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); 682 base::FilePath chrome_exe(installation_root.Append(kChromeExe));
683 CreateOrUpdateShortcuts( 683 CreateOrUpdateShortcuts(
684 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); 684 chrome_exe, chrome, prefs, CURRENT_USER, install_operation);
685 } 685 }
686 686
687 bool InstallFromWebstore(const std::string& app_code) { 687 bool InstallFromWebstore(const std::string& app_code) {
688 base::FilePath app_host_path(chrome_launcher_support::GetAnyAppHostPath()); 688 base::FilePath app_host_path(chrome_launcher_support::GetAnyAppHostPath());
689 if (app_host_path.empty()) 689 if (app_host_path.empty())
690 return false; 690 return false;
691 691
692 CommandLine cmd(app_host_path); 692 CommandLine cmd(app_host_path);
693 cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code); 693 cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code);
694 VLOG(1) << "App install command: " << cmd.GetCommandLineString(); 694 VLOG(1) << "App install command: " << cmd.GetCommandLineString();
695 return base::LaunchProcess(cmd, base::LaunchOptions(), NULL); 695 return base::LaunchProcess(cmd, base::LaunchOptions(), NULL);
696 } 696 }
697 697
698 } // namespace installer 698 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/launcher_support/chrome_launcher_support.cc ('k') | chrome/installer/setup/install_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698