summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util/installer_state.h
blob: 214ae4510794bc476cb3c710f3cf61a51ec744b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) 2010 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.

#ifndef CHROME_INSTALLER_UTIL_INSTALLER_STATE_H_
#define CHROME_INSTALLER_UTIL_INSTALLER_STATE_H_
#pragma once

#include <string>

#include "base/basictypes.h"
#include "chrome/installer/util/browser_distribution.h"

namespace installer {

class InstallationState;
class MasterPreferences;

// Encapsulates the state of the current installation operation.  Only valid
// for installs and upgrades (not for uninstalls or non-install commands)
class InstallerState {
 public:
  enum Operation {
    UNINITIALIZED,
    SINGLE_INSTALL_OR_UPDATE,
    MULTI_INSTALL,
    MULTI_UPDATE,
  };

  InstallerState();

  // Initializes |this| based on the current operation.
  void Initialize(const MasterPreferences& prefs,
                  const InstallationState& machine_state);

  // true if system-level, false if user-level.
  bool system_install() const { return system_install_; }

  Operation operation() const { return operation_; }

  BrowserDistribution::Type GetInstallOperand() const {
    return install_operand_;
  }

  // The ClientState key by which we interact with Google Update.
  const std::wstring& state_key() const { return state_key_; }

 private:
  bool IsMultiInstallUpdate(const MasterPreferences& prefs,
                            const InstallationState& machine_state);

  Operation operation_;
  BrowserDistribution::Type install_operand_;
  std::wstring state_key_;
  bool system_install_;

  DISALLOW_COPY_AND_ASSIGN(InstallerState);
};  // class InstallerState

}  // namespace installer

#endif  // CHROME_INSTALLER_UTIL_INSTALLER_STATE_H_