1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "chromeos/network/network_handler.h" 6 7 #include "base/threading/worker_pool.h" 8 #include "chromeos/dbus/dbus_thread_manager.h" 9 #include "chromeos/network/client_cert_resolver.h" 10 #include "chromeos/network/geolocation_handler.h" 11 #include "chromeos/network/managed_network_configuration_handler_impl.h" 12 #include "chromeos/network/network_activation_handler.h" 13 #include "chromeos/network/network_cert_migrator.h" 14 #include "chromeos/network/network_configuration_handler.h" 15 #include "chromeos/network/network_connection_handler.h" 16 #include "chromeos/network/network_device_handler_impl.h" 17 #include "chromeos/network/network_event_log.h" 18 #include "chromeos/network/network_profile_handler.h" 19 #include "chromeos/network/network_profile_observer.h" 20 #include "chromeos/network/network_sms_handler.h" 21 #include "chromeos/network/network_state_handler.h" 22 #include "chromeos/network/network_state_handler_observer.h" 23 24 namespace chromeos { 25 26 static NetworkHandler* g_network_handler = NULL; 27 NetworkHandler()28NetworkHandler::NetworkHandler() 29 : message_loop_(base::MessageLoopProxy::current()) { 30 CHECK(DBusThreadManager::IsInitialized()); 31 32 network_event_log::Initialize(); 33 34 network_state_handler_.reset(new NetworkStateHandler()); 35 network_device_handler_.reset(new NetworkDeviceHandlerImpl()); 36 network_profile_handler_.reset(new NetworkProfileHandler()); 37 network_configuration_handler_.reset(new NetworkConfigurationHandler()); 38 managed_network_configuration_handler_.reset( 39 new ManagedNetworkConfigurationHandlerImpl()); 40 if (CertLoader::IsInitialized()) { 41 network_cert_migrator_.reset(new NetworkCertMigrator()); 42 client_cert_resolver_.reset(new ClientCertResolver()); 43 } 44 network_activation_handler_.reset(new NetworkActivationHandler()); 45 network_connection_handler_.reset(new NetworkConnectionHandler()); 46 network_sms_handler_.reset(new NetworkSmsHandler()); 47 geolocation_handler_.reset(new GeolocationHandler()); 48 } 49 ~NetworkHandler()50NetworkHandler::~NetworkHandler() { 51 network_event_log::Shutdown(); 52 } 53 Init()54void NetworkHandler::Init() { 55 network_state_handler_->InitShillPropertyHandler(); 56 network_device_handler_->Init(network_state_handler_.get()); 57 network_profile_handler_->Init(); 58 network_configuration_handler_->Init(network_state_handler_.get()); 59 managed_network_configuration_handler_->Init( 60 network_state_handler_.get(), 61 network_profile_handler_.get(), 62 network_configuration_handler_.get(), 63 network_device_handler_.get()); 64 network_connection_handler_->Init( 65 network_state_handler_.get(), 66 network_configuration_handler_.get(), 67 managed_network_configuration_handler_.get()); 68 if (network_cert_migrator_) 69 network_cert_migrator_->Init(network_state_handler_.get()); 70 if (client_cert_resolver_) { 71 client_cert_resolver_->Init(network_state_handler_.get(), 72 managed_network_configuration_handler_.get()); 73 } 74 network_sms_handler_->Init(); 75 geolocation_handler_->Init(); 76 } 77 78 // static Initialize()79void NetworkHandler::Initialize() { 80 CHECK(!g_network_handler); 81 g_network_handler = new NetworkHandler(); 82 g_network_handler->Init(); 83 } 84 85 // static Shutdown()86void NetworkHandler::Shutdown() { 87 CHECK(g_network_handler); 88 delete g_network_handler; 89 g_network_handler = NULL; 90 } 91 92 // static Get()93NetworkHandler* NetworkHandler::Get() { 94 CHECK(g_network_handler) 95 << "NetworkHandler::Get() called before Initialize()"; 96 return g_network_handler; 97 } 98 99 // static IsInitialized()100bool NetworkHandler::IsInitialized() { 101 return g_network_handler; 102 } 103 network_state_handler()104NetworkStateHandler* NetworkHandler::network_state_handler() { 105 return network_state_handler_.get(); 106 } 107 network_device_handler()108NetworkDeviceHandler* NetworkHandler::network_device_handler() { 109 return network_device_handler_.get(); 110 } 111 network_profile_handler()112NetworkProfileHandler* NetworkHandler::network_profile_handler() { 113 return network_profile_handler_.get(); 114 } 115 network_configuration_handler()116NetworkConfigurationHandler* NetworkHandler::network_configuration_handler() { 117 return network_configuration_handler_.get(); 118 } 119 120 ManagedNetworkConfigurationHandler* managed_network_configuration_handler()121NetworkHandler::managed_network_configuration_handler() { 122 return managed_network_configuration_handler_.get(); 123 } 124 network_activation_handler()125NetworkActivationHandler* NetworkHandler::network_activation_handler() { 126 return network_activation_handler_.get(); 127 } 128 network_connection_handler()129NetworkConnectionHandler* NetworkHandler::network_connection_handler() { 130 return network_connection_handler_.get(); 131 } 132 network_sms_handler()133NetworkSmsHandler* NetworkHandler::network_sms_handler() { 134 return network_sms_handler_.get(); 135 } 136 geolocation_handler()137GeolocationHandler* NetworkHandler::geolocation_handler() { 138 return geolocation_handler_.get(); 139 } 140 141 } // namespace chromeos 142