Index: chromeos/network/managed_network_configuration_handler.cc |
diff --git a/chromeos/network/managed_network_configuration_handler.cc b/chromeos/network/managed_network_configuration_handler.cc |
index ea772f6b923f2d402ad3e721cbb5b89d538bed2e..685ca1dc22e8568c6eec999f1fb33b6a016a8c49 100644 |
--- a/chromeos/network/managed_network_configuration_handler.cc |
+++ b/chromeos/network/managed_network_configuration_handler.cc |
@@ -316,35 +316,6 @@ void TranslatePropertiesToOncAndRunCallback( |
} // namespace |
-static ManagedNetworkConfigurationHandler* |
-g_configuration_handler_instance = NULL; |
- |
-// static |
-void ManagedNetworkConfigurationHandler::Initialize( |
- NetworkProfileHandler* profile_handler) { |
- CHECK(!g_configuration_handler_instance); |
- g_configuration_handler_instance = |
- new ManagedNetworkConfigurationHandler(profile_handler); |
-} |
- |
-// static |
-bool ManagedNetworkConfigurationHandler::IsInitialized() { |
- return g_configuration_handler_instance; |
-} |
- |
-// static |
-void ManagedNetworkConfigurationHandler::Shutdown() { |
- CHECK(g_configuration_handler_instance); |
- delete g_configuration_handler_instance; |
- g_configuration_handler_instance = NULL; |
-} |
- |
-// static |
-ManagedNetworkConfigurationHandler* ManagedNetworkConfigurationHandler::Get() { |
- CHECK(g_configuration_handler_instance); |
- return g_configuration_handler_instance; |
-} |
- |
void ManagedNetworkConfigurationHandler::GetManagedProperties( |
const std::string& userhash, |
const std::string& service_path, |
@@ -357,7 +328,7 @@ void ManagedNetworkConfigurationHandler::GetManagedProperties( |
error_callback); |
return; |
} |
- NetworkConfigurationHandler::Get()->GetProperties( |
+ NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
service_path, |
base::Bind( |
&ManagedNetworkConfigurationHandler::GetManagedPropertiesCallback, |
@@ -375,8 +346,8 @@ void ManagedNetworkConfigurationHandler::GetManagedPropertiesCallback( |
std::string profile_path; |
shill_properties.GetStringWithoutPathExpansion(flimflam::kProfileProperty, |
&profile_path); |
- const NetworkProfile* profile = |
- profile_handler_->GetProfileForPath(profile_path); |
+ const NetworkProfile* profile = NetworkHandler::Get()-> |
+ network_profile_handler()->GetProfileForPath(profile_path); |
if (!profile) { |
VLOG(1) << "No or no known profile received for service " |
<< service_path << "."; |
@@ -447,7 +418,7 @@ void ManagedNetworkConfigurationHandler::GetProperties( |
const std::string& service_path, |
const network_handler::DictionaryResultCallback& callback, |
const network_handler::ErrorCallback& error_callback) const { |
- NetworkConfigurationHandler::Get()->GetProperties( |
+ NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
service_path, |
base::Bind(&TranslatePropertiesToOncAndRunCallback, callback), |
error_callback); |
@@ -458,8 +429,8 @@ void ManagedNetworkConfigurationHandler::SetProperties( |
const base::DictionaryValue& user_settings, |
const base::Closure& callback, |
const network_handler::ErrorCallback& error_callback) const { |
- const NetworkState* state = |
- NetworkStateHandler::Get()->GetNetworkState(service_path); |
+ const NetworkState* state = NetworkHandler::Get()->network_state_handler()-> |
+ GetNetworkState(service_path); |
if (!state) { |
RunErrorCallback(service_path, |
@@ -482,8 +453,8 @@ void ManagedNetworkConfigurationHandler::SetProperties( |
} |
const std::string& profile_path = state->profile_path(); |
- const NetworkProfile *profile = |
- profile_handler_->GetProfileForPath(profile_path); |
+ const NetworkProfile *profile = NetworkHandler::Get()-> |
+ network_profile_handler()->GetProfileForPath(profile_path); |
if (!profile) { |
RunErrorCallback(service_path, |
kUnknownProfilePath, |
@@ -534,28 +505,24 @@ void ManagedNetworkConfigurationHandler::SetProperties( |
scoped_ptr<base::DictionaryValue> shill_dictionary( |
CreateShillConfiguration(*profile, guid, policy, &user_settings)); |
- NetworkConfigurationHandler::Get()->SetProperties(service_path, |
- *shill_dictionary, |
- callback, |
- error_callback); |
+ NetworkHandler::Get()->network_configuration_handler()->SetProperties( |
+ service_path, *shill_dictionary, callback, error_callback); |
} |
void ManagedNetworkConfigurationHandler::Connect( |
const std::string& service_path, |
const base::Closure& callback, |
const network_handler::ErrorCallback& error_callback) const { |
- NetworkConfigurationHandler::Get()->Connect(service_path, |
- callback, |
- error_callback); |
+ NetworkHandler::Get()->network_configuration_handler()->Connect( |
+ service_path, callback, error_callback); |
} |
void ManagedNetworkConfigurationHandler::Disconnect( |
const std::string& service_path, |
const base::Closure& callback, |
const network_handler::ErrorCallback& error_callback) const { |
- NetworkConfigurationHandler::Get()->Disconnect(service_path, |
- callback, |
- error_callback); |
+ NetworkHandler::Get()->network_configuration_handler()->Disconnect( |
+ service_path, callback, error_callback); |
} |
void ManagedNetworkConfigurationHandler::CreateConfiguration( |
@@ -579,8 +546,8 @@ void ManagedNetworkConfigurationHandler::CreateConfiguration( |
error_callback); |
} |
- const NetworkProfile* profile = |
- profile_handler_->GetProfileForUserhash(userhash); |
+ const NetworkProfile* profile = NetworkHandler::Get()-> |
+ network_profile_handler()->GetProfileForUserhash(userhash); |
if (!profile) { |
RunErrorCallback("", |
kProfileNotInitialized, |
@@ -599,18 +566,16 @@ void ManagedNetworkConfigurationHandler::CreateConfiguration( |
CreateShillConfiguration(*profile, guid, NULL /*no policy*/, |
&properties)); |
- NetworkConfigurationHandler::Get()->CreateConfiguration(*shill_dictionary, |
- callback, |
- error_callback); |
+ NetworkHandler::Get()->network_configuration_handler()->CreateConfiguration( |
+ *shill_dictionary, callback, error_callback); |
} |
void ManagedNetworkConfigurationHandler::RemoveConfiguration( |
const std::string& service_path, |
const base::Closure& callback, |
const network_handler::ErrorCallback& error_callback) const { |
- NetworkConfigurationHandler::Get()->RemoveConfiguration(service_path, |
- callback, |
- error_callback); |
+ NetworkHandler::Get()->network_configuration_handler()->RemoveConfiguration( |
+ service_path, callback, error_callback); |
} |
// This class compares (entry point is Run()) |modified_policies| with the |
@@ -757,10 +722,10 @@ class ManagedNetworkConfigurationHandler::PolicyApplicator |
scoped_ptr<base::DictionaryValue> shill_dictionary = |
CreateShillConfiguration(profile_, new_guid, new_policy, |
ui_data->user_settings()); |
- NetworkConfigurationHandler::Get()->CreateConfiguration( |
- *shill_dictionary, |
- base::Bind(&IgnoreString), |
- base::Bind(&LogErrorWithDict, FROM_HERE)); |
+ NetworkHandler::Get()->network_configuration_handler()-> |
+ CreateConfiguration(*shill_dictionary, |
+ base::Bind(&IgnoreString), |
+ base::Bind(&LogErrorWithDict, FROM_HERE)); |
remaining_policies_.erase(new_guid); |
} |
} else if (was_managed) { |
@@ -822,10 +787,10 @@ class ManagedNetworkConfigurationHandler::PolicyApplicator |
scoped_ptr<base::DictionaryValue> shill_dictionary = |
CreateShillConfiguration(profile_, *it, policy, |
NULL /* no user settings */); |
- NetworkConfigurationHandler::Get()->CreateConfiguration( |
- *shill_dictionary, |
- base::Bind(&IgnoreString), |
- base::Bind(&LogErrorWithDict, FROM_HERE)); |
+ NetworkHandler::Get()->network_configuration_handler()-> |
+ CreateConfiguration(*shill_dictionary, |
+ base::Bind(&IgnoreString), |
+ base::Bind(&LogErrorWithDict, FROM_HERE)); |
} |
} |
@@ -880,8 +845,8 @@ void ManagedNetworkConfigurationHandler::SetPolicy( |
STLDeleteValues(&old_policies); |
- const NetworkProfile* profile = |
- profile_handler_->GetProfileForUserhash(userhash); |
+ const NetworkProfile* profile = NetworkHandler::Get()-> |
+ network_profile_handler()->GetProfileForUserhash(userhash); |
if (!profile) { |
VLOG(1) << "The relevant Shill profile isn't initialized yet, postponing " |
<< "policy application."; |
@@ -941,19 +906,20 @@ ManagedNetworkConfigurationHandler::GetPoliciesForProfile( |
return GetPoliciesForUser(profile.userhash); |
} |
-ManagedNetworkConfigurationHandler::ManagedNetworkConfigurationHandler( |
- NetworkProfileHandler* profile_handler) |
- : profile_handler_(profile_handler), |
- weak_ptr_factory_(this) { |
- profile_handler_->AddObserver(this); |
+ManagedNetworkConfigurationHandler::ManagedNetworkConfigurationHandler() |
+ : weak_ptr_factory_(this) { |
} |
ManagedNetworkConfigurationHandler::~ManagedNetworkConfigurationHandler() { |
- profile_handler_->RemoveObserver(this); |
+ NetworkHandler::Get()->network_profile_handler()->RemoveObserver(this); |
for (UserToPoliciesMap::iterator it = policies_by_user_.begin(); |
it != policies_by_user_.end(); ++it) { |
STLDeleteValues(&it->second); |
} |
} |
+void ManagedNetworkConfigurationHandler::Init() { |
+ NetworkHandler::Get()->network_profile_handler()->AddObserver(this); |
+} |
+ |
} // namespace chromeos |