Commit ee17c1de authored by Greg Thompson's avatar Greg Thompson Committed by Commit Bot

Replace Product::SetMsiMarker with DeleteRegistryValue.

The latter is simpler, and allows for some code removal.

BUG=none

Change-Id: Ifaf2fd855e07c2c56cbc13920f17acd29055b9ed
Reviewed-on: https://chromium-review.googlesource.com/1196233Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Commit-Queue: Greg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587604}
parent 3f0aba15
...@@ -901,7 +901,9 @@ InstallStatus UninstallProduct(const InstallationState& original_state, ...@@ -901,7 +901,9 @@ InstallStatus UninstallProduct(const InstallationState& original_state,
// there). This is due to a Google Update behaviour where an uninstall and a // there). This is due to a Google Update behaviour where an uninstall and a
// rapid reinstall might result in stale values from the old ClientState key // rapid reinstall might result in stale values from the old ClientState key
// being picked up on reinstall. // being picked up on reinstall.
product.SetMsiMarker(installer_state.system_install(), false); InstallUtil::DeleteRegistryValue(
installer_state.root_key(), install_static::GetClientStateKeyPath(),
KEY_WOW64_32KEY, google_update::kRegMSIField);
InstallStatus ret = installer::UNKNOWN_STATUS; InstallStatus ret = installer::UNKNOWN_STATUS;
......
...@@ -9,15 +9,11 @@ ...@@ -9,15 +9,11 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/process/launch.h" #include "base/process/launch.h"
#include "base/win/registry.h"
#include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/chrome_browser_operations.h" #include "chrome/installer/util/chrome_browser_operations.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/install_util.h" #include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/product_operations.h" #include "chrome/installer/util/product_operations.h"
using base::win::RegKey;
namespace installer { namespace installer {
Product::Product(BrowserDistribution* distribution) Product::Product(BrowserDistribution* distribution)
...@@ -77,25 +73,6 @@ bool Product::LaunchChromeAndWait(const base::FilePath& application_path, ...@@ -77,25 +73,6 @@ bool Product::LaunchChromeAndWait(const base::FilePath& application_path,
return success; return success;
} }
bool Product::SetMsiMarker(bool system_install, bool set) const {
HKEY reg_root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
RegKey client_state_key;
LONG result = client_state_key.Open(reg_root,
distribution_->GetStateKey().c_str(),
KEY_SET_VALUE | KEY_WOW64_32KEY);
if (result == ERROR_SUCCESS) {
result = client_state_key.WriteValue(google_update::kRegMSIField,
set ? 1 : 0);
}
if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) {
LOG(ERROR)
<< "Failed to Open or Write MSI value to client state key. error: "
<< result;
return false;
}
return true;
}
void Product::AddKeyFiles(std::vector<base::FilePath>* key_files) const { void Product::AddKeyFiles(std::vector<base::FilePath>* key_files) const {
operations_->AddKeyFiles(key_files); operations_->AddKeyFiles(key_files);
} }
......
...@@ -56,11 +56,6 @@ class Product { ...@@ -56,11 +56,6 @@ class Product {
const base::CommandLine& options, const base::CommandLine& options,
int32_t* exit_code) const; int32_t* exit_code) const;
// Sets the boolean MSI marker for this installation if set is true or clears
// it otherwise. The MSI marker is stored in the registry under the
// ClientState key.
bool SetMsiMarker(bool system_install, bool set) const;
// See ProductOperations::AddKeyFiles. // See ProductOperations::AddKeyFiles.
void AddKeyFiles(std::vector<base::FilePath>* key_files) const; void AddKeyFiles(std::vector<base::FilePath>* key_files) const;
...@@ -70,10 +65,6 @@ class Product { ...@@ -70,10 +65,6 @@ class Product {
ShellUtil::ShortcutProperties* properties) const; ShellUtil::ShortcutProperties* properties) const;
protected: protected:
enum CacheStateFlags {
MSI_STATE = 0x01
};
BrowserDistribution* const distribution_; BrowserDistribution* const distribution_;
const std::unique_ptr<ProductOperations> operations_; const std::unique_ptr<ProductOperations> operations_;
......
...@@ -63,29 +63,11 @@ TEST(ProductTest, ProductInstallBasic) { ...@@ -63,29 +63,11 @@ TEST(ProductTest, ProductInstallBasic) {
base::UTF8ToWide( base::UTF8ToWide(
current_version.GetString()).c_str()); current_version.GetString()).c_str());
// We started out with a non-msi product.
machine_state.Initialize(); machine_state.Initialize();
const installer::ProductState* chrome_state = const installer::ProductState* chrome_state =
machine_state.GetProductState(system_level); machine_state.GetProductState(system_level);
EXPECT_NE(nullptr, chrome_state); ASSERT_NE(nullptr, chrome_state);
if (chrome_state) { EXPECT_EQ(chrome_state->version(), current_version);
EXPECT_EQ(chrome_state->version(), current_version);
EXPECT_FALSE(chrome_state->is_msi());
}
// Create a make-believe client state key.
RegKey key;
std::wstring state_key_path(distribution->GetStateKey());
ASSERT_EQ(ERROR_SUCCESS,
key.Create(root, state_key_path.c_str(), KEY_ALL_ACCESS));
// Set the MSI marker, refresh, and verify that we now see the MSI marker.
EXPECT_TRUE(product->SetMsiMarker(system_level, true));
machine_state.Initialize();
chrome_state = machine_state.GetProductState(system_level);
EXPECT_NE(nullptr, chrome_state);
if (chrome_state)
EXPECT_TRUE(chrome_state->is_msi());
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment