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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/installer/setup/setup_install_details.h"
6
7 #include <memory>
8 #include <utility>
9
10 #include "base/command_line.h"
11 #include "base/memory/ptr_util.h"
12 #include "chrome/install_static/install_details.h"
13 #include "chrome/install_static/install_modes.h"
14 #include "chrome/install_static/install_util.h"
15 #include "chrome/installer/setup/brand_constants.h"
16 #include "chrome/installer/util/installer_state.h"
17 #include "chrome/installer/util/master_preferences.h"
18 #include "chrome/installer/util/master_preferences_constants.h"
19
20 namespace {
21
22 const install_static::InstallConstants* FindInstallMode(
23 const base::CommandLine& command_line) {
24 // Search for a mode whose switch is on the command line.
25 for (int i = 0; i < install_static::NUM_INSTALL_MODES; ++i) {
26 const BrandConstants& constants = kBrandConstants[i];
27 if (*constants.install_switch &&
28 command_line.HasSwitch(constants.install_switch)) {
29 return &install_static::kInstallModes[i];
30 }
31 }
32 // The first mode is always the default if all else fails.
33 return &install_static::kInstallModes[0];
34 }
35
36 } // namespace
37
38 void InitializeInstallDetails(
39 const base::CommandLine& command_line,
40 const installer::MasterPreferences& master_preferences,
41 const installer::InstallerState& installer_state) {
42 std::unique_ptr<install_static::PrimaryInstallDetails> details(
43 base::MakeUnique<install_static::PrimaryInstallDetails>());
44
45 // The mode is determined by brand-specific command line switches.
46 const install_static::InstallConstants* const mode =
47 FindInstallMode(command_line);
48 details->set_mode(mode);
49
50 // The install level may be set by any of:
51 // - distribution.system_level=true in master_preferences,
52 // - --system-level on the command line, or
53 // - the GoogleUpdateIsMachine=1 environment variable.
54 // 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.
55 bool system_level = false;
56 master_preferences.GetBool(installer::master_preferences::kSystemLevel,
57 &system_level);
58 details->set_system_level(system_level);
59
60 // Multi-install may be set by either of:
61 // - distribution.multi_install in master_preferences or
62 // - --multi-install on the command line.
63 // 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.
64 details->set_multi_install(master_preferences.is_multi_install());
65
66 // The channel is determined based on the brand and the mode's
67 // ChannelStrategy. For brands that do not support Google Update, the channel
68 // is an empty string. For modes using the FIXED strategy, the channel is the
69 // default_channel_name in the mode. For modes using the ADDITIONAL_PARAMETERS
70 // strategy, the channel is parsed from the "ap" value in either the binaries'
71 // ClientState registry key or the mode's ClientState registry key. Which one
72 // is used depends on whether this is a new install (use the product's key) or
73 // an update of a multi-install product (use the binaries' key), and is sussed
74 // out in InstallerState initialization.
75 details->set_channel(install_static::DetermineChannel(
76 *mode, system_level,
77 installer_state.state_type() == BrowserDistribution::CHROME_BINARIES));
78
79 install_static::InstallDetails::SetForProcess(std::move(details));
80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698