Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_INSTALLER_UTIL_BEACONS_H_ | |
| 6 #define CHROME_INSTALLER_UTIL_BEACONS_H_ | |
| 7 | |
| 8 #include <windows.h> | |
| 9 | |
| 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" | |
| 16 | |
| 17 class AppRegistrationData; | |
| 18 class BrowserDistribution; | |
| 19 | |
| 20 namespace base { | |
| 21 class FilePath; | |
| 22 } | |
| 23 | |
| 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). | |
|
gab
2015/05/26 18:54:34
Reorder sentence to begin with the actual action t
grt (UTC plus 2)
2015/05/26 20:54:01
It is in the right order: it checks the default st
gab
2015/05/29 13:37:36
Well the fact that it "checks" is a side-effect of
grt (UTC plus 2)
2015/05/29 15:31:10
The only way that the beacons can be updated to re
| |
| 26 void UpdateDefaultBrowserBeaconForPath(const base::FilePath& chrome_exe); | |
| 27 | |
| 28 // Updates the last was default or first not default beacon for the current user | |
| 29 // based on |default_state|. | |
| 30 void UpdateDefaultBrowserBeacon(const base::FilePath& chrome_exe, | |
|
gab
2015/05/26 18:54:34
s/UpdateDefaultBrowserBeacon/UpdateDefaultBrowserB
grt (UTC plus 2)
2015/05/26 20:54:01
Done.
| |
| 31 BrowserDistribution* distribution, | |
| 32 ShellUtil::DefaultState default_state); | |
| 33 | |
| 34 // Updates the last OS upgrade beacon for the install. | |
| 35 void UpdateOsUpgradeBeacon(bool system_install, | |
| 36 BrowserDistribution* distribution); | |
| 37 | |
| 38 // A named beacon stored in the registry representing the first or last time at | |
| 39 // which some event took place. A beacon may apply to a per-user event or a | |
| 40 // per-install event. | |
| 41 class Beacon { | |
|
gab
2015/05/26 18:54:34
I think this should either be in the install_util
grt (UTC plus 2)
2015/05/26 20:54:01
I've been steered away from namespaces by other re
grt (UTC plus 2)
2015/05/28 14:05:42
Thinking about it more, this class is pretty much
gab
2015/05/29 13:37:36
I like a namespace here; otherwise you need a more
grt (UTC plus 2)
2015/05/29 15:31:10
Done.
| |
| 42 public: | |
| 43 ~Beacon(); | |
|
gab
2015/05/26 18:54:34
I think you can use
~Beacon() = default;
here inst
grt (UTC plus 2)
2015/05/26 20:54:01
A string16 isn't a POD since it has a dtor, but ma
| |
| 44 | |
| 45 // Returns an instance representing the last time the machine's OS was | |
| 46 // ugpraded. | |
| 47 static scoped_ptr<Beacon> LastOsUpgrade( | |
| 48 bool system_install, | |
| 49 const AppRegistrationData& registration_data); | |
| 50 | |
| 51 // Returns an instance representing the last time Chrome was the user's | |
| 52 // default browser. | |
| 53 static scoped_ptr<Beacon> LastWasDefault( | |
| 54 bool system_install, | |
| 55 const AppRegistrationData& registration_data); | |
| 56 | |
| 57 // Returns an instance representing the first time Chrome was not the user's | |
| 58 // default browser. | |
| 59 static scoped_ptr<Beacon> FirstNotDefault( | |
| 60 bool system_install, | |
| 61 const AppRegistrationData& registration_data); | |
| 62 | |
| 63 // Updates the beacon. For a type LAST beacon, the current time is written | |
| 64 // unconditionally. For a type FIRST beacon, the beacon is only updated if it | |
| 65 // does not already exist. | |
| 66 void Update(); | |
| 67 | |
| 68 // Removes the beacon. | |
| 69 void Remove(); | |
| 70 | |
| 71 // Returns the beacon's value or a null time if not found. | |
| 72 base::Time Get(); | |
| 73 | |
| 74 protected: | |
| 75 enum class BeaconType { | |
| 76 // A beacon that marks the first occurrence of an event. | |
| 77 FIRST, | |
| 78 // A beacon that marks the last occurrence of an event. | |
| 79 LAST, | |
| 80 }; | |
| 81 | |
| 82 enum class BeaconScope { | |
| 83 // A beacon that applies to a per-user event. | |
| 84 PER_USER, | |
| 85 // A beacon that applies to a per-install event. | |
| 86 PER_INSTALL, | |
| 87 }; | |
| 88 | |
| 89 Beacon(base::StringPiece16 name, | |
| 90 BeaconType type, | |
| 91 BeaconScope scope, | |
| 92 bool system_install, | |
| 93 const AppRegistrationData& registration_data); | |
| 94 | |
| 95 private: | |
| 96 // Initializes the key_path_ and value_name_ fields of the beacon. | |
| 97 void Initialize(base::StringPiece16 name, | |
| 98 bool system_install, | |
| 99 const AppRegistrationData& registration_data); | |
| 100 | |
| 101 // The type of beacon. | |
| 102 const BeaconType type_; | |
| 103 | |
| 104 // The root key in the registry where this beacon is stored. | |
| 105 const HKEY root_; | |
| 106 | |
| 107 // The scope of the beacon. | |
| 108 const BeaconScope scope_; | |
| 109 | |
| 110 // The path to the registry key holding the beacon. | |
| 111 base::string16 key_path_; | |
| 112 | |
| 113 // The name of the registry value holding the beacon. | |
| 114 base::string16 value_name_; | |
| 115 | |
| 116 DISALLOW_COPY_AND_ASSIGN(Beacon); | |
| 117 }; | |
| 118 | |
| 119 #endif // CHROME_INSTALLER_UTIL_BEACONS_H_ | |
| OLD | NEW |