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

Unified Diff: chrome/installer/setup/setup_install_details.cc

Issue 2459583002: Use InstallDetails in setup. (Closed)
Patch Set: Created 4 years, 1 month 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
Index: chrome/installer/setup/setup_install_details.cc
diff --git a/chrome/installer/setup/setup_install_details.cc b/chrome/installer/setup/setup_install_details.cc
new file mode 100644
index 0000000000000000000000000000000000000000..33ab97a21696c4a3c4f62cbfb90dd5c1aa0dd40f
--- /dev/null
+++ b/chrome/installer/setup/setup_install_details.cc
@@ -0,0 +1,80 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/installer/setup/setup_install_details.h"
+
+#include <memory>
+#include <utility>
+
+#include "base/command_line.h"
+#include "base/memory/ptr_util.h"
+#include "chrome/install_static/install_details.h"
+#include "chrome/install_static/install_modes.h"
+#include "chrome/install_static/install_util.h"
+#include "chrome/installer/setup/brand_constants.h"
+#include "chrome/installer/util/installer_state.h"
+#include "chrome/installer/util/master_preferences.h"
+#include "chrome/installer/util/master_preferences_constants.h"
+
+namespace {
+
+const install_static::InstallConstants* FindInstallMode(
+ const base::CommandLine& command_line) {
+ // Search for a mode whose switch is on the command line.
+ for (int i = 0; i < install_static::NUM_INSTALL_MODES; ++i) {
+ const BrandConstants& constants = kBrandConstants[i];
+ if (*constants.install_switch &&
+ command_line.HasSwitch(constants.install_switch)) {
+ return &install_static::kInstallModes[i];
+ }
+ }
+ // The first mode is always the default if all else fails.
+ return &install_static::kInstallModes[0];
+}
+
+} // namespace
+
+void InitializeInstallDetails(
+ const base::CommandLine& command_line,
+ const installer::MasterPreferences& master_preferences,
+ const installer::InstallerState& installer_state) {
+ std::unique_ptr<install_static::PrimaryInstallDetails> details(
+ base::MakeUnique<install_static::PrimaryInstallDetails>());
+
+ // The mode is determined by brand-specific command line switches.
+ const install_static::InstallConstants* const mode =
+ FindInstallMode(command_line);
+ details->set_mode(mode);
+
+ // The install level may be set by any of:
+ // - distribution.system_level=true in master_preferences,
+ // - --system-level on the command line, or
+ // - the GoogleUpdateIsMachine=1 environment variable.
+ // The value is sussed out in MasterPreferences initialization.
robertshield 2016/11/04 12:50:35 s/The value/In all three cases the value/
grt (UTC plus 2) 2016/11/08 13:02:13 Done.
+ bool system_level = false;
+ master_preferences.GetBool(installer::master_preferences::kSystemLevel,
+ &system_level);
+ details->set_system_level(system_level);
+
+ // Multi-install may be set by either of:
+ // - distribution.multi_install in master_preferences or
+ // - --multi-install on the command line.
+ // The value is sussed out in MasterPreferences initialization.
robertshield 2016/11/04 12:50:35 In both cases
grt (UTC plus 2) 2016/11/08 13:02:13 Done.
+ details->set_multi_install(master_preferences.is_multi_install());
+
+ // The channel is determined based on the brand and the mode's
+ // ChannelStrategy. For brands that do not support Google Update, the channel
+ // is an empty string. For modes using the FIXED strategy, the channel is the
+ // default_channel_name in the mode. For modes using the ADDITIONAL_PARAMETERS
+ // strategy, the channel is parsed from the "ap" value in either the binaries'
+ // ClientState registry key or the mode's ClientState registry key. Which one
+ // is used depends on whether this is a new install (use the product's key) or
+ // an update of a multi-install product (use the binaries' key), and is sussed
+ // out in InstallerState initialization.
+ details->set_channel(install_static::DetermineChannel(
+ *mode, system_level,
+ installer_state.state_type() == BrowserDistribution::CHROME_BINARIES));
+
+ install_static::InstallDetails::SetForProcess(std::move(details));
+}

Powered by Google App Engine
This is Rietveld 408576698