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.
5 #include "chromeos/network/network_handler.h"
7 #include "base/threading/worker_pool.h"
8 #include "chromeos/dbus/dbus_thread_manager.h"
9 #include "chromeos/network/auto_connect_handler.h"
10 #include "chromeos/network/client_cert_resolver.h"
11 #include "chromeos/network/geolocation_handler.h"
12 #include "chromeos/network/managed_network_configuration_handler_impl.h"
13 #include "chromeos/network/network_activation_handler.h"
14 #include "chromeos/network/network_cert_migrator.h"
15 #include "chromeos/network/network_configuration_handler.h"
16 #include "chromeos/network/network_connection_handler.h"
17 #include "chromeos/network/network_device_handler_impl.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"
26 static NetworkHandler
* g_network_handler
= NULL
;
28 NetworkHandler::NetworkHandler()
29 : message_loop_(base::MessageLoopProxy::current()) {
30 CHECK(DBusThreadManager::IsInitialized());
32 network_state_handler_
.reset(new NetworkStateHandler());
33 network_device_handler_
.reset(new NetworkDeviceHandlerImpl());
34 network_profile_handler_
.reset(new NetworkProfileHandler());
35 network_configuration_handler_
.reset(new NetworkConfigurationHandler());
36 managed_network_configuration_handler_
.reset(
37 new ManagedNetworkConfigurationHandlerImpl());
38 if (CertLoader::IsInitialized()) {
39 auto_connect_handler_
.reset(new AutoConnectHandler());
40 network_cert_migrator_
.reset(new NetworkCertMigrator());
41 client_cert_resolver_
.reset(new ClientCertResolver());
43 network_activation_handler_
.reset(new NetworkActivationHandler());
44 network_connection_handler_
.reset(new NetworkConnectionHandler());
45 network_sms_handler_
.reset(new NetworkSmsHandler());
46 geolocation_handler_
.reset(new GeolocationHandler());
49 NetworkHandler::~NetworkHandler() {
52 void NetworkHandler::Init() {
53 network_state_handler_
->InitShillPropertyHandler();
54 network_device_handler_
->Init(network_state_handler_
.get());
55 network_profile_handler_
->Init();
56 network_configuration_handler_
->Init(network_state_handler_
.get(),
57 network_device_handler_
.get());
58 managed_network_configuration_handler_
->Init(
59 network_state_handler_
.get(),
60 network_profile_handler_
.get(),
61 network_configuration_handler_
.get(),
62 network_device_handler_
.get());
63 network_connection_handler_
->Init(
64 network_state_handler_
.get(),
65 network_configuration_handler_
.get(),
66 managed_network_configuration_handler_
.get());
67 if (network_cert_migrator_
)
68 network_cert_migrator_
->Init(network_state_handler_
.get());
69 if (client_cert_resolver_
) {
70 client_cert_resolver_
->Init(network_state_handler_
.get(),
71 managed_network_configuration_handler_
.get());
73 if (auto_connect_handler_
) {
74 auto_connect_handler_
->Init(client_cert_resolver_
.get(),
75 network_connection_handler_
.get(),
76 network_state_handler_
.get(),
77 managed_network_configuration_handler_
.get());
79 network_sms_handler_
->Init();
80 geolocation_handler_
->Init();
84 void NetworkHandler::Initialize() {
85 CHECK(!g_network_handler
);
86 g_network_handler
= new NetworkHandler();
87 g_network_handler
->Init();
91 void NetworkHandler::Shutdown() {
92 CHECK(g_network_handler
);
93 delete g_network_handler
;
94 g_network_handler
= NULL
;
98 NetworkHandler
* NetworkHandler::Get() {
99 CHECK(g_network_handler
)
100 << "NetworkHandler::Get() called before Initialize()";
101 return g_network_handler
;
105 bool NetworkHandler::IsInitialized() {
106 return g_network_handler
;
109 NetworkStateHandler
* NetworkHandler::network_state_handler() {
110 return network_state_handler_
.get();
113 NetworkDeviceHandler
* NetworkHandler::network_device_handler() {
114 return network_device_handler_
.get();
117 NetworkProfileHandler
* NetworkHandler::network_profile_handler() {
118 return network_profile_handler_
.get();
121 NetworkConfigurationHandler
* NetworkHandler::network_configuration_handler() {
122 return network_configuration_handler_
.get();
125 ManagedNetworkConfigurationHandler
*
126 NetworkHandler::managed_network_configuration_handler() {
127 return managed_network_configuration_handler_
.get();
130 NetworkActivationHandler
* NetworkHandler::network_activation_handler() {
131 return network_activation_handler_
.get();
134 NetworkConnectionHandler
* NetworkHandler::network_connection_handler() {
135 return network_connection_handler_
.get();
138 NetworkSmsHandler
* NetworkHandler::network_sms_handler() {
139 return network_sms_handler_
.get();
142 GeolocationHandler
* NetworkHandler::geolocation_handler() {
143 return geolocation_handler_
.get();
146 } // namespace chromeos