blob: d090762a190d40b8cf77e75f7b6d26151ed78c08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/chromeos/network/tray_network_state_observer.h"
#include <set>
#include <string>
#include "ash/system/chromeos/network/network_icon.h"
#include "base/location.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
using chromeos::NetworkHandler;
namespace ash {
namespace internal {
TrayNetworkStateObserver::TrayNetworkStateObserver(Delegate* delegate)
: delegate_(delegate) {
if (NetworkHandler::IsInitialized()) {
NetworkHandler::Get()->network_state_handler()->AddObserver(
this, FROM_HERE);
}
}
TrayNetworkStateObserver::~TrayNetworkStateObserver() {
if (NetworkHandler::IsInitialized()) {
NetworkHandler::Get()->network_state_handler()->RemoveObserver(
this, FROM_HERE);
}
}
void TrayNetworkStateObserver::NetworkListChanged() {
delegate_->NetworkStateChanged(true);
network_icon::PurgeNetworkIconCache();
}
void TrayNetworkStateObserver::DeviceListChanged() {
delegate_->NetworkStateChanged(false);
}
void TrayNetworkStateObserver::DefaultNetworkChanged(
const chromeos::NetworkState* network) {
delegate_->NetworkStateChanged(true);
}
void TrayNetworkStateObserver::NetworkPropertiesUpdated(
const chromeos::NetworkState* network) {
if (network ==
NetworkHandler::Get()->network_state_handler()->DefaultNetwork())
delegate_->NetworkStateChanged(true);
delegate_->NetworkServiceChanged(network);
}
} // namespace ash
} // namespace internal
|