Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(897)

Unified Diff: chrome/browser/chromeos/cros/cros_library.cc

Issue 3076029: Allow chrome for cros to be started with a username / password (Closed)
Patch Set: Only declare StubLogin on cros builds Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/cros/cros_library.h ('k') | chrome/browser/chromeos/cros/cryptohome_library.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/cros/cros_library.cc
diff --git a/chrome/browser/chromeos/cros/cros_library.cc b/chrome/browser/chromeos/cros/cros_library.cc
index a9e469d31b7d5518c335ea155d527301ce437e83..d31e76ee369fa78c7848021d136743fd1bffcd2c 100644
--- a/chrome/browser/chromeos/cros/cros_library.cc
+++ b/chrome/browser/chromeos/cros/cros_library.cc
@@ -22,69 +22,14 @@
namespace chromeos {
CrosLibrary::CrosLibrary() : library_loader_(NULL),
- crypto_lib_(NULL),
- keyboard_lib_(NULL),
- input_method_lib_(NULL),
- login_lib_(NULL),
- mount_lib_(NULL),
- network_lib_(NULL),
- power_lib_(NULL),
- screen_lock_lib_(NULL),
- speech_synthesis_lib_(NULL),
- synaptics_lib_(NULL),
- syslogs_lib_(NULL),
- system_lib_(NULL),
- update_lib_(NULL),
- own_library_loader_(true),
- own_cryptohome_lib_(true),
- own_keyboard_lib_(true),
- own_input_method_lib_(true),
- own_login_lib_(true),
- own_mount_lib_(true),
- own_network_lib_(true),
- own_power_lib_(true),
- own_screen_lock_lib_(true),
- own_speech_synthesis_lib_(true),
- own_synaptics_lib_(true),
- own_syslogs_lib_(true),
- own_system_lib_(true),
- own_update_lib_(true),
loaded_(false),
load_error_(false),
test_api_(NULL) {
-
}
CrosLibrary::~CrosLibrary() {
if (own_library_loader_)
delete library_loader_;
- if (own_cryptohome_lib_)
- delete crypto_lib_;
- if (own_keyboard_lib_)
- delete keyboard_lib_;
- if (own_input_method_lib_)
- delete input_method_lib_;
- if (own_login_lib_)
- delete login_lib_;
- if (own_mount_lib_)
- delete mount_lib_;
- if (own_network_lib_)
- delete network_lib_;
- if (own_power_lib_)
- delete power_lib_;
- if (own_screen_lock_lib_)
- delete screen_lock_lib_;
- if (own_speech_synthesis_lib_)
- delete speech_synthesis_lib_;
- if (own_synaptics_lib_)
- delete synaptics_lib_;
- if (own_syslogs_lib_)
- delete syslogs_lib_;
- if (own_system_lib_)
- delete system_lib_;
- if (own_update_lib_)
- delete update_lib_;
- delete test_api_;
}
// static
@@ -93,84 +38,61 @@ CrosLibrary* CrosLibrary::Get() {
}
CryptohomeLibrary* CrosLibrary::GetCryptohomeLibrary() {
- if (!crypto_lib_)
- crypto_lib_ = new CryptohomeLibraryImpl();
- return crypto_lib_;
+ return crypto_lib_.GetDefaultImpl(use_stub_impl_);
}
KeyboardLibrary* CrosLibrary::GetKeyboardLibrary() {
- if (!keyboard_lib_)
- keyboard_lib_ = new KeyboardLibraryImpl();
- return keyboard_lib_;
+ return keyboard_lib_.GetDefaultImpl(use_stub_impl_);
}
InputMethodLibrary* CrosLibrary::GetInputMethodLibrary() {
- if (!input_method_lib_)
- input_method_lib_ = new InputMethodLibraryImpl();
- return input_method_lib_;
+ return input_method_lib_.GetDefaultImpl(use_stub_impl_);
}
LoginLibrary* CrosLibrary::GetLoginLibrary() {
- if (!login_lib_)
- login_lib_ = new LoginLibraryImpl();
- return login_lib_;
+ return login_lib_.GetDefaultImpl(use_stub_impl_);
}
MountLibrary* CrosLibrary::GetMountLibrary() {
- if (!mount_lib_)
- mount_lib_ = new MountLibraryImpl();
- return mount_lib_;
+ return mount_lib_.GetDefaultImpl(use_stub_impl_);
}
NetworkLibrary* CrosLibrary::GetNetworkLibrary() {
- if (!network_lib_)
- network_lib_ = new NetworkLibraryImpl();
- return network_lib_;
+ return network_lib_.GetDefaultImpl(use_stub_impl_);
}
PowerLibrary* CrosLibrary::GetPowerLibrary() {
- if (!power_lib_)
- power_lib_ = new PowerLibraryImpl();
- return power_lib_;
+ return power_lib_.GetDefaultImpl(use_stub_impl_);
}
ScreenLockLibrary* CrosLibrary::GetScreenLockLibrary() {
- if (!screen_lock_lib_)
- screen_lock_lib_ = new ScreenLockLibraryImpl();
- return screen_lock_lib_;
+ return screen_lock_lib_.GetDefaultImpl(use_stub_impl_);
}
SpeechSynthesisLibrary* CrosLibrary::GetSpeechSynthesisLibrary() {
- if (!speech_synthesis_lib_)
- speech_synthesis_lib_ = new SpeechSynthesisLibraryImpl();
- return speech_synthesis_lib_;
+ return speech_synthesis_lib_.GetDefaultImpl(use_stub_impl_);
}
SynapticsLibrary* CrosLibrary::GetSynapticsLibrary() {
- if (!synaptics_lib_)
- synaptics_lib_ = new SynapticsLibraryImpl();
- return synaptics_lib_;
+ return synaptics_lib_.GetDefaultImpl(use_stub_impl_);
}
SyslogsLibrary* CrosLibrary::GetSyslogsLibrary() {
- if (!syslogs_lib_)
- syslogs_lib_ = new SyslogsLibraryImpl();
- return syslogs_lib_;
+ return syslogs_lib_.GetDefaultImpl(use_stub_impl_);
}
SystemLibrary* CrosLibrary::GetSystemLibrary() {
- if (!system_lib_)
- system_lib_ = new SystemLibraryImpl();
- return system_lib_;
+ return system_lib_.GetDefaultImpl(use_stub_impl_);
}
UpdateLibrary* CrosLibrary::GetUpdateLibrary() {
- if (!update_lib_)
- update_lib_ = new UpdateLibraryImpl();
- return update_lib_;
+ return update_lib_.GetDefaultImpl(use_stub_impl_);
}
bool CrosLibrary::EnsureLoaded() {
+ if (use_stub_impl_)
+ return true;
+
if (!loaded_ && !load_error_) {
if (!library_loader_)
library_loader_ = new CrosLibraryLoader();
@@ -186,6 +108,10 @@ CrosLibrary::TestApi* CrosLibrary::GetTestApi() {
return test_api_;
}
+void CrosLibrary::TestApi::SetUseStubImpl() {
+ library_->use_stub_impl_ = true;
+}
+
void CrosLibrary::TestApi::SetLibraryLoader(LibraryLoader* loader, bool own) {
if (library_->library_loader_ == loader)
return;
@@ -199,105 +125,69 @@ void CrosLibrary::TestApi::SetLibraryLoader(LibraryLoader* loader, bool own) {
library_->load_error_ = false;
}
-void CrosLibrary::TestApi::SetCryptohomeLibrary(CryptohomeLibrary* library,
- bool own) {
- if (library_->own_cryptohome_lib_)
- delete library_->crypto_lib_;
- library_->own_cryptohome_lib_ = own;
- library_->crypto_lib_ = library;
+void CrosLibrary::TestApi::SetCryptohomeLibrary(
+ CryptohomeLibrary* library, bool own) {
+ library_->crypto_lib_.SetImpl(library, own);
}
-void CrosLibrary::TestApi::SetKeyboardLibrary(KeyboardLibrary* library,
- bool own) {
- if (library_->own_keyboard_lib_)
- delete library_->keyboard_lib_;
- library_->own_keyboard_lib_ = own;
- library_->keyboard_lib_ = library;
+void CrosLibrary::TestApi::SetKeyboardLibrary(
+ KeyboardLibrary* library, bool own) {
+ library_->keyboard_lib_.SetImpl(library, own);
}
-void CrosLibrary::TestApi::SetInputMethodLibrary(InputMethodLibrary* library,
- bool own) {
- if (library_->own_input_method_lib_)
- delete library_->input_method_lib_;
- library_->own_input_method_lib_ = own;
- library_->input_method_lib_ = library;
+void CrosLibrary::TestApi::SetInputMethodLibrary(
+ InputMethodLibrary* library, bool own) {
+ library_->input_method_lib_.SetImpl(library, own);
}
-void CrosLibrary::TestApi::SetLoginLibrary(LoginLibrary* library, bool own) {
- if (library_->own_login_lib_)
- delete library_->login_lib_;
- library_->own_login_lib_ = own;
- library_->login_lib_ = library;
+void CrosLibrary::TestApi::SetLoginLibrary(
+ LoginLibrary* library, bool own) {
+ library_->login_lib_.SetImpl(library, own);
}
-void CrosLibrary::TestApi::SetMountLibrary(MountLibrary* library, bool own) {
- if (library_->own_mount_lib_)
- delete library_->mount_lib_;
- library_->own_mount_lib_ = own;
- library_->mount_lib_ = library;
+void CrosLibrary::TestApi::SetMountLibrary(
+ MountLibrary* library, bool own) {
+ library_->mount_lib_.SetImpl(library, own);
}
-void CrosLibrary::TestApi::SetNetworkLibrary(NetworkLibrary* library,
- bool own) {
- if (library_->own_network_lib_)
- delete library_->network_lib_;
- library_->own_network_lib_ = own;
- library_->network_lib_ = library;
+void CrosLibrary::TestApi::SetNetworkLibrary(
+ NetworkLibrary* library, bool own) {
+ library_->network_lib_.SetImpl(library, own);
}
-void CrosLibrary::TestApi::SetPowerLibrary(PowerLibrary* library, bool own) {
- if (library_->own_power_lib_)
- delete library_->power_lib_;
- library_->own_power_lib_ = own;
- library_->power_lib_ = library;
+void CrosLibrary::TestApi::SetPowerLibrary(
+ PowerLibrary* library, bool own) {
+ library_->power_lib_.SetImpl(library, own);
}
-void CrosLibrary::TestApi::SetScreenLockLibrary(ScreenLockLibrary* library,
- bool own) {
- if (library_->own_screen_lock_lib_)
- delete library_->screen_lock_lib_;
- library_->own_screen_lock_lib_ = own;
- library_->screen_lock_lib_ = library;
+void CrosLibrary::TestApi::SetScreenLockLibrary(
+ ScreenLockLibrary* library, bool own) {
+ library_->screen_lock_lib_.SetImpl(library, own);
}
void CrosLibrary::TestApi::SetSpeechSynthesisLibrary(
SpeechSynthesisLibrary* library, bool own) {
- if (library_->own_speech_synthesis_lib_)
- delete library_->speech_synthesis_lib_;
- library_->own_speech_synthesis_lib_ = own;
- library_->speech_synthesis_lib_ = library;
-}
-
-void CrosLibrary::TestApi::SetSynapticsLibrary(SynapticsLibrary* library,
- bool own) {
- if (library_->own_synaptics_lib_)
- delete library_->synaptics_lib_;
- library_->own_synaptics_lib_ = own;
- library_->synaptics_lib_ = library;
-}
-
-void CrosLibrary::TestApi::SetSyslogsLibrary(SyslogsLibrary* library,
- bool own) {
- if (library_->syslogs_lib_)
- delete library_->syslogs_lib_;
- library_->own_syslogs_lib_ = own;
- library_->syslogs_lib_ = library;
-}
-
-void CrosLibrary::TestApi::SetSystemLibrary(SystemLibrary* library,
- bool own) {
- if (library_->system_lib_)
- delete library_->system_lib_;
- library_->own_system_lib_ = own;
- library_->system_lib_ = library;
-}
-
-void CrosLibrary::TestApi::SetUpdateLibrary(UpdateLibrary* library,
- bool own) {
- if (library_->update_lib_)
- delete library_->update_lib_;
- library_->own_update_lib_ = own;
- library_->update_lib_ = library;
+ library_->speech_synthesis_lib_.SetImpl(library, own);
+}
+
+void CrosLibrary::TestApi::SetSynapticsLibrary(
+ SynapticsLibrary* library, bool own) {
+ library_->synaptics_lib_.SetImpl(library, own);
+}
+
+void CrosLibrary::TestApi::SetSyslogsLibrary(
+ SyslogsLibrary* library, bool own) {
+ library_->syslogs_lib_.SetImpl(library, own);
+}
+
+void CrosLibrary::TestApi::SetSystemLibrary(
+ SystemLibrary* library, bool own) {
+ library_->system_lib_.SetImpl(library, own);
+}
+
+void CrosLibrary::TestApi::SetUpdateLibrary(
+ UpdateLibrary* library, bool own) {
+ library_->update_lib_.SetImpl(library, own);
}
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/cros/cros_library.h ('k') | chrome/browser/chromeos/cros/cryptohome_library.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698