Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: ui/chromeos/network/network_list.cc

Issue 1469733003: system tray ui change for AllowOnlyPolicyNetworksToConnect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/chromeos/network/network_info.h ('k') | ui/chromeos/ui_chromeos.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
35 namespace {
36
37 bool IsProhibitedByPolicy(const chromeos::NetworkState* network) {
38 if (!NetworkTypePattern::WiFi().MatchesType(network->type()))
39 return false;
40 if (!LoginState::IsInitialized() || !LoginState::Get()->IsUserLoggedIn())
41 return false;
42 ManagedNetworkConfigurationHandler* managed_configuration_handler =
43 NetworkHandler::Get()->managed_network_configuration_handler();
44 const base::DictionaryValue* global_network_config =
45 managed_configuration_handler->GetGlobalConfigFromPolicy(
46 std::string() /* no username hash, device policy */);
47 bool policy_prohibites_unmanaged = false;
48 if (global_network_config) {
49 global_network_config->GetBooleanWithoutPathExpansion(
50 ::onc::global_network_config::kAllowOnlyPolicyNetworksToConnect,
51 &policy_prohibites_unmanaged);
52 }
53 if (!policy_prohibites_unmanaged)
54 return false;
55 return !managed_configuration_handler->FindPolicyByGuidAndProfile(
56 network->guid(), network->profile_path());
57 }
58
59 } // namespace
60
30 // NetworkListView: 61 // NetworkListView:
31 62
32 NetworkListView::NetworkListView(NetworkListDelegate* delegate) 63 NetworkListView::NetworkListView(NetworkListDelegate* delegate)
33 : delegate_(delegate), 64 : delegate_(delegate),
34 no_wifi_networks_view_(NULL), 65 no_wifi_networks_view_(NULL),
35 no_cellular_networks_view_(NULL) { 66 no_cellular_networks_view_(NULL) {
36 CHECK(delegate_); 67 CHECK(delegate_);
37 } 68 }
38 69
39 NetworkListView::~NetworkListView() { 70 NetworkListView::~NetworkListView() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 network_list_.push_back(info); 107 network_list_.push_back(info);
77 } 108 }
78 } 109 }
79 110
80 void NetworkListView::UpdateNetworkIcons() { 111 void NetworkListView::UpdateNetworkIcons() {
81 SCOPED_NET_LOG_IF_SLOW(); 112 SCOPED_NET_LOG_IF_SLOW();
82 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 113 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
83 114
84 // First, update state for all networks 115 // First, update state for all networks
85 bool animating = false; 116 bool animating = false;
117
86 for (size_t i = 0; i < network_list_.size(); ++i) { 118 for (size_t i = 0; i < network_list_.size(); ++i) {
87 NetworkInfo* info = network_list_[i]; 119 NetworkInfo* info = network_list_[i];
88 const chromeos::NetworkState* network = 120 const chromeos::NetworkState* network =
89 handler->GetNetworkState(info->service_path); 121 handler->GetNetworkState(info->service_path);
90 if (!network) 122 if (!network)
91 continue; 123 continue;
124 bool prohibited_by_policy = IsProhibitedByPolicy(network);
92 info->image = 125 info->image =
93 network_icon::GetImageForNetwork(network, network_icon::ICON_TYPE_LIST); 126 network_icon::GetImageForNetwork(network, network_icon::ICON_TYPE_LIST);
94 info->label = 127 info->label =
95 network_icon::GetLabelForNetwork(network, network_icon::ICON_TYPE_LIST); 128 network_icon::GetLabelForNetwork(network, network_icon::ICON_TYPE_LIST);
96 info->highlight = 129 info->highlight =
97 network->IsConnectedState() || network->IsConnectingState(); 130 network->IsConnectedState() || network->IsConnectingState();
98 info->disable = 131 info->disable =
99 network->activation_state() == shill::kActivationStateActivating; 132 (network->activation_state() == shill::kActivationStateActivating) ||
133 prohibited_by_policy;
134 if (prohibited_by_policy) {
135 info->tooltip =
136 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_PROHIBITED);
137 }
100 if (!animating && network->IsConnectingState()) 138 if (!animating && network->IsConnectingState())
101 animating = true; 139 animating = true;
102 } 140 }
103 if (animating) 141 if (animating)
104 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); 142 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this);
105 else 143 else
106 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); 144 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this);
107 } 145 }
108 146
109 void NetworkListView::UpdateNetworkListInternal() { 147 void NetworkListView::UpdateNetworkListInternal() {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 needs_relayout = true; 315 needs_relayout = true;
278 } 316 }
279 return needs_relayout; 317 return needs_relayout;
280 } 318 }
281 319
282 void NetworkListView::NetworkIconChanged() { 320 void NetworkListView::NetworkIconChanged() {
283 Update(); 321 Update();
284 } 322 }
285 323
286 } // namespace ui 324 } // namespace ui
OLDNEW
« no previous file with comments | « ui/chromeos/network/network_info.h ('k') | ui/chromeos/ui_chromeos.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698