OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 "ash/system/chromeos/network/tray_network_state_observer.h" |
| 6 |
| 7 #include "ash/shell.h" |
| 8 #include "ash/system/chromeos/network/network_detailed_view.h" |
| 9 #include "ash/system/chromeos/network/tray_network.h" |
| 10 #include "ash/system/tray/tray_constants.h" |
| 11 #include "chromeos/network/network_state_handler.h" |
| 12 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 13 |
| 14 namespace ash { |
| 15 namespace internal { |
| 16 |
| 17 TrayNetworkStateObserver::TrayNetworkStateObserver(TrayNetwork* tray) |
| 18 : tray_(tray), |
| 19 wifi_state_(WIFI_UNKNOWN) { |
| 20 Shell::GetInstance()->network_state_handler()->AddObserver(this); |
| 21 } |
| 22 |
| 23 TrayNetworkStateObserver::~TrayNetworkStateObserver() { |
| 24 Shell::GetInstance()->network_state_handler()->RemoveObserver(this); |
| 25 } |
| 26 |
| 27 void TrayNetworkStateObserver::NetworkManagerChanged( |
| 28 const std::string& property) { |
| 29 tray::NetworkDetailedView* detailed = tray_->detailed(); |
| 30 bool wifi_enabled = Shell::GetInstance()->network_state_handler()-> |
| 31 TechnologyEnabled(flimflam::kTypeWifi); |
| 32 WifiState wifi_state = wifi_enabled ? WIFI_ENABLED : WIFI_DISABLED; |
| 33 if ((wifi_state_ != WIFI_UNKNOWN && wifi_state_ != wifi_state) && |
| 34 (!detailed || |
| 35 detailed->GetViewType() == tray::NetworkDetailedView::WIFI_VIEW)) { |
| 36 tray_->set_request_wifi_view(true); |
| 37 tray_->PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); |
| 38 } |
| 39 wifi_state_ = wifi_state; |
| 40 if (detailed) |
| 41 detailed->ManagerChanged(); |
| 42 } |
| 43 |
| 44 void TrayNetworkStateObserver::NetworkListChanged( |
| 45 const NetworkStateList& networks) { |
| 46 tray::NetworkDetailedView* detailed = tray_->detailed(); |
| 47 if (detailed) |
| 48 detailed->NetworkListChanged(networks); |
| 49 } |
| 50 |
| 51 void TrayNetworkStateObserver::NetworkServiceChanged(const std::string& path) { |
| 52 tray::NetworkDetailedView* detailed = tray_->detailed(); |
| 53 if (detailed) |
| 54 detailed->NetworkServiceChanged(path); |
| 55 } |
| 56 |
| 57 } // namespace ash |
| 58 } // namespace internal |
OLD | NEW |