Chromium Code Reviews| Index: chrome/installer/setup/install_worker.cc |
| diff --git a/chrome/installer/setup/install_worker.cc b/chrome/installer/setup/install_worker.cc |
| index 7164d5032219a4ce284d8ddacfc94e5e2959f836..3e26b5c1836552a24ca8765d0ae59b55e0d9c2e1 100644 |
| --- a/chrome/installer/setup/install_worker.cc |
| +++ b/chrome/installer/setup/install_worker.cc |
| @@ -606,6 +606,9 @@ bool AppendPostInstallTasks(const InstallerState& installer_state, |
| // update upgrade_utils::SwapNewChromeExeIfPresent. |
| } |
| + MaybeAddCopyIELowRightsPolicyWorkItems(installer_state, |
| + in_use_update_work_items.get()); |
| + |
| post_install_task_list->AddWorkItem(in_use_update_work_items.release()); |
| } |
| @@ -626,6 +629,9 @@ bool AppendPostInstallTasks(const InstallerState& installer_state, |
| google_update::kRegRenameCmdField); |
| } |
| + MaybeAddDeleteOldIELowRightsPolicyWorkItems( |
| + installer_state, regular_update_work_items.get()); |
| + |
| post_install_task_list->AddWorkItem(regular_update_work_items.release()); |
| } |
| @@ -969,62 +975,84 @@ void AddChromeFrameWorkItems(const InstallationState& original_state, |
| } |
| } |
| -void AddElevationPolicyWorkItems(const InstallationState& original_state, |
| - const InstallerState& installer_state, |
| - const Version& new_version, |
| - WorkItemList* install_list) { |
| - if (!installer_state.is_multi_install()) { |
| - VLOG(1) << "Not adding elevation policy for single installs"; |
| - return; |
| +namespace { |
| + |
| +enum ElevationPolicyId { |
| + CURRENT_ELEVATION_POLICY, |
| + OLD_ELEVATION_POLICY, |
| +}; |
| + |
| +// Historically, the UUID of the ChromeFrame class has been used for this value. |
| +// There is no need for the elevation policy GUID to match the ChromeFrame |
| +// class's GUID, so I am choosing to hardcode the GUID for the policy here |
| +// rather than do something like StringFromGUID2(__uuidof(ChromeFrame), ...). |
|
robertshield
2011/09/22 20:34:10
If there is nothing that constrains the GUID from
grt (UTC plus 2)
2011/09/23 04:16:49
Because the reader could be confused into thinking
robertshield
2011/09/23 14:22:18
SGTM.
|
| +const wchar_t kIELowRightsPolicyGuid[] = |
|
robertshield
2011/09/22 20:34:10
Sometimes we call things ElevationPolicy and other
grt (UTC plus 2)
2011/09/23 04:16:49
GCF requires some entries in two subkeys of IE's "
robertshield
2011/09/23 14:22:18
Ok, I don't feel strongly, as long as you admit th
|
| + L"{E0A900DF-9611-4446-86BD-4B1D47E7DB2A}"; |
| +const wchar_t kIELowRightsPolicyOldGuid[] = |
| + L"{6C288DD7-76FB-4721-B628-56FAC252E199}"; |
| + |
| +const wchar_t kElevationPolicyKeyPath[] = |
| + L"SOFTWARE\\Microsoft\\Internet Explorer\\Low Rights\\ElevationPolicy\\"; |
| + |
| +void GetIELowRightsElevationPolicyKeyPath(ElevationPolicyId policy, |
|
robertshield
2011/09/22 20:34:10
Drop the "LowRights" bit of the name.
grt (UTC plus 2)
2011/09/23 04:16:49
This function returns the path to the "ElevationPo
robertshield
2011/09/23 14:22:18
As you will.
|
| + std::wstring* key_path) { |
| + DCHECK(policy == CURRENT_ELEVATION_POLICY || policy == OLD_ELEVATION_POLICY); |
|
robertshield
2011/09/22 20:34:10
Do we commonly dcheck that enum values are one of
grt (UTC plus 2)
2011/09/23 04:16:49
I'm not sure. I put this here so that if a third
robertshield
2011/09/23 14:22:18
Yes, but just because you're paranoid doesn't mean
|
| + |
| + key_path->assign(kElevationPolicyKeyPath, |
| + arraysize(kElevationPolicyKeyPath) - 1); |
| + if (policy == CURRENT_ELEVATION_POLICY) { |
| + key_path->append(kIELowRightsPolicyGuid, |
| + arraysize(kIELowRightsPolicyGuid) - 1); |
| } else { |
|
robertshield
2011/09/23 14:22:18
perhaps change this to
} else if (policy == OLD_
grt (UTC plus 2)
2011/09/23 18:21:07
My hope was that the DCHECK is sufficient. How st
robertshield
2011/09/23 18:34:24
lg.
|
| - const ProductState* cf_state = |
| - original_state.GetProductState(installer_state.system_install(), |
| - BrowserDistribution::CHROME_FRAME); |
| - if (cf_state && !cf_state->is_multi_install()) { |
| - LOG(WARNING) << "Not adding elevation policy since a single install " |
| - "of CF exists"; |
| - return; |
| - } |
| + key_path->append(kIELowRightsPolicyOldGuid, |
| + arraysize(kIELowRightsPolicyOldGuid)- 1); |
| } |
| +} |
| - FilePath binary_dir( |
| - GetChromeInstallPath(installer_state.system_install(), |
| - BrowserDistribution::GetSpecificDistribution( |
| - BrowserDistribution::CHROME_BINARIES))); |
| - |
| - struct { |
| - const wchar_t* sub_key; |
| - const wchar_t* executable; |
| - const FilePath exe_dir; |
| - } low_rights_entries[] = { |
| - { L"ElevationPolicy\\", kChromeLauncherExe, |
| - binary_dir.Append(ASCIIToWide(new_version.GetString())) }, |
| - { L"DragDrop\\", chrome::kBrowserProcessExecutableName, binary_dir }, |
| - }; |
| - |
| - bool uninstall = (installer_state.operation() == InstallerState::UNINSTALL); |
| - HKEY root = installer_state.root_key(); |
| - const wchar_t kLowRightsKeyPath[] = |
| - L"SOFTWARE\\Microsoft\\Internet Explorer\\Low Rights\\"; |
| - std::wstring key_path(kLowRightsKeyPath); |
| +// Returns true if this installation run owns the old IE low rights policies. |
| +bool InstallerOwnsOldLowRightsPolicies(const InstallerState& installer_state) { |
|
robertshield
2011/09/22 20:34:10
InstallerOwnsOldLowRightsPolicies -> InstallerOwns
robertshield
2011/09/23 14:22:18
I take it that you disagree? Fine :-)
|
| + // The installer owns the old policies only when GCF is being operated on. |
| + return installer_state.FindProduct(BrowserDistribution::CHROME_FRAME) != NULL; |
| +} |
| - wchar_t cf_classid[64] = {0}; |
| - StringFromGUID2(__uuidof(ChromeFrame), cf_classid, arraysize(cf_classid)); |
| +} // namespace |
| - for (size_t i = 0; i < arraysize(low_rights_entries); ++i) { |
| - key_path.append(low_rights_entries[i].sub_key).append(cf_classid); |
| - if (uninstall) { |
| - install_list->AddDeleteRegKeyWorkItem(root, key_path); |
| - } else { |
| - install_list->AddCreateRegKeyWorkItem(root, key_path); |
| - install_list->AddSetRegValueWorkItem(root, key_path, L"Policy", |
| - static_cast<DWORD>(3), true); |
| - install_list->AddSetRegValueWorkItem(root, key_path, L"AppName", |
| - low_rights_entries[i].executable, true); |
| - install_list->AddSetRegValueWorkItem(root, key_path, L"AppPath", |
| - low_rights_entries[i].exe_dir.value(), true); |
| +void MaybeAddDeleteOldIELowRightsPolicyWorkItems( |
| + const InstallerState& installer_state, |
| + WorkItemList* install_list) { |
| + DCHECK(install_list); |
| + |
| + if (InstallerOwnsOldLowRightsPolicies(installer_state)) { |
| + std::wstring key_path; |
| + GetIELowRightsElevationPolicyKeyPath(OLD_ELEVATION_POLICY, &key_path); |
| + install_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), key_path); |
| + } |
| +} |
| + |
| +// Conditionally adds work items to copy the chrome_launcher IE low rights |
| +// elevation policy from the primary policy GUID to the "old" policy GUID. Take |
| +// care not to perform the copy if there is already an old policy present, as |
| +// the ones under the main kElevationPolicyGuid would then correspond to an |
| +// intermediate version (current_version < pv < new_version). |
| +void MaybeAddCopyIELowRightsPolicyWorkItems( |
|
robertshield
2011/09/22 20:34:10
what about instead of having these MaybeFoo method
grt (UTC plus 2)
2011/09/23 04:16:49
The Copy is only called for an in-use update, whil
robertshield
2011/09/23 14:22:18
How about just wrapping the existing call sites in
grt (UTC plus 2)
2011/09/23 18:21:07
Done.
|
| + const InstallerState& installer_state, |
| + WorkItemList* install_list) { |
| + DCHECK(install_list); |
| + |
| + // Proceed if we own the old policies and if old policies are not already |
| + // present (we don't want to clobber them). |
| + if (InstallerOwnsOldLowRightsPolicies(installer_state)) { |
| + const HKEY root = installer_state.root_key(); |
| + std::wstring old_key_path; |
| + |
| + GetIELowRightsElevationPolicyKeyPath(OLD_ELEVATION_POLICY, &old_key_path); |
| + if (!RegKey(root, old_key_path.c_str(), KEY_QUERY_VALUE).Valid()) { |
| + std::wstring current_key_path; |
| + |
| + GetIELowRightsElevationPolicyKeyPath(CURRENT_ELEVATION_POLICY, |
| + ¤t_key_path); |
| + install_list->AddCopyRegKeyWorkItem(root, current_key_path, old_key_path); |
| } |
| - key_path.resize(arraysize(kLowRightsKeyPath) - 1); |
| } |
| } |