| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/singleton.h" | 10 #include "base/singleton.h" |
| 11 | 11 |
| 12 namespace chromeos { | 12 namespace chromeos { |
| 13 | 13 |
| 14 class CryptohomeLibrary; | 14 class CryptohomeLibrary; |
| 15 class KeyboardLibrary; | 15 class KeyboardLibrary; |
| 16 class InputMethodLibrary; | 16 class InputMethodLibrary; |
| 17 class LibraryLoader; | 17 class LibraryLoader; |
| 18 class LoginLibrary; | 18 class LoginLibrary; |
| 19 class MountLibrary; | 19 class MountLibrary; |
| 20 class NetworkLibrary; | 20 class NetworkLibrary; |
| 21 class PowerLibrary; | 21 class PowerLibrary; |
| 22 class ScreenLockLibrary; | 22 class ScreenLockLibrary; |
| 23 class SpeechSynthesisLibrary; | 23 class SpeechSynthesisLibrary; |
| 24 class SynapticsLibrary; | 24 class SynapticsLibrary; |
| 25 class SyslogsLibrary; | 25 class SyslogsLibrary; |
| 26 class SystemLibrary; | 26 class SystemLibrary; |
| 27 class UpdateLibrary; |
| 27 | 28 |
| 28 // This class handles access to sub-parts of ChromeOS library. it provides | 29 // This class handles access to sub-parts of ChromeOS library. it provides |
| 29 // a level of indirection so individual libraries that it exposes can | 30 // a level of indirection so individual libraries that it exposes can |
| 30 // be mocked for testing. | 31 // be mocked for testing. |
| 31 class CrosLibrary { | 32 class CrosLibrary { |
| 32 public: | 33 public: |
| 33 | 34 |
| 34 // This class provides access to internal members of CrosLibrary class for | 35 // This class provides access to internal members of CrosLibrary class for |
| 35 // purpose of testing (i.e. replacement of members' implementation with | 36 // purpose of testing (i.e. replacement of members' implementation with |
| 36 // mock objects). | 37 // mock objects). |
| (...skipping 20 matching lines...) Expand all Loading... |
| 57 // Setter for ScreenLockLibrary. | 58 // Setter for ScreenLockLibrary. |
| 58 void SetScreenLockLibrary(ScreenLockLibrary* library, bool own); | 59 void SetScreenLockLibrary(ScreenLockLibrary* library, bool own); |
| 59 // Setter for SpeechSynthesisLibrary. | 60 // Setter for SpeechSynthesisLibrary. |
| 60 void SetSpeechSynthesisLibrary(SpeechSynthesisLibrary* library, bool own); | 61 void SetSpeechSynthesisLibrary(SpeechSynthesisLibrary* library, bool own); |
| 61 // Setter for SynapticsLibrary. | 62 // Setter for SynapticsLibrary. |
| 62 void SetSynapticsLibrary(SynapticsLibrary* library, bool own); | 63 void SetSynapticsLibrary(SynapticsLibrary* library, bool own); |
| 63 // Setter for SyslogsLibrary. | 64 // Setter for SyslogsLibrary. |
| 64 void SetSyslogsLibrary(SyslogsLibrary* library, bool own); | 65 void SetSyslogsLibrary(SyslogsLibrary* library, bool own); |
| 65 // Setter for SystemLibrary. | 66 // Setter for SystemLibrary. |
| 66 void SetSystemLibrary(SystemLibrary* library, bool own); | 67 void SetSystemLibrary(SystemLibrary* library, bool own); |
| 68 // Setter for UpdateLibrary. |
| 69 void SetUpdateLibrary(UpdateLibrary* library, bool own); |
| 67 | 70 |
| 68 private: | 71 private: |
| 69 friend class CrosLibrary; | 72 friend class CrosLibrary; |
| 70 explicit TestApi(CrosLibrary* library) : library_(library) {} | 73 explicit TestApi(CrosLibrary* library) : library_(library) {} |
| 71 CrosLibrary* library_; | 74 CrosLibrary* library_; |
| 72 }; | 75 }; |
| 73 | 76 |
| 74 // This gets the CrosLibrary. | 77 // This gets the CrosLibrary. |
| 75 static CrosLibrary* Get(); | 78 static CrosLibrary* Get(); |
| 76 | 79 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 103 | 106 |
| 104 // This gets the singleton SynapticsLibrary. | 107 // This gets the singleton SynapticsLibrary. |
| 105 SynapticsLibrary* GetSynapticsLibrary(); | 108 SynapticsLibrary* GetSynapticsLibrary(); |
| 106 | 109 |
| 107 // This gets the singleton SyslogsLibrary. | 110 // This gets the singleton SyslogsLibrary. |
| 108 SyslogsLibrary* GetSyslogsLibrary(); | 111 SyslogsLibrary* GetSyslogsLibrary(); |
| 109 | 112 |
| 110 // This gets the singleton SystemLibrary. | 113 // This gets the singleton SystemLibrary. |
| 111 SystemLibrary* GetSystemLibrary(); | 114 SystemLibrary* GetSystemLibrary(); |
| 112 | 115 |
| 116 // This gets the singleton UpdateLibrary. |
| 117 UpdateLibrary* GetUpdateLibrary(); |
| 118 |
| 113 // Getter for Test API that gives access to internal members of this class. | 119 // Getter for Test API that gives access to internal members of this class. |
| 114 TestApi* GetTestApi(); | 120 TestApi* GetTestApi(); |
| 115 | 121 |
| 116 // Ensures that the library is loaded, loading it if needed. If the library | 122 // Ensures that the library is loaded, loading it if needed. If the library |
| 117 // could not be loaded, returns false. | 123 // could not be loaded, returns false. |
| 118 bool EnsureLoaded(); | 124 bool EnsureLoaded(); |
| 119 | 125 |
| 120 // Returns an unlocalized string describing the last load error (if any). | 126 // Returns an unlocalized string describing the last load error (if any). |
| 121 const std::string& load_error_string() { | 127 const std::string& load_error_string() { |
| 122 return load_error_string_; | 128 return load_error_string_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 135 InputMethodLibrary* input_method_lib_; | 141 InputMethodLibrary* input_method_lib_; |
| 136 LoginLibrary* login_lib_; | 142 LoginLibrary* login_lib_; |
| 137 MountLibrary* mount_lib_; | 143 MountLibrary* mount_lib_; |
| 138 NetworkLibrary* network_lib_; | 144 NetworkLibrary* network_lib_; |
| 139 PowerLibrary* power_lib_; | 145 PowerLibrary* power_lib_; |
| 140 ScreenLockLibrary* screen_lock_lib_; | 146 ScreenLockLibrary* screen_lock_lib_; |
| 141 SpeechSynthesisLibrary* speech_synthesis_lib_; | 147 SpeechSynthesisLibrary* speech_synthesis_lib_; |
| 142 SynapticsLibrary* synaptics_lib_; | 148 SynapticsLibrary* synaptics_lib_; |
| 143 SyslogsLibrary* syslogs_lib_; | 149 SyslogsLibrary* syslogs_lib_; |
| 144 SystemLibrary* system_lib_; | 150 SystemLibrary* system_lib_; |
| 151 UpdateLibrary* update_lib_; |
| 145 | 152 |
| 146 bool own_library_loader_; | 153 bool own_library_loader_; |
| 147 bool own_cryptohome_lib_; | 154 bool own_cryptohome_lib_; |
| 148 bool own_keyboard_lib_; | 155 bool own_keyboard_lib_; |
| 149 bool own_input_method_lib_; | 156 bool own_input_method_lib_; |
| 150 bool own_login_lib_; | 157 bool own_login_lib_; |
| 151 bool own_mount_lib_; | 158 bool own_mount_lib_; |
| 152 bool own_network_lib_; | 159 bool own_network_lib_; |
| 153 bool own_power_lib_; | 160 bool own_power_lib_; |
| 154 bool own_screen_lock_lib_; | 161 bool own_screen_lock_lib_; |
| 155 bool own_speech_synthesis_lib_; | 162 bool own_speech_synthesis_lib_; |
| 156 bool own_synaptics_lib_; | 163 bool own_synaptics_lib_; |
| 157 bool own_syslogs_lib_; | 164 bool own_syslogs_lib_; |
| 158 bool own_system_lib_; | 165 bool own_system_lib_; |
| 166 bool own_update_lib_; |
| 159 | 167 |
| 160 // True if libcros was successfully loaded. | 168 // True if libcros was successfully loaded. |
| 161 bool loaded_; | 169 bool loaded_; |
| 162 // True if the last load attempt had an error. | 170 // True if the last load attempt had an error. |
| 163 bool load_error_; | 171 bool load_error_; |
| 164 // Contains the error string from the last load attempt. | 172 // Contains the error string from the last load attempt. |
| 165 std::string load_error_string_; | 173 std::string load_error_string_; |
| 166 TestApi* test_api_; | 174 TestApi* test_api_; |
| 167 | 175 |
| 168 DISALLOW_COPY_AND_ASSIGN(CrosLibrary); | 176 DISALLOW_COPY_AND_ASSIGN(CrosLibrary); |
| 169 }; | 177 }; |
| 170 | 178 |
| 171 } // namespace chromeos | 179 } // namespace chromeos |
| 172 | 180 |
| 173 #endif // CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_ | 181 #endif // CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_ |
| OLD | NEW |