OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_FRAME_TEST_UTILS_H_ | 5 #ifndef CHROME_FRAME_TEST_UTILS_H_ |
6 #define CHROME_FRAME_TEST_UTILS_H_ | 6 #define CHROME_FRAME_TEST_UTILS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include <atlbase.h> | 10 #include <atlbase.h> |
11 #include <atlcom.h> | 11 #include <atlcom.h> |
12 | 12 |
| 13 #include "base/string16.h" |
| 14 |
13 class FilePath; | 15 class FilePath; |
14 | 16 |
15 extern const wchar_t kChromeFrameDllName[]; | 17 extern const wchar_t kChromeFrameDllName[]; |
16 extern const wchar_t kChromeLauncherExeName[]; | 18 extern const wchar_t kChromeLauncherExeName[]; |
17 | 19 |
18 // Helper class used to register different chrome frame DLLs while running | 20 // Helper class used to register different chrome frame DLLs while running |
19 // tests. The default constructor registers the DLL found in the build path. | 21 // tests. The default constructor registers the DLL found in the build path. |
20 | 22 // Programs that use this class MUST include a call to the class's |
| 23 // RegisterAndExitProcessIfDirected method at the top of their main entrypoint. |
| 24 // |
21 // At destruction, again registers the DLL found in the build path if another | 25 // At destruction, again registers the DLL found in the build path if another |
22 // DLL has since been registered. Triggers GTEST asserts on failure. | 26 // DLL has since been registered. Triggers GTEST asserts on failure. |
23 // | 27 // |
24 // TODO(robertshield): Ideally, make this class restore the originally | 28 // TODO(robertshield): Ideally, make this class restore the originally |
25 // registered chrome frame DLL (e.g. by looking in HKCR) on destruction. | 29 // registered chrome frame DLL (e.g. by looking in HKCR) on destruction. |
26 class ScopedChromeFrameRegistrar { | 30 class ScopedChromeFrameRegistrar { |
27 public: | 31 public: |
28 enum RegistrationType { | 32 enum RegistrationType { |
29 PER_USER, | 33 PER_USER, |
30 SYSTEM_LEVEL, | 34 SYSTEM_LEVEL, |
(...skipping 10 matching lines...) Expand all Loading... |
41 | 45 |
42 std::wstring GetChromeFrameDllPath() const; | 46 std::wstring GetChromeFrameDllPath() const; |
43 | 47 |
44 static void RegisterAtPath(const std::wstring& path, | 48 static void RegisterAtPath(const std::wstring& path, |
45 RegistrationType registration_type); | 49 RegistrationType registration_type); |
46 static void UnregisterAtPath(const std::wstring& path, | 50 static void UnregisterAtPath(const std::wstring& path, |
47 RegistrationType registration_type); | 51 RegistrationType registration_type); |
48 static void RegisterDefaults(); | 52 static void RegisterDefaults(); |
49 static FilePath GetReferenceChromeFrameDllPath(); | 53 static FilePath GetReferenceChromeFrameDllPath(); |
50 | 54 |
| 55 // Registers or unregisters a COM DLL and exits the process if the process's |
| 56 // command line is: |
| 57 // this.exe --call-registration-entrypoint path_to_dll entrypoint |
| 58 // Otherwise simply returns. This method should be invoked at the start of the |
| 59 // entrypoint in each executable that uses ScopedChromeFrameRegistrar to |
| 60 // register or unregister DLLs. |
| 61 static void RegisterAndExitProcessIfDirected(); |
| 62 |
51 private: | 63 private: |
| 64 enum RegistrationOperation { |
| 65 REGISTER, |
| 66 UNREGISTER, |
| 67 }; |
| 68 |
| 69 // The string "--call-registration-entrypoint". |
| 70 static const wchar_t kCallRegistrationEntrypointSwitch[]; |
| 71 |
| 72 static void DoRegistration(const string16& path, |
| 73 RegistrationType registration_type, |
| 74 RegistrationOperation registration_operation); |
| 75 |
52 // Contains the path of the most recently registered Chrome Frame DLL. | 76 // Contains the path of the most recently registered Chrome Frame DLL. |
53 std::wstring new_chrome_frame_dll_path_; | 77 std::wstring new_chrome_frame_dll_path_; |
54 | 78 |
55 // Contains the path of the Chrome Frame DLL to be registered at destruction. | 79 // Contains the path of the Chrome Frame DLL to be registered at destruction. |
56 std::wstring original_dll_path_; | 80 std::wstring original_dll_path_; |
57 | 81 |
58 // Indicates whether per user or per machine registration is needed. | 82 // Indicates whether per user or per machine registration is needed. |
59 RegistrationType registration_type_; | 83 RegistrationType registration_type_; |
60 // We need to register the chrome path provider only once per process. This | 84 // We need to register the chrome path provider only once per process. This |
61 // flag keeps track of that. | 85 // flag keeps track of that. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // Kills all running processes named |process_name| that have the string | 129 // Kills all running processes named |process_name| that have the string |
106 // |argument| on their command line. Useful for killing all Chrome Frame | 130 // |argument| on their command line. Useful for killing all Chrome Frame |
107 // instances of Chrome that all have --chrome-frame in their command line. | 131 // instances of Chrome that all have --chrome-frame in their command line. |
108 bool KillAllNamedProcessesWithArgument(const std::wstring& process_name, | 132 bool KillAllNamedProcessesWithArgument(const std::wstring& process_name, |
109 const std::wstring& argument); | 133 const std::wstring& argument); |
110 | 134 |
111 // If the workstation is locked and cannot receive user input. | 135 // If the workstation is locked and cannot receive user input. |
112 bool IsWorkstationLocked(); | 136 bool IsWorkstationLocked(); |
113 | 137 |
114 #endif // CHROME_FRAME_TEST_UTILS_H_ | 138 #endif // CHROME_FRAME_TEST_UTILS_H_ |
OLD | NEW |