| 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 MaybeAddCopyIELowRightsPolicyWorkItems(installer_state, |
| 610 in_use_update_work_items.get()); |
| 611 |
| 609 post_install_task_list->AddWorkItem(in_use_update_work_items.release()); | 612 post_install_task_list->AddWorkItem(in_use_update_work_items.release()); |
| 610 } | 613 } |
| 611 | 614 |
| 612 // Append work items that will be executed if this was NOT an in-use update. | 615 // Append work items that will be executed if this was NOT an in-use update. |
| 613 { | 616 { |
| 614 scoped_ptr<WorkItemList> regular_update_work_items( | 617 scoped_ptr<WorkItemList> regular_update_work_items( |
| 615 WorkItem::CreateConditionalWorkItemList( | 618 WorkItem::CreateConditionalWorkItemList( |
| 616 new Not(new ConditionRunIfFileExists(new_chrome_exe)))); | 619 new Not(new ConditionRunIfFileExists(new_chrome_exe)))); |
| 617 regular_update_work_items->set_log_message("RegularUpdateWorkItemList"); | 620 regular_update_work_items->set_log_message("RegularUpdateWorkItemList"); |
| 618 | 621 |
| 619 // Since this was not an in-use-update, delete 'opv' and 'cmd' keys. | 622 // Since this was not an in-use-update, delete 'opv' and 'cmd' keys. |
| 620 for (size_t i = 0; i < products.size(); ++i) { | 623 for (size_t i = 0; i < products.size(); ++i) { |
| 621 BrowserDistribution* dist = products[i]->distribution(); | 624 BrowserDistribution* dist = products[i]->distribution(); |
| 622 std::wstring version_key(dist->GetVersionKey()); | 625 std::wstring version_key(dist->GetVersionKey()); |
| 623 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, | 626 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, |
| 624 google_update::kRegOldVersionField); | 627 google_update::kRegOldVersionField); |
| 625 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, | 628 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, |
| 626 google_update::kRegRenameCmdField); | 629 google_update::kRegRenameCmdField); |
| 627 } | 630 } |
| 628 | 631 |
| 632 MaybeAddDeleteOldIELowRightsPolicyWorkItems( |
| 633 installer_state, regular_update_work_items.get()); |
| 634 |
| 629 post_install_task_list->AddWorkItem(regular_update_work_items.release()); | 635 post_install_task_list->AddWorkItem(regular_update_work_items.release()); |
| 630 } | 636 } |
| 631 | 637 |
| 632 AddRegisterComDllWorkItemsForPackage(installer_state, current_version, | 638 AddRegisterComDllWorkItemsForPackage(installer_state, current_version, |
| 633 new_version, post_install_task_list); | 639 new_version, post_install_task_list); |
| 634 | 640 |
| 635 // If we're told that we're an MSI install, make sure to set the marker | 641 // 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. | 642 // in the client state key so that future updates do the right thing. |
| 637 if (installer_state.is_msi()) { | 643 if (installer_state.is_msi()) { |
| 638 for (size_t i = 0; i < products.size(); ++i) { | 644 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)); | 968 BrowserDistribution::CHROME_BROWSER)); |
| 963 chrome.InitializeFromUninstallCommand(chrome_state->uninstall_command()); | 969 chrome.InitializeFromUninstallCommand(chrome_state->uninstall_command()); |
| 964 AddUninstallShortcutWorkItems(installer_state, setup_path, | 970 AddUninstallShortcutWorkItems(installer_state, setup_path, |
| 965 chrome_state->version(), list, chrome); | 971 chrome_state->version(), list, chrome); |
| 966 } else { | 972 } else { |
| 967 NOTREACHED() << "What happened to Chrome?"; | 973 NOTREACHED() << "What happened to Chrome?"; |
| 968 } | 974 } |
| 969 } | 975 } |
| 970 } | 976 } |
| 971 | 977 |
| 972 void AddElevationPolicyWorkItems(const InstallationState& original_state, | 978 namespace { |
| 973 const InstallerState& installer_state, | 979 |
| 974 const Version& new_version, | 980 enum ElevationPolicyId { |
| 975 WorkItemList* install_list) { | 981 CURRENT_ELEVATION_POLICY, |
| 976 if (!installer_state.is_multi_install()) { | 982 OLD_ELEVATION_POLICY, |
| 977 VLOG(1) << "Not adding elevation policy for single installs"; | 983 }; |
| 978 return; | 984 |
| 985 // Although the UUID of the ChromeFrame class is used for the "current" value, |
| 986 // this is done only as a convenience; there is no need for the GUID of the Low |
| 987 // Rights policies to match the ChromeFrame class's GUID. Hence, it is safe to |
| 988 // use this completely unrelated GUID for the "old" policies. |
| 989 const wchar_t kIELowRightsPolicyOldGuid[] = |
| 990 L"{6C288DD7-76FB-4721-B628-56FAC252E199}"; |
| 991 |
| 992 const wchar_t kElevationPolicyKeyPath[] = |
| 993 L"SOFTWARE\\Microsoft\\Internet Explorer\\Low Rights\\ElevationPolicy\\"; |
| 994 |
| 995 void GetIELowRightsElevationPolicyKeyPath(ElevationPolicyId policy, |
| 996 std::wstring* key_path) { |
| 997 DCHECK(policy == CURRENT_ELEVATION_POLICY || policy == OLD_ELEVATION_POLICY); |
| 998 |
| 999 key_path->assign(kElevationPolicyKeyPath, |
| 1000 arraysize(kElevationPolicyKeyPath) - 1); |
| 1001 if (policy == CURRENT_ELEVATION_POLICY) { |
| 1002 wchar_t cf_clsid[64]; |
| 1003 int len = StringFromGUID2(__uuidof(ChromeFrame), &cf_clsid[0], |
| 1004 arraysize(cf_clsid)); |
| 1005 key_path->append(&cf_clsid[0], len - 1); |
| 979 } else { | 1006 } else { |
| 980 const ProductState* cf_state = | 1007 key_path->append(kIELowRightsPolicyOldGuid, |
| 981 original_state.GetProductState(installer_state.system_install(), | 1008 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 } | 1009 } |
| 1029 } | 1010 } |
| 1030 | 1011 |
| 1012 // Returns true if this installation run owns the old IE low rights policies. |
| 1013 bool InstallerOwnsOldLowRightsPolicies(const InstallerState& installer_state) { |
| 1014 // The installer owns the old policies only when GCF is being operated on. |
| 1015 return installer_state.FindProduct(BrowserDistribution::CHROME_FRAME) != NULL; |
| 1016 } |
| 1017 |
| 1018 } // namespace |
| 1019 |
| 1020 void MaybeAddDeleteOldIELowRightsPolicyWorkItems( |
| 1021 const InstallerState& installer_state, |
| 1022 WorkItemList* install_list) { |
| 1023 DCHECK(install_list); |
| 1024 |
| 1025 if (InstallerOwnsOldLowRightsPolicies(installer_state)) { |
| 1026 std::wstring key_path; |
| 1027 GetIELowRightsElevationPolicyKeyPath(OLD_ELEVATION_POLICY, &key_path); |
| 1028 install_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), key_path); |
| 1029 } |
| 1030 } |
| 1031 |
| 1032 // Conditionally adds work items to copy the chrome_launcher IE low rights |
| 1033 // elevation policy from the primary policy GUID to the "old" policy GUID. Take |
| 1034 // care not to perform the copy if there is already an old policy present, as |
| 1035 // the ones under the main kElevationPolicyGuid would then correspond to an |
| 1036 // intermediate version (current_version < pv < new_version). |
| 1037 void MaybeAddCopyIELowRightsPolicyWorkItems( |
| 1038 const InstallerState& installer_state, |
| 1039 WorkItemList* install_list) { |
| 1040 DCHECK(install_list); |
| 1041 |
| 1042 // Proceed if we own the old policies and if old policies are not already |
| 1043 // present (we don't want to clobber them). |
| 1044 if (InstallerOwnsOldLowRightsPolicies(installer_state)) { |
| 1045 const HKEY root = installer_state.root_key(); |
| 1046 std::wstring old_key_path; |
| 1047 |
| 1048 GetIELowRightsElevationPolicyKeyPath(OLD_ELEVATION_POLICY, &old_key_path); |
| 1049 if (!RegKey(root, old_key_path.c_str(), KEY_QUERY_VALUE).Valid()) { |
| 1050 std::wstring current_key_path; |
| 1051 |
| 1052 GetIELowRightsElevationPolicyKeyPath(CURRENT_ELEVATION_POLICY, |
| 1053 ¤t_key_path); |
| 1054 install_list->AddCopyRegKeyWorkItem(root, current_key_path, old_key_path); |
| 1055 } |
| 1056 } |
| 1057 } |
| 1058 |
| 1031 void AppendUninstallCommandLineFlags(const InstallerState& installer_state, | 1059 void AppendUninstallCommandLineFlags(const InstallerState& installer_state, |
| 1032 const Product& product, | 1060 const Product& product, |
| 1033 CommandLine* uninstall_cmd) { | 1061 CommandLine* uninstall_cmd) { |
| 1034 DCHECK(uninstall_cmd); | 1062 DCHECK(uninstall_cmd); |
| 1035 | 1063 |
| 1036 uninstall_cmd->AppendSwitch(installer::switches::kUninstall); | 1064 uninstall_cmd->AppendSwitch(installer::switches::kUninstall); |
| 1037 | 1065 |
| 1038 // Append the product-specific uninstall flags. | 1066 // Append the product-specific uninstall flags. |
| 1039 product.AppendUninstallFlags(uninstall_cmd); | 1067 product.AppendUninstallFlags(uninstall_cmd); |
| 1040 if (installer_state.is_msi()) { | 1068 if (installer_state.is_msi()) { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 } else { | 1229 } else { |
| 1202 DCHECK(operation == REMOVE_COMMAND); | 1230 DCHECK(operation == REMOVE_COMMAND); |
| 1203 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), | 1231 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), |
| 1204 cmd_key)->set_log_message( | 1232 cmd_key)->set_log_message( |
| 1205 "removing quick-enable-cf command"); | 1233 "removing quick-enable-cf command"); |
| 1206 } | 1234 } |
| 1207 } | 1235 } |
| 1208 } | 1236 } |
| 1209 | 1237 |
| 1210 } // namespace installer | 1238 } // namespace installer |
| OLD | NEW |