OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/chromeos/network/network_list.h" | 5 #include "ui/chromeos/network/network_list.h" |
6 | 6 |
7 #include "chromeos/dbus/dbus_thread_manager.h" | 7 #include "chromeos/dbus/dbus_thread_manager.h" |
8 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" | 8 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" |
9 #include "chromeos/dbus/power_manager_client.h" | 9 #include "chromeos/dbus/power_manager_client.h" |
10 #include "chromeos/login/login_state.h" | |
11 #include "chromeos/network/managed_network_configuration_handler.h" | |
10 #include "chromeos/network/network_state.h" | 12 #include "chromeos/network/network_state.h" |
11 #include "chromeos/network/network_state_handler.h" | 13 #include "chromeos/network/network_state_handler.h" |
12 #include "chromeos/network/network_state_handler_observer.h" | 14 #include "chromeos/network/network_state_handler_observer.h" |
13 #include "components/device_event_log/device_event_log.h" | 15 #include "components/device_event_log/device_event_log.h" |
14 #include "grit/ui_chromeos_strings.h" | 16 #include "grit/ui_chromeos_strings.h" |
17 #include "ui/base/l10n/l10n_util.h" | |
15 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
16 #include "ui/chromeos/network/network_icon.h" | 19 #include "ui/chromeos/network/network_icon.h" |
17 #include "ui/chromeos/network/network_icon_animation.h" | 20 #include "ui/chromeos/network/network_icon_animation.h" |
18 #include "ui/chromeos/network/network_info.h" | 21 #include "ui/chromeos/network/network_info.h" |
19 #include "ui/chromeos/network/network_list_delegate.h" | 22 #include "ui/chromeos/network/network_list_delegate.h" |
20 #include "ui/gfx/font.h" | 23 #include "ui/gfx/font.h" |
21 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
22 #include "ui/views/view.h" | 25 #include "ui/views/view.h" |
23 | 26 |
27 using chromeos::LoginState; | |
24 using chromeos::NetworkHandler; | 28 using chromeos::NetworkHandler; |
25 using chromeos::NetworkStateHandler; | 29 using chromeos::NetworkStateHandler; |
30 using chromeos::ManagedNetworkConfigurationHandler; | |
26 using chromeos::NetworkTypePattern; | 31 using chromeos::NetworkTypePattern; |
27 | 32 |
28 namespace ui { | 33 namespace ui { |
29 | 34 |
30 // NetworkListView: | 35 // NetworkListView: |
31 | 36 |
32 NetworkListView::NetworkListView(NetworkListDelegate* delegate) | 37 NetworkListView::NetworkListView(NetworkListDelegate* delegate) |
33 : delegate_(delegate), | 38 : delegate_(delegate), |
34 no_wifi_networks_view_(NULL), | 39 no_wifi_networks_view_(NULL), |
35 no_cellular_networks_view_(NULL) { | 40 no_cellular_networks_view_(NULL) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 if (!pattern.MatchesType(network->type())) | 78 if (!pattern.MatchesType(network->type())) |
74 continue; | 79 continue; |
75 NetworkInfo* info = new NetworkInfo(network->path()); | 80 NetworkInfo* info = new NetworkInfo(network->path()); |
76 network_list_.push_back(info); | 81 network_list_.push_back(info); |
77 } | 82 } |
78 } | 83 } |
79 | 84 |
80 void NetworkListView::UpdateNetworkIcons() { | 85 void NetworkListView::UpdateNetworkIcons() { |
81 SCOPED_NET_LOG_IF_SLOW(); | 86 SCOPED_NET_LOG_IF_SLOW(); |
82 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 87 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
88 ManagedNetworkConfigurationHandler* managed_configuration_handler = | |
89 NetworkHandler::Get()->managed_network_configuration_handler(); | |
83 | 90 |
84 // First, update state for all networks | 91 // First, update state for all networks |
85 bool animating = false; | 92 bool animating = false; |
93 | |
94 const base::DictionaryValue* global_network_config = | |
95 managed_configuration_handler->GetGlobalConfigFromPolicy( | |
96 std::string() /* no username hash, device policy */); | |
97 bool policy_prohibites_unmanaged = false; | |
98 global_network_config->GetBooleanWithoutPathExpansion( | |
99 ::onc::global_network_config::kAllowOnlyPolicyNetworksToConnect, | |
100 &policy_prohibites_unmanaged); | |
stevenjb
2015/11/23 18:10:34
Same here, let's use a helper function for this.
fqj
2015/11/23 19:21:47
Done.
stevenjb
2015/11/23 20:39:32
Same here:
namespace {
bool IsProhibitedByPolicy(
| |
86 for (size_t i = 0; i < network_list_.size(); ++i) { | 101 for (size_t i = 0; i < network_list_.size(); ++i) { |
87 NetworkInfo* info = network_list_[i]; | 102 NetworkInfo* info = network_list_[i]; |
88 const chromeos::NetworkState* network = | 103 const chromeos::NetworkState* network = |
89 handler->GetNetworkState(info->service_path); | 104 handler->GetNetworkState(info->service_path); |
90 if (!network) | 105 if (!network) |
91 continue; | 106 continue; |
107 bool prohibited_by_policy = | |
108 (!NetworkTypePattern::Ethernet().MatchesType(network->type()) && | |
109 LoginState::IsInitialized() && LoginState::Get()->IsUserLoggedIn() && | |
110 policy_prohibites_unmanaged && | |
111 !managed_configuration_handler->FindPolicyByGuidAndProfile( | |
112 network->guid(), network->profile_path())); | |
stevenjb
2015/11/23 18:10:34
This too.
fqj
2015/11/23 19:21:47
Merged into one
| |
92 info->image = | 113 info->image = |
93 network_icon::GetImageForNetwork(network, network_icon::ICON_TYPE_LIST); | 114 network_icon::GetImageForNetwork(network, network_icon::ICON_TYPE_LIST); |
94 info->label = | 115 info->label = |
95 network_icon::GetLabelForNetwork(network, network_icon::ICON_TYPE_LIST); | 116 network_icon::GetLabelForNetwork(network, network_icon::ICON_TYPE_LIST); |
96 info->highlight = | 117 info->highlight = |
97 network->IsConnectedState() || network->IsConnectingState(); | 118 network->IsConnectedState() || network->IsConnectingState(); |
98 info->disable = | 119 info->disable = |
99 network->activation_state() == shill::kActivationStateActivating; | 120 (network->activation_state() == shill::kActivationStateActivating) || |
121 prohibited_by_policy; | |
122 if (prohibited_by_policy) | |
123 info->tooltip = | |
124 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_PROHIBITED); | |
stevenjb
2015/11/23 18:10:34
{}
fqj
2015/11/23 19:21:47
Done.
| |
100 if (!animating && network->IsConnectingState()) | 125 if (!animating && network->IsConnectingState()) |
101 animating = true; | 126 animating = true; |
102 } | 127 } |
103 if (animating) | 128 if (animating) |
104 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); | 129 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); |
105 else | 130 else |
106 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); | 131 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); |
107 } | 132 } |
108 | 133 |
109 void NetworkListView::UpdateNetworkListInternal() { | 134 void NetworkListView::UpdateNetworkListInternal() { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 needs_relayout = true; | 302 needs_relayout = true; |
278 } | 303 } |
279 return needs_relayout; | 304 return needs_relayout; |
280 } | 305 } |
281 | 306 |
282 void NetworkListView::NetworkIconChanged() { | 307 void NetworkListView::NetworkIconChanged() { |
283 Update(); | 308 Update(); |
284 } | 309 } |
285 | 310 |
286 } // namespace ui | 311 } // namespace ui |
OLD | NEW |