Index: chrome/browser/importer/ie_importer_test_registry_overrider_win.h |
diff --git a/chrome/browser/importer/ie_importer_test_registry_overrider_win.h b/chrome/browser/importer/ie_importer_test_registry_overrider_win.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d282dc6432520705b53e6c820c6ea6c1ad202df9 |
--- /dev/null |
+++ b/chrome/browser/importer/ie_importer_test_registry_overrider_win.h |
@@ -0,0 +1,48 @@ |
+// Copyright (c) 2013 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_BROWSER_IMPORTER_IE_IMPORTER_TEST_REGISTRY_OVERRIDER_WIN_H_ |
+#define CHROME_BROWSER_IMPORTER_IE_IMPORTER_TEST_REGISTRY_OVERRIDER_WIN_H_ |
+ |
+#include "base/basictypes.h" |
+ |
+// A helper class to override HKEY_CURRENT_USER to point to a test key from this |
+// process' point of view. Also provides functionality (via an environment |
+// variable) to let child processes check whether they should also override. |
+// Always unsets any existing override upon being deleted. |
+class IEImporterTestRegistryOverrider { |
+ public: |
+ IEImporterTestRegistryOverrider() : override_set_by_current_process_(false) {} |
+ |
+ // Unsets any existing registry override and deletes the temporary registry |
+ // key if |override_set_by_current_process_|. |
+ ~IEImporterTestRegistryOverrider(); |
+ |
+ // Calls StartRegistryOverride() and sets an environment variable so that |
+ // future calls to StartRegistryOverrideIfNeeded() from child processes also |
+ // result in an overriden registry. |
+ // Returns false on unexpected failure. |
+ 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
|
+ |
+ // Calls StartRegistryOverride() if the environment was set by a parent |
+ // process via SetRegistryOverride(). |
+ // Returns false on unexpected failure. |
+ bool StartRegistryOverrideIfNeeded(); |
+ |
+ private: |
+ // Overrides HKCU to point to a test key from this process' point of view. |
+ // Returns false on unexpected failure. |
+ bool StartRegistryOverride(); |
+ |
+ // Whether a registry override was initiated in the current process. |
+ bool override_active_; |
robertshield
2013/04/26 19:20:53
should this be static?
gab
2013/04/29 02:00:43
See main comment.
|
+ |
+ // 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.
|
+ // the one deleting the temporary key when done). |
+ bool override_set_by_current_process_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(IEImporterTestRegistryOverrider); |
+}; |
+ |
+#endif // CHROME_BROWSER_IMPORTER_IE_IMPORTER_TEST_REGISTRY_OVERRIDER_WIN_H_ |