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

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

Issue 4928002: Changing the installer switches from wchar_t[] to char[].... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
« no previous file with comments | « chrome/browser/browser_main_win.cc ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/setup/install.h" 5 #include "chrome/installer/setup/install.h"
6 6
7 #include <shlobj.h> 7 #include <shlobj.h>
8 #include <time.h> 8 #include <time.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 install_list->AddCopyTreeWorkItem(exe_path, exe_dst, temp_path, 75 install_list->AddCopyTreeWorkItem(exe_path, exe_dst, temp_path,
76 WorkItem::ALWAYS); 76 WorkItem::ALWAYS);
77 if (system_level) { 77 if (system_level) {
78 install_list->AddCopyTreeWorkItem(archive_path, archive_dst, temp_path, 78 install_list->AddCopyTreeWorkItem(archive_path, archive_dst, temp_path,
79 WorkItem::ALWAYS); 79 WorkItem::ALWAYS);
80 } else { 80 } else {
81 install_list->AddMoveTreeWorkItem(archive_path, archive_dst, temp_path); 81 install_list->AddMoveTreeWorkItem(archive_path, archive_dst, temp_path);
82 } 82 }
83 } 83 }
84 84
85 // A little helper function to save on tons of WideToASCII call sites.
86 void AppendWideSwitch(CommandLine* cmd, const wchar_t* switch_name) {
87 cmd->AppendSwitch(WideToASCII(switch_name));
88 }
89
90 void AppendUninstallCommandLineFlags(CommandLine* uninstall_cmd, 85 void AppendUninstallCommandLineFlags(CommandLine* uninstall_cmd,
91 bool is_system) { 86 bool is_system) {
92 DCHECK(uninstall_cmd); 87 DCHECK(uninstall_cmd);
93 AppendWideSwitch(uninstall_cmd, installer_util::switches::kUninstall); 88 uninstall_cmd->AppendSwitch(installer_util::switches::kUninstall);
94 89
95 // TODO(tommi): In case of multiple installations, we need to create multiple 90 // TODO(tommi): In case of multiple installations, we need to create multiple
96 // uninstall entries, and not one magic one for all. 91 // uninstall entries, and not one magic one for all.
97 const installer_util::MasterPreferences& prefs = 92 const installer_util::MasterPreferences& prefs =
98 InstallUtil::GetMasterPreferencesForCurrentProcess(); 93 InstallUtil::GetMasterPreferencesForCurrentProcess();
99 DCHECK(!prefs.is_multi_install()); 94 DCHECK(!prefs.is_multi_install());
100 95
101 if (prefs.install_chrome_frame()) { 96 if (prefs.install_chrome_frame()) {
102 AppendWideSwitch(uninstall_cmd, installer_util::switches::kDeleteProfile); 97 uninstall_cmd->AppendSwitch(installer_util::switches::kDeleteProfile);
103 AppendWideSwitch(uninstall_cmd, installer_util::switches::kChromeFrame); 98 uninstall_cmd->AppendSwitch(installer_util::switches::kChromeFrame);
104 } 99 }
105 100
106 if (InstallUtil::IsChromeSxSProcess()) { 101 if (InstallUtil::IsChromeSxSProcess()) {
107 AppendWideSwitch(uninstall_cmd, installer_util::switches::kChromeSxS); 102 uninstall_cmd->AppendSwitch(installer_util::switches::kChromeSxS);
108 } 103 }
109 104
110 if (InstallUtil::IsMSIProcess(is_system)) { 105 if (InstallUtil::IsMSIProcess(is_system)) {
111 AppendWideSwitch(uninstall_cmd, installer_util::switches::kMsi); 106 uninstall_cmd->AppendSwitch(installer_util::switches::kMsi);
112 } 107 }
113 108
114 // Propagate the verbose logging switch to uninstalls too. 109 // Propagate the verbose logging switch to uninstalls too.
115 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 110 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
116 if (command_line.HasSwitch(installer_util::switches::kVerboseLogging)) { 111 if (command_line.HasSwitch(installer_util::switches::kVerboseLogging)) {
117 AppendWideSwitch(uninstall_cmd, installer_util::switches::kVerboseLogging); 112 uninstall_cmd->AppendSwitch(installer_util::switches::kVerboseLogging);
118 } 113 }
119 114
120 if (is_system) { 115 if (is_system) {
121 AppendWideSwitch(uninstall_cmd, installer_util::switches::kSystemLevel); 116 uninstall_cmd->AppendSwitch(installer_util::switches::kSystemLevel);
122 } 117 }
123 } 118 }
124 119
125 // This method adds work items to create (or update) Chrome uninstall entry in 120 // This method adds work items to create (or update) Chrome uninstall entry in
126 // either the Control Panel->Add/Remove Programs list or in the Omaha client 121 // either the Control Panel->Add/Remove Programs list or in the Omaha client
127 // state key if running under an MSI installer. 122 // state key if running under an MSI installer.
128 void AddUninstallShortcutWorkItems(HKEY reg_root, 123 void AddUninstallShortcutWorkItems(HKEY reg_root,
129 const std::wstring& exe_path, 124 const std::wstring& exe_path,
130 const std::wstring& install_path, 125 const std::wstring& install_path,
131 const std::wstring& product_name, 126 const std::wstring& product_name,
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 if (current_version.empty()) { 408 if (current_version.empty()) {
414 LOG(ERROR) << "New chrome.exe exists but current version is empty!"; 409 LOG(ERROR) << "New chrome.exe exists but current version is empty!";
415 return false; 410 return false;
416 } 411 }
417 scoped_ptr<WorkItemList> inuse_list(WorkItem::CreateWorkItemList()); 412 scoped_ptr<WorkItemList> inuse_list(WorkItem::CreateWorkItemList());
418 inuse_list->AddSetRegValueWorkItem(reg_root, 413 inuse_list->AddSetRegValueWorkItem(reg_root,
419 version_key, 414 version_key,
420 google_update::kRegOldVersionField, 415 google_update::kRegOldVersionField,
421 current_version.c_str(), 416 current_version.c_str(),
422 true); 417 true);
418 FilePath installer_path(installer::GetInstallerPathUnderChrome(install_path,
419 new_version.GetString()));
420 installer_path = installer_path.Append(
421 file_util::GetFilenameFromPath(exe_path));
423 422
424 std::wstring rename_cmd(installer::GetInstallerPathUnderChrome( 423 CommandLine rename_cmd(installer_path);
425 install_path, new_version.GetString())); 424 rename_cmd.AppendSwitch(installer_util::switches::kRenameChromeExe);
426 file_util::AppendToPath(&rename_cmd,
427 file_util::GetFilenameFromPath(exe_path));
428 rename_cmd = L"\"" + rename_cmd +
429 L"\" --" + installer_util::switches::kRenameChromeExe;
430 if (is_system_install) 425 if (is_system_install)
431 rename_cmd = rename_cmd + L" --" + installer_util::switches::kSystemLevel; 426 rename_cmd.AppendSwitch(installer_util::switches::kSystemLevel);
432 427
433 if (prefs.install_chrome_frame()) { 428 if (prefs.install_chrome_frame())
434 rename_cmd += L" --"; 429 rename_cmd.AppendSwitch(installer_util::switches::kChromeFrame);
435 rename_cmd += installer_util::switches::kChromeFrame;
436 }
437 430
438 if (InstallUtil::IsChromeSxSProcess()) { 431 if (InstallUtil::IsChromeSxSProcess())
439 rename_cmd += L" --"; 432 rename_cmd.AppendSwitch(installer_util::switches::kChromeSxS);
440 rename_cmd += installer_util::switches::kChromeSxS;
441 }
442 433
443 inuse_list->AddSetRegValueWorkItem(reg_root, 434 inuse_list->AddSetRegValueWorkItem(reg_root,
444 version_key, 435 version_key,
445 google_update::kRegRenameCmdField, 436 google_update::kRegRenameCmdField,
446 rename_cmd.c_str(), 437 rename_cmd.command_line_string(),
447 true); 438 true);
448 if (!inuse_list->Do()) { 439 if (!inuse_list->Do()) {
449 LOG(ERROR) << "Couldn't write opv/cmd values to registry."; 440 LOG(ERROR) << "Couldn't write opv/cmd values to registry.";
450 inuse_list->Rollback(); 441 inuse_list->Rollback();
451 return false; 442 return false;
452 } 443 }
453 } else { 444 } else {
454 // Since this was not in-use-update, delete 'opv' and 'cmd' keys. 445 // Since this was not in-use-update, delete 'opv' and 'cmd' keys.
455 scoped_ptr<WorkItemList> inuse_list(WorkItem::CreateWorkItemList()); 446 scoped_ptr<WorkItemList> inuse_list(WorkItem::CreateWorkItemList());
456 inuse_list->AddDeleteRegValueWorkItem(reg_root, version_key, 447 inuse_list->AddDeleteRegValueWorkItem(reg_root, version_key,
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 } 802 }
812 803
813 std::wstring latest_version_to_keep(new_version.GetString()); 804 std::wstring latest_version_to_keep(new_version.GetString());
814 if (!current_version.empty()) 805 if (!current_version.empty())
815 latest_version_to_keep.assign(current_version); 806 latest_version_to_keep.assign(current_version);
816 RemoveOldVersionDirs(install_path, latest_version_to_keep); 807 RemoveOldVersionDirs(install_path, latest_version_to_keep);
817 } 808 }
818 809
819 return result; 810 return result;
820 } 811 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_main_win.cc ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698