OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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_BROWSER_IMPORTER_IE_IMPORTER_TEST_REGISTRY_OVERRIDER_WIN_H_ | |
6 #define CHROME_BROWSER_IMPORTER_IE_IMPORTER_TEST_REGISTRY_OVERRIDER_WIN_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 | |
10 // A helper class to override HKEY_CURRENT_USER to point to a test key from this | |
11 // process' point of view. Also provides functionality (via an environment | |
12 // variable) to let child processes check whether they should also override. | |
13 // Always unsets any existing override upon being deleted. | |
14 class IEImporterTestRegistryOverrider { | |
15 public: | |
16 IEImporterTestRegistryOverrider() : override_set_by_current_process_(false) {} | |
17 | |
18 // Unsets any existing registry override and deletes the temporary registry | |
19 // key if |override_set_by_current_process_|. | |
20 ~IEImporterTestRegistryOverrider(); | |
21 | |
22 // Calls StartRegistryOverride() and sets an environment variable so that | |
23 // future calls to StartRegistryOverrideIfNeeded() from child processes also | |
24 // result in an overriden registry. | |
25 // Returns false on unexpected failure. | |
26 bool SetRegistryOverride(); | |
robertshield
2013/04/26 19:20:53
If I am reading this correctly, a caller should ne
gab
2013/04/29 02:00:43
Changed the interface quite a bit, let me know if
| |
27 | |
28 // Calls StartRegistryOverride() if the environment was set by a parent | |
29 // process via SetRegistryOverride(). | |
30 // Returns false on unexpected failure. | |
31 bool StartRegistryOverrideIfNeeded(); | |
32 | |
33 private: | |
34 // Overrides HKCU to point to a test key from this process' point of view. | |
35 // Returns false on unexpected failure. | |
36 bool StartRegistryOverride(); | |
37 | |
38 // Whether a registry override was initiated in the current process. | |
39 bool override_active_; | |
robertshield
2013/04/26 19:20:53
should this be static?
gab
2013/04/29 02:00:43
See main comment.
| |
40 | |
41 // Wheter this process is the one that set the override (and thus should be | |
robertshield
2013/04/26 19:20:53
nit: Whether
gab
2013/04/29 02:00:43
Done.
| |
42 // the one deleting the temporary key when done). | |
43 bool override_set_by_current_process_; | |
44 | |
45 DISALLOW_COPY_AND_ASSIGN(IEImporterTestRegistryOverrider); | |
46 }; | |
47 | |
48 #endif // CHROME_BROWSER_IMPORTER_IE_IMPORTER_TEST_REGISTRY_OVERRIDER_WIN_H_ | |
OLD | NEW |