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

Unified Diff: chrome/installer/util/product.cc

Issue 6288009: More installer refactoring in the interest of fixing some bugs and cleaning t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/util/product.h ('k') | chrome/installer/util/product_operations.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/util/product.cc
===================================================================
--- chrome/installer/util/product.cc (revision 72487)
+++ chrome/installer/util/product.cc (working copy)
@@ -10,74 +10,70 @@
#include "base/logging.h"
#include "base/process_util.h"
#include "base/win/registry.h"
+#include "chrome/installer/util/chrome_browser_operations.h"
+#include "chrome/installer/util/chrome_browser_sxs_operations.h"
+#include "chrome/installer/util/chrome_frame_operations.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/master_preferences.h"
#include "chrome/installer/util/master_preferences_constants.h"
-#include "chrome/installer/util/package_properties.h"
+#include "chrome/installer/util/product_operations.h"
using base::win::RegKey;
using installer::MasterPreferences;
-namespace {
-class ProductIsOfType {
- public:
- explicit ProductIsOfType(BrowserDistribution::Type type)
- : type_(type) { }
- bool operator()(
- const scoped_refptr<const installer::Product>& pi) const {
- return pi->distribution()->GetType() == type_;
- }
- private:
- BrowserDistribution::Type type_;
-}; // class ProductIsOfType
-} // end namespace
-
namespace installer {
-const Product* FindProduct(const Products& products,
- BrowserDistribution::Type type) {
- Products::const_iterator i =
- std::find_if(products.begin(), products.end(), ProductIsOfType(type));
- return i == products.end() ? NULL : *i;
+Product::Product(BrowserDistribution* distribution)
+ : distribution_(distribution) {
+ switch (distribution->GetType()) {
+ case BrowserDistribution::CHROME_BROWSER:
+ operations_.reset(InstallUtil::IsChromeSxSProcess() ?
+ new ChromeBrowserSxSOperations() :
+ new ChromeBrowserOperations());
+ break;
+ case BrowserDistribution::CHROME_FRAME:
+ operations_.reset(new ChromeFrameOperations());
+ break;
+ default:
+ NOTREACHED() << "Unsupported BrowserDistribution::Type: "
+ << distribution->GetType();
+ }
}
-////////////////////////////////////////////////////////////////////////////////
+Product::~Product() {
+}
-Product::Product(BrowserDistribution* distribution, Package* package)
- : distribution_(distribution),
- package_(package),
- msi_(false),
- cache_state_(0) {
- package_->AssociateProduct(this);
+void Product::InitializeFromPreferences(const MasterPreferences& prefs) {
+ operations_->ReadOptions(prefs, &options_);
}
-const Package& Product::package() const {
- return *package_.get();
+void Product::InitializeFromUninstallCommand(
+ const CommandLine& uninstall_command) {
+ operations_->ReadOptions(uninstall_command, &options_);
}
FilePath Product::GetUserDataPath() const {
return GetChromeUserDataPath(distribution_);
}
-bool Product::LaunchChrome() const {
- const FilePath& install_package = package_->path();
- bool success = !install_package.empty();
+bool Product::LaunchChrome(const FilePath& application_path) const {
+ bool success = !application_path.empty();
if (success) {
- CommandLine cmd(install_package.Append(installer::kChromeExe));
+ CommandLine cmd(application_path.Append(installer::kChromeExe));
success = base::LaunchApp(cmd, false, false, NULL);
}
return success;
}
-bool Product::LaunchChromeAndWait(const CommandLine& options,
+bool Product::LaunchChromeAndWait(const FilePath& application_path,
+ const CommandLine& options,
int32* exit_code) const {
- const FilePath& install_package = package_->path();
- if (install_package.empty())
+ if (application_path.empty())
return false;
- CommandLine cmd(install_package.Append(installer::kChromeExe));
+ CommandLine cmd(application_path.Append(installer::kChromeExe));
cmd.AppendArguments(options, false);
bool success = false;
@@ -113,36 +109,8 @@
return success;
}
-bool Product::IsMsi() const {
- if ((cache_state_ & MSI_STATE) == 0) {
- msi_ = false; // Covers failure cases below.
-
- const MasterPreferences& prefs = MasterPreferences::ForCurrentProcess();
-
- bool is_msi = false;
- prefs.GetBool(installer::master_preferences::kMsi, &is_msi);
-
- if (!is_msi) {
- // We didn't find it in the preferences, try looking in the registry.
- HKEY reg_root = system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
- RegKey key;
- if (key.Open(reg_root, distribution_->GetStateKey().c_str(),
- KEY_READ) == ERROR_SUCCESS) {
- DWORD msi_value = 0;
- key.ReadValueDW(google_update::kRegMSIField, &msi_value);
- msi_ = msi_value != 0;
- }
- } else {
- msi_ = true;
- }
- cache_state_ |= MSI_STATE;
- }
-
- return msi_;
-}
-
-bool Product::SetMsiMarker(bool set) const {
- HKEY reg_root = system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
+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_READ | KEY_WRITE);
@@ -158,92 +126,23 @@
}
bool Product::ShouldCreateUninstallEntry() const {
- if (IsMsi()) {
- // MSI installations will manage their own uninstall shortcuts.
- return false;
- }
-
- return distribution_->ShouldCreateUninstallEntry();
+ return operations_->ShouldCreateUninstallEntry(options_);
}
-///////////////////////////////////////////////////////////////////////////////
-ProductPackageMapping::ProductPackageMapping(bool multi_install,
- bool system_level)
- : package_properties_(new ActivePackageProperties()),
- multi_install_(multi_install),
- system_level_(system_level) {
+void Product::AddKeyFiles(std::vector<FilePath>* key_files) const {
+ operations_->AddKeyFiles(options_, key_files);
}
-const Packages& ProductPackageMapping::packages() const {
- return packages_;
+void Product::AddComDllList(std::vector<FilePath>* com_dll_list) const {
+ operations_->AddComDllList(options_, com_dll_list);
}
-const Products& ProductPackageMapping::products() const {
- return products_;
+void Product::AppendProductFlags(CommandLine* command_line) const {
+ operations_->AppendProductFlags(options_, command_line);
}
-bool ProductPackageMapping::AddDistribution(BrowserDistribution* distribution) {
- DCHECK(distribution);
- // Each product type can be added exactly once.
- DCHECK(FindProduct(products_, distribution->GetType()) == NULL);
-
- FilePath install_package;
- if (distribution->GetType() == BrowserDistribution::CHROME_BROWSER) {
- install_package = GetChromeInstallPath(system_level_, distribution);
- } else {
- DCHECK_EQ(BrowserDistribution::CHROME_FRAME, distribution->GetType());
- install_package = GetChromeFrameInstallPath(multi_install_, system_level_,
- distribution);
- }
-
- if (install_package.empty()) {
- LOG(ERROR) << "Got an empty installation path for "
- << distribution->GetApplicationName()
- << ". It's likely that there's a conflicting "
- "installation present";
- return false;
- }
-
- scoped_refptr<Package> target_package;
- for (size_t i = 0; i < packages_.size(); ++i) {
- if (packages_[i]->IsEqual(install_package)) {
- // Use an existing Package.
- target_package = packages_[i];
- break;
- }
- }
-
- if (!target_package.get()) {
- DCHECK(packages_.empty()) << "Multiple packages per run unsupported.";
- // create new one and add.
- target_package = new Package(multi_install_, system_level_, install_package,
- package_properties_.get());
- packages_.push_back(target_package);
- }
-
- scoped_refptr<Product> product(new Product(distribution, target_package));
-#ifndef NDEBUG
- for (size_t i = 0; i < products_.size(); ++i) {
- DCHECK_EQ(product->IsMsi(), products_[i]->IsMsi());
- }
-#endif
- products_.push_back(product);
-
- return true;
+bool Product::SetChannelFlags(bool set, ChannelInfo* channel_info) const {
+ return operations_->SetChannelFlags(options_, set, channel_info);
}
-bool ProductPackageMapping::AddDistribution(
- BrowserDistribution::Type type,
- const MasterPreferences& prefs) {
- BrowserDistribution* distribution =
- BrowserDistribution::GetSpecificDistribution(type, prefs);
- if (!distribution) {
- NOTREACHED();
- return false;
- }
-
- return AddDistribution(distribution);
-}
-
} // namespace installer
-
« no previous file with comments | « chrome/installer/util/product.h ('k') | chrome/installer/util/product_operations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698