1 // Copyright 2015 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.
5 #ifndef CHROME_INSTALLER_UTIL_BEACONS_H_
6 #define CHROME_INSTALLER_UTIL_BEACONS_H_
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h"
13 #include "base/strings/string_piece.h"
14 #include "base/time/time.h"
15 #include "chrome/installer/util/shell_util.h"
17 class AppRegistrationData
;
18 class BrowserDistribution
;
24 // Checks the default state of the browser for the current user and updates the
25 // appropriate beacon (last was default or first not default).
26 void UpdateDefaultBrowserBeaconForPath(const base::FilePath
& chrome_exe
);
28 // Updates the last was default or first not default beacon for the current user
29 // based on |default_state|.
30 void UpdateDefaultBrowserBeaconWithState(const base::FilePath
& chrome_exe
,
31 BrowserDistribution
* distribution
,
32 ShellUtil::DefaultState default_state
);
34 // Updates the last OS upgrade beacon for the install.
35 void UpdateOsUpgradeBeacon(bool system_install
,
36 BrowserDistribution
* distribution
);
38 namespace installer_util
{
42 // Returns a Beacon representing the last time the machine's OS was ugpraded.
43 scoped_ptr
<Beacon
> MakeLastOsUpgradeBeacon(
45 const AppRegistrationData
& registration_data
);
47 // Returns a Beacon representing the last time Chrome was the user's default
49 scoped_ptr
<Beacon
> MakeLastWasDefaultBeacon(
51 const AppRegistrationData
& registration_data
);
53 // Returns a Beacon representing the first time Chrome was not the user's
55 scoped_ptr
<Beacon
> MakeFirstNotDefaultBeacon(
57 const AppRegistrationData
& registration_data
);
59 // A named beacon stored in the registry representing the first or last time at
60 // which some event took place. A beacon may apply to a per-user event or a
61 // per-install event. In general, beacons should be created via factory methods
62 // such as those above.
65 enum class BeaconType
{
66 // A beacon that marks the first occurrence of an event.
68 // A beacon that marks the last occurrence of an event.
72 enum class BeaconScope
{
73 // A beacon that applies to a per-user event.
75 // A beacon that applies to a per-install event.
79 // Creates a beacon named |name| for the product identified by
80 // |registration_data| installed as either a per-user or a per-machine app
81 // according to |system_install|.
82 Beacon(base::StringPiece16 name
,
86 const AppRegistrationData
& registration_data
);
89 // Updates the beacon. For a type LAST beacon, the current time is written
90 // unconditionally. For a type FIRST beacon, the beacon is only updated if it
91 // does not already exist.
94 // Removes the beacon.
97 // Returns the beacon's value or a null time if not found.
101 // Initializes the key_path_ and value_name_ fields of the beacon.
102 void Initialize(base::StringPiece16 name
,
104 const AppRegistrationData
& registration_data
);
106 // The type of beacon.
107 const BeaconType type_
;
109 // The root key in the registry where this beacon is stored.
112 // The scope of the beacon.
113 const BeaconScope scope_
;
115 // The path to the registry key holding the beacon.
116 base::string16 key_path_
;
118 // The name of the registry value holding the beacon.
119 base::string16 value_name_
;
121 DISALLOW_COPY_AND_ASSIGN(Beacon
);
124 } // namespace installer_util
126 #endif // CHROME_INSTALLER_UTIL_BEACONS_H_