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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "base/singleton.h" | 12 #include "base/singleton.h" |
13 namespace chromeos { | 13 namespace chromeos { |
14 | 14 |
| 15 class BurnLibrary; |
15 class CryptohomeLibrary; | 16 class CryptohomeLibrary; |
16 class KeyboardLibrary; | 17 class KeyboardLibrary; |
17 class InputMethodLibrary; | 18 class InputMethodLibrary; |
18 class LibraryLoader; | 19 class LibraryLoader; |
19 class LoginLibrary; | 20 class LoginLibrary; |
20 class MountLibrary; | 21 class MountLibrary; |
21 class NetworkLibrary; | 22 class NetworkLibrary; |
22 class PowerLibrary; | 23 class PowerLibrary; |
23 class ScreenLockLibrary; | 24 class ScreenLockLibrary; |
24 class SpeechSynthesisLibrary; | 25 class SpeechSynthesisLibrary; |
(...skipping 12 matching lines...) Expand all Loading... |
37 // mock objects). | 38 // mock objects). |
38 class TestApi { | 39 class TestApi { |
39 public: | 40 public: |
40 // Use the stub implementations of the library. This is mainly for | 41 // Use the stub implementations of the library. This is mainly for |
41 // running the chromeos build of chrome on the desktop. | 42 // running the chromeos build of chrome on the desktop. |
42 void SetUseStubImpl(); | 43 void SetUseStubImpl(); |
43 // Passing true for own for these setters will cause them to be deleted | 44 // Passing true for own for these setters will cause them to be deleted |
44 // when the CrosLibrary is deleted (or other mocks are set). | 45 // when the CrosLibrary is deleted (or other mocks are set). |
45 // Setter for LibraryLoader. | 46 // Setter for LibraryLoader. |
46 void SetLibraryLoader(LibraryLoader* loader, bool own); | 47 void SetLibraryLoader(LibraryLoader* loader, bool own); |
| 48 // Setter for BurnLibrary. |
| 49 void SetBurnLibrary(BurnLibrary* library, bool own); |
47 // Setter for CryptohomeLibrary. | 50 // Setter for CryptohomeLibrary. |
48 void SetCryptohomeLibrary(CryptohomeLibrary* library, bool own); | 51 void SetCryptohomeLibrary(CryptohomeLibrary* library, bool own); |
49 // Setter for KeyboardLibrary | 52 // Setter for KeyboardLibrary |
50 void SetKeyboardLibrary(KeyboardLibrary* library, bool own); | 53 void SetKeyboardLibrary(KeyboardLibrary* library, bool own); |
51 // Setter for InputMethodLibrary | 54 // Setter for InputMethodLibrary |
52 void SetInputMethodLibrary(InputMethodLibrary* library, bool own); | 55 void SetInputMethodLibrary(InputMethodLibrary* library, bool own); |
53 // Setter for LoginLibrary. | 56 // Setter for LoginLibrary. |
54 void SetLoginLibrary(LoginLibrary* library, bool own); | 57 void SetLoginLibrary(LoginLibrary* library, bool own); |
55 // Setter for MountLibrary. | 58 // Setter for MountLibrary. |
56 void SetMountLibrary(MountLibrary* library, bool own); | 59 void SetMountLibrary(MountLibrary* library, bool own); |
(...skipping 16 matching lines...) Expand all Loading... |
73 | 76 |
74 private: | 77 private: |
75 friend class CrosLibrary; | 78 friend class CrosLibrary; |
76 explicit TestApi(CrosLibrary* library) : library_(library) {} | 79 explicit TestApi(CrosLibrary* library) : library_(library) {} |
77 CrosLibrary* library_; | 80 CrosLibrary* library_; |
78 }; | 81 }; |
79 | 82 |
80 // This gets the CrosLibrary. | 83 // This gets the CrosLibrary. |
81 static CrosLibrary* Get(); | 84 static CrosLibrary* Get(); |
82 | 85 |
| 86 // Getter for BurnLibrary. |
| 87 BurnLibrary* GetBurnLibrary(); |
| 88 |
83 // Getter for CryptohomeLibrary. | 89 // Getter for CryptohomeLibrary. |
84 CryptohomeLibrary* GetCryptohomeLibrary(); | 90 CryptohomeLibrary* GetCryptohomeLibrary(); |
85 | 91 |
86 // Getter for KeyboardLibrary | 92 // Getter for KeyboardLibrary |
87 KeyboardLibrary* GetKeyboardLibrary(); | 93 KeyboardLibrary* GetKeyboardLibrary(); |
88 | 94 |
89 // Getter for InputMethodLibrary | 95 // Getter for InputMethodLibrary |
90 InputMethodLibrary* GetInputMethodLibrary(); | 96 InputMethodLibrary* GetInputMethodLibrary(); |
91 | 97 |
92 // Getter for LoginLibrary. | 98 // Getter for LoginLibrary. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 138 } |
133 | 139 |
134 private: | 140 private: |
135 friend struct DefaultSingletonTraits<chromeos::CrosLibrary>; | 141 friend struct DefaultSingletonTraits<chromeos::CrosLibrary>; |
136 friend class CrosLibrary::TestApi; | 142 friend class CrosLibrary::TestApi; |
137 | 143 |
138 CrosLibrary(); | 144 CrosLibrary(); |
139 virtual ~CrosLibrary(); | 145 virtual ~CrosLibrary(); |
140 | 146 |
141 LibraryLoader* library_loader_; | 147 LibraryLoader* library_loader_; |
| 148 |
142 bool own_library_loader_; | 149 bool own_library_loader_; |
143 | 150 |
144 // This template supports the creation, setting and optional deletion of | 151 // This template supports the creation, setting and optional deletion of |
145 // the cros libraries. | 152 // the cros libraries. |
146 template <class L> | 153 template <class L> |
147 class Library { | 154 class Library { |
148 public: | 155 public: |
149 Library() : library_(NULL), own_(true) {} | 156 Library() : library_(NULL), own_(true) {} |
150 | 157 |
151 ~Library() { | 158 ~Library() { |
(...skipping 16 matching lines...) Expand all Loading... |
168 library_ = library; | 175 library_ = library; |
169 own_ = own; | 176 own_ = own; |
170 } | 177 } |
171 } | 178 } |
172 | 179 |
173 private: | 180 private: |
174 L* library_; | 181 L* library_; |
175 bool own_; | 182 bool own_; |
176 }; | 183 }; |
177 | 184 |
| 185 Library<BurnLibrary> burn_lib_; |
178 Library<CryptohomeLibrary> crypto_lib_; | 186 Library<CryptohomeLibrary> crypto_lib_; |
179 Library<KeyboardLibrary> keyboard_lib_; | 187 Library<KeyboardLibrary> keyboard_lib_; |
180 Library<InputMethodLibrary> input_method_lib_; | 188 Library<InputMethodLibrary> input_method_lib_; |
181 Library<LoginLibrary> login_lib_; | 189 Library<LoginLibrary> login_lib_; |
182 Library<MountLibrary> mount_lib_; | 190 Library<MountLibrary> mount_lib_; |
183 Library<NetworkLibrary> network_lib_; | 191 Library<NetworkLibrary> network_lib_; |
184 Library<PowerLibrary> power_lib_; | 192 Library<PowerLibrary> power_lib_; |
185 Library<ScreenLockLibrary> screen_lock_lib_; | 193 Library<ScreenLockLibrary> screen_lock_lib_; |
186 Library<SpeechSynthesisLibrary> speech_synthesis_lib_; | 194 Library<SpeechSynthesisLibrary> speech_synthesis_lib_; |
187 Library<SynapticsLibrary> synaptics_lib_; | 195 Library<SynapticsLibrary> synaptics_lib_; |
(...skipping 10 matching lines...) Expand all Loading... |
198 // Contains the error string from the last load attempt. | 206 // Contains the error string from the last load attempt. |
199 std::string load_error_string_; | 207 std::string load_error_string_; |
200 scoped_ptr<TestApi> test_api_; | 208 scoped_ptr<TestApi> test_api_; |
201 | 209 |
202 DISALLOW_COPY_AND_ASSIGN(CrosLibrary); | 210 DISALLOW_COPY_AND_ASSIGN(CrosLibrary); |
203 }; | 211 }; |
204 | 212 |
205 } // namespace chromeos | 213 } // namespace chromeos |
206 | 214 |
207 #endif // CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_ | 215 #endif // CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_ |
OLD | NEW |