OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file contains the definitions of the installer functions that build | 5 // This file contains the definitions of the installer functions that build |
6 // the WorkItemList used to install the application. | 6 // the WorkItemList used to install the application. |
7 | 7 |
8 #include "chrome/installer/setup/install_worker.h" | 8 #include "chrome/installer/setup/install_worker.h" |
9 | 9 |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 in_use_update_work_items->AddSetRegValueWorkItem( | 599 in_use_update_work_items->AddSetRegValueWorkItem( |
600 root, | 600 root, |
601 dist->GetVersionKey(), | 601 dist->GetVersionKey(), |
602 google_update::kRegOldVersionField, | 602 google_update::kRegOldVersionField, |
603 UTF8ToWide(current_version->GetString()), | 603 UTF8ToWide(current_version->GetString()), |
604 true); | 604 true); |
605 // TODO(tommi): We should move the rename command here. We also need to | 605 // TODO(tommi): We should move the rename command here. We also need to |
606 // update upgrade_utils::SwapNewChromeExeIfPresent. | 606 // update upgrade_utils::SwapNewChromeExeIfPresent. |
607 } | 607 } |
608 | 608 |
| 609 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) { |
| 610 AddCopyIELowRightsPolicyWorkItems(installer_state, |
| 611 in_use_update_work_items.get()); |
| 612 } |
| 613 |
609 post_install_task_list->AddWorkItem(in_use_update_work_items.release()); | 614 post_install_task_list->AddWorkItem(in_use_update_work_items.release()); |
610 } | 615 } |
611 | 616 |
612 // Append work items that will be executed if this was NOT an in-use update. | 617 // Append work items that will be executed if this was NOT an in-use update. |
613 { | 618 { |
614 scoped_ptr<WorkItemList> regular_update_work_items( | 619 scoped_ptr<WorkItemList> regular_update_work_items( |
615 WorkItem::CreateConditionalWorkItemList( | 620 WorkItem::CreateConditionalWorkItemList( |
616 new Not(new ConditionRunIfFileExists(new_chrome_exe)))); | 621 new Not(new ConditionRunIfFileExists(new_chrome_exe)))); |
617 regular_update_work_items->set_log_message("RegularUpdateWorkItemList"); | 622 regular_update_work_items->set_log_message("RegularUpdateWorkItemList"); |
618 | 623 |
619 // Since this was not an in-use-update, delete 'opv' and 'cmd' keys. | 624 // Since this was not an in-use-update, delete 'opv' and 'cmd' keys. |
620 for (size_t i = 0; i < products.size(); ++i) { | 625 for (size_t i = 0; i < products.size(); ++i) { |
621 BrowserDistribution* dist = products[i]->distribution(); | 626 BrowserDistribution* dist = products[i]->distribution(); |
622 std::wstring version_key(dist->GetVersionKey()); | 627 std::wstring version_key(dist->GetVersionKey()); |
623 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, | 628 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, |
624 google_update::kRegOldVersionField); | 629 google_update::kRegOldVersionField); |
625 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, | 630 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, |
626 google_update::kRegRenameCmdField); | 631 google_update::kRegRenameCmdField); |
627 } | 632 } |
628 | 633 |
| 634 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) { |
| 635 AddDeleteOldIELowRightsPolicyWorkItems(installer_state, |
| 636 regular_update_work_items.get()); |
| 637 } |
| 638 |
629 post_install_task_list->AddWorkItem(regular_update_work_items.release()); | 639 post_install_task_list->AddWorkItem(regular_update_work_items.release()); |
630 } | 640 } |
631 | 641 |
632 AddRegisterComDllWorkItemsForPackage(installer_state, current_version, | 642 AddRegisterComDllWorkItemsForPackage(installer_state, current_version, |
633 new_version, post_install_task_list); | 643 new_version, post_install_task_list); |
634 | 644 |
635 // If we're told that we're an MSI install, make sure to set the marker | 645 // If we're told that we're an MSI install, make sure to set the marker |
636 // in the client state key so that future updates do the right thing. | 646 // in the client state key so that future updates do the right thing. |
637 if (installer_state.is_msi()) { | 647 if (installer_state.is_msi()) { |
638 for (size_t i = 0; i < products.size(); ++i) { | 648 for (size_t i = 0; i < products.size(); ++i) { |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 BrowserDistribution::CHROME_BROWSER)); | 972 BrowserDistribution::CHROME_BROWSER)); |
963 chrome.InitializeFromUninstallCommand(chrome_state->uninstall_command()); | 973 chrome.InitializeFromUninstallCommand(chrome_state->uninstall_command()); |
964 AddUninstallShortcutWorkItems(installer_state, setup_path, | 974 AddUninstallShortcutWorkItems(installer_state, setup_path, |
965 chrome_state->version(), list, chrome); | 975 chrome_state->version(), list, chrome); |
966 } else { | 976 } else { |
967 NOTREACHED() << "What happened to Chrome?"; | 977 NOTREACHED() << "What happened to Chrome?"; |
968 } | 978 } |
969 } | 979 } |
970 } | 980 } |
971 | 981 |
972 void AddElevationPolicyWorkItems(const InstallationState& original_state, | 982 namespace { |
973 const InstallerState& installer_state, | 983 |
974 const Version& new_version, | 984 enum ElevationPolicyId { |
975 WorkItemList* install_list) { | 985 CURRENT_ELEVATION_POLICY, |
976 if (!installer_state.is_multi_install()) { | 986 OLD_ELEVATION_POLICY, |
977 VLOG(1) << "Not adding elevation policy for single installs"; | 987 }; |
978 return; | 988 |
| 989 // Although the UUID of the ChromeFrame class is used for the "current" value, |
| 990 // this is done only as a convenience; there is no need for the GUID of the Low |
| 991 // Rights policies to match the ChromeFrame class's GUID. Hence, it is safe to |
| 992 // use this completely unrelated GUID for the "old" policies. |
| 993 const wchar_t kIELowRightsPolicyOldGuid[] = |
| 994 L"{6C288DD7-76FB-4721-B628-56FAC252E199}"; |
| 995 |
| 996 const wchar_t kElevationPolicyKeyPath[] = |
| 997 L"SOFTWARE\\Microsoft\\Internet Explorer\\Low Rights\\ElevationPolicy\\"; |
| 998 |
| 999 void GetIELowRightsElevationPolicyKeyPath(ElevationPolicyId policy, |
| 1000 std::wstring* key_path) { |
| 1001 DCHECK(policy == CURRENT_ELEVATION_POLICY || policy == OLD_ELEVATION_POLICY); |
| 1002 |
| 1003 key_path->assign(kElevationPolicyKeyPath, |
| 1004 arraysize(kElevationPolicyKeyPath) - 1); |
| 1005 if (policy == CURRENT_ELEVATION_POLICY) { |
| 1006 wchar_t cf_clsid[64]; |
| 1007 int len = StringFromGUID2(__uuidof(ChromeFrame), &cf_clsid[0], |
| 1008 arraysize(cf_clsid)); |
| 1009 key_path->append(&cf_clsid[0], len - 1); |
979 } else { | 1010 } else { |
980 const ProductState* cf_state = | 1011 key_path->append(kIELowRightsPolicyOldGuid, |
981 original_state.GetProductState(installer_state.system_install(), | 1012 arraysize(kIELowRightsPolicyOldGuid)- 1); |
982 BrowserDistribution::CHROME_FRAME); | |
983 if (cf_state && !cf_state->is_multi_install()) { | |
984 LOG(WARNING) << "Not adding elevation policy since a single install " | |
985 "of CF exists"; | |
986 return; | |
987 } | |
988 } | |
989 | |
990 FilePath binary_dir( | |
991 GetChromeInstallPath(installer_state.system_install(), | |
992 BrowserDistribution::GetSpecificDistribution( | |
993 BrowserDistribution::CHROME_BINARIES))); | |
994 | |
995 struct { | |
996 const wchar_t* sub_key; | |
997 const wchar_t* executable; | |
998 const FilePath exe_dir; | |
999 } low_rights_entries[] = { | |
1000 { L"ElevationPolicy\\", kChromeLauncherExe, | |
1001 binary_dir.Append(ASCIIToWide(new_version.GetString())) }, | |
1002 { L"DragDrop\\", chrome::kBrowserProcessExecutableName, binary_dir }, | |
1003 }; | |
1004 | |
1005 bool uninstall = (installer_state.operation() == InstallerState::UNINSTALL); | |
1006 HKEY root = installer_state.root_key(); | |
1007 const wchar_t kLowRightsKeyPath[] = | |
1008 L"SOFTWARE\\Microsoft\\Internet Explorer\\Low Rights\\"; | |
1009 std::wstring key_path(kLowRightsKeyPath); | |
1010 | |
1011 wchar_t cf_classid[64] = {0}; | |
1012 StringFromGUID2(__uuidof(ChromeFrame), cf_classid, arraysize(cf_classid)); | |
1013 | |
1014 for (size_t i = 0; i < arraysize(low_rights_entries); ++i) { | |
1015 key_path.append(low_rights_entries[i].sub_key).append(cf_classid); | |
1016 if (uninstall) { | |
1017 install_list->AddDeleteRegKeyWorkItem(root, key_path); | |
1018 } else { | |
1019 install_list->AddCreateRegKeyWorkItem(root, key_path); | |
1020 install_list->AddSetRegValueWorkItem(root, key_path, L"Policy", | |
1021 static_cast<DWORD>(3), true); | |
1022 install_list->AddSetRegValueWorkItem(root, key_path, L"AppName", | |
1023 low_rights_entries[i].executable, true); | |
1024 install_list->AddSetRegValueWorkItem(root, key_path, L"AppPath", | |
1025 low_rights_entries[i].exe_dir.value(), true); | |
1026 } | |
1027 key_path.resize(arraysize(kLowRightsKeyPath) - 1); | |
1028 } | 1013 } |
1029 } | 1014 } |
1030 | 1015 |
| 1016 } // namespace |
| 1017 |
| 1018 void AddDeleteOldIELowRightsPolicyWorkItems( |
| 1019 const InstallerState& installer_state, |
| 1020 WorkItemList* install_list) { |
| 1021 DCHECK(install_list); |
| 1022 |
| 1023 std::wstring key_path; |
| 1024 GetIELowRightsElevationPolicyKeyPath(OLD_ELEVATION_POLICY, &key_path); |
| 1025 install_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), key_path); |
| 1026 } |
| 1027 |
| 1028 // Adds work items to copy the chrome_launcher IE low rights elevation policy |
| 1029 // from the primary policy GUID to the "old" policy GUID. Take care not to |
| 1030 // perform the copy if there is already an old policy present, as the ones under |
| 1031 // the main kElevationPolicyGuid would then correspond to an intermediate |
| 1032 // version (current_version < pv < new_version). |
| 1033 void AddCopyIELowRightsPolicyWorkItems(const InstallerState& installer_state, |
| 1034 WorkItemList* install_list) { |
| 1035 DCHECK(install_list); |
| 1036 |
| 1037 std::wstring current_key_path; |
| 1038 std::wstring old_key_path; |
| 1039 |
| 1040 GetIELowRightsElevationPolicyKeyPath(CURRENT_ELEVATION_POLICY, |
| 1041 ¤t_key_path); |
| 1042 GetIELowRightsElevationPolicyKeyPath(OLD_ELEVATION_POLICY, &old_key_path); |
| 1043 // Do not clobber existing old policies. |
| 1044 install_list->AddCopyRegKeyWorkItem(installer_state.root_key(), |
| 1045 current_key_path, old_key_path, |
| 1046 WorkItem::IF_NOT_PRESENT); |
| 1047 } |
| 1048 |
1031 void AppendUninstallCommandLineFlags(const InstallerState& installer_state, | 1049 void AppendUninstallCommandLineFlags(const InstallerState& installer_state, |
1032 const Product& product, | 1050 const Product& product, |
1033 CommandLine* uninstall_cmd) { | 1051 CommandLine* uninstall_cmd) { |
1034 DCHECK(uninstall_cmd); | 1052 DCHECK(uninstall_cmd); |
1035 | 1053 |
1036 uninstall_cmd->AppendSwitch(installer::switches::kUninstall); | 1054 uninstall_cmd->AppendSwitch(installer::switches::kUninstall); |
1037 | 1055 |
1038 // Append the product-specific uninstall flags. | 1056 // Append the product-specific uninstall flags. |
1039 product.AppendUninstallFlags(uninstall_cmd); | 1057 product.AppendUninstallFlags(uninstall_cmd); |
1040 if (installer_state.is_msi()) { | 1058 if (installer_state.is_msi()) { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 } else { | 1219 } else { |
1202 DCHECK(operation == REMOVE_COMMAND); | 1220 DCHECK(operation == REMOVE_COMMAND); |
1203 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), | 1221 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), |
1204 cmd_key)->set_log_message( | 1222 cmd_key)->set_log_message( |
1205 "removing quick-enable-cf command"); | 1223 "removing quick-enable-cf command"); |
1206 } | 1224 } |
1207 } | 1225 } |
1208 } | 1226 } |
1209 | 1227 |
1210 } // namespace installer | 1228 } // namespace installer |
OLD | NEW |