Disable app banners on ChromeOS.
[chromium-blink-merge.git] / chromeos / network / network_handler.cc
blob0ce9ff8c12058f19fcf643b9a3abc209af16f365
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/thread_task_runner_handle.h"
8 #include "base/threading/worker_pool.h"
9 #include "chromeos/dbus/dbus_thread_manager.h"
10 #include "chromeos/network/auto_connect_handler.h"
11 #include "chromeos/network/client_cert_resolver.h"
12 #include "chromeos/network/geolocation_handler.h"
13 #include "chromeos/network/managed_network_configuration_handler_impl.h"
14 #include "chromeos/network/network_activation_handler.h"
15 #include "chromeos/network/network_cert_migrator.h"
16 #include "chromeos/network/network_configuration_handler.h"
17 #include "chromeos/network/network_connection_handler.h"
18 #include "chromeos/network/network_device_handler_impl.h"
19 #include "chromeos/network/network_profile_handler.h"
20 #include "chromeos/network/network_profile_observer.h"
21 #include "chromeos/network/network_sms_handler.h"
22 #include "chromeos/network/network_state_handler.h"
23 #include "chromeos/network/network_state_handler_observer.h"
25 namespace chromeos {
27 static NetworkHandler* g_network_handler = NULL;
29 NetworkHandler::NetworkHandler()
30 : task_runner_(base::ThreadTaskRunnerHandle::Get()) {
31 CHECK(DBusThreadManager::IsInitialized());
33 network_state_handler_.reset(new NetworkStateHandler());
34 network_device_handler_.reset(new NetworkDeviceHandlerImpl());
35 network_profile_handler_.reset(new NetworkProfileHandler());
36 network_configuration_handler_.reset(new NetworkConfigurationHandler());
37 managed_network_configuration_handler_.reset(
38 new ManagedNetworkConfigurationHandlerImpl());
39 if (CertLoader::IsInitialized()) {
40 auto_connect_handler_.reset(new AutoConnectHandler());
41 network_cert_migrator_.reset(new NetworkCertMigrator());
42 client_cert_resolver_.reset(new ClientCertResolver());
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());
50 NetworkHandler::~NetworkHandler() {
53 void NetworkHandler::Init() {
54 network_state_handler_->InitShillPropertyHandler();
55 network_device_handler_->Init(network_state_handler_.get());
56 network_profile_handler_->Init();
57 network_configuration_handler_->Init(network_state_handler_.get(),
58 network_device_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());
74 if (auto_connect_handler_) {
75 auto_connect_handler_->Init(client_cert_resolver_.get(),
76 network_connection_handler_.get(),
77 network_state_handler_.get(),
78 managed_network_configuration_handler_.get());
80 network_sms_handler_->Init();
81 geolocation_handler_->Init();
84 // static
85 void NetworkHandler::Initialize() {
86 CHECK(!g_network_handler);
87 g_network_handler = new NetworkHandler();
88 g_network_handler->Init();
91 // static
92 void NetworkHandler::Shutdown() {
93 CHECK(g_network_handler);
94 delete g_network_handler;
95 g_network_handler = NULL;
98 // static
99 NetworkHandler* NetworkHandler::Get() {
100 CHECK(g_network_handler)
101 << "NetworkHandler::Get() called before Initialize()";
102 return g_network_handler;
105 // static
106 bool NetworkHandler::IsInitialized() {
107 return g_network_handler;
110 NetworkStateHandler* NetworkHandler::network_state_handler() {
111 return network_state_handler_.get();
114 NetworkDeviceHandler* NetworkHandler::network_device_handler() {
115 return network_device_handler_.get();
118 NetworkProfileHandler* NetworkHandler::network_profile_handler() {
119 return network_profile_handler_.get();
122 NetworkConfigurationHandler* NetworkHandler::network_configuration_handler() {
123 return network_configuration_handler_.get();
126 ManagedNetworkConfigurationHandler*
127 NetworkHandler::managed_network_configuration_handler() {
128 return managed_network_configuration_handler_.get();
131 NetworkActivationHandler* NetworkHandler::network_activation_handler() {
132 return network_activation_handler_.get();
135 NetworkConnectionHandler* NetworkHandler::network_connection_handler() {
136 return network_connection_handler_.get();
139 NetworkSmsHandler* NetworkHandler::network_sms_handler() {
140 return network_sms_handler_.get();
143 GeolocationHandler* NetworkHandler::geolocation_handler() {
144 return geolocation_handler_.get();
147 } // namespace chromeos