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

Unified 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: fix shared build Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ui/chromeos/network/network_list.cc
diff --git a/ui/chromeos/network/network_list.cc b/ui/chromeos/network/network_list.cc
index 76cbaf6d48419e0f7b39114255eb886ca755b13d..49601ca04fe6f0e826619b796aa0421e748bfb1b 100644
--- a/ui/chromeos/network/network_list.cc
+++ b/ui/chromeos/network/network_list.cc
@@ -7,11 +7,14 @@
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
#include "chromeos/dbus/power_manager_client.h"
+#include "chromeos/login/login_state.h"
+#include "chromeos/network/managed_network_configuration_handler.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_state_handler_observer.h"
#include "components/device_event_log/device_event_log.h"
#include "grit/ui_chromeos_strings.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/chromeos/network/network_icon.h"
#include "ui/chromeos/network/network_icon_animation.h"
@@ -21,8 +24,10 @@
#include "ui/views/controls/label.h"
#include "ui/views/view.h"
+using chromeos::LoginState;
using chromeos::NetworkHandler;
using chromeos::NetworkStateHandler;
+using chromeos::ManagedNetworkConfigurationHandler;
using chromeos::NetworkTypePattern;
namespace ui {
@@ -80,15 +85,31 @@ void NetworkListView::UpdateNetworks(
void NetworkListView::UpdateNetworkIcons() {
SCOPED_NET_LOG_IF_SLOW();
NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
+ ManagedNetworkConfigurationHandler* managed_configuration_handler =
+ NetworkHandler::Get()->managed_network_configuration_handler();
// First, update state for all networks
bool animating = false;
+
+ const base::DictionaryValue* global_network_config =
+ managed_configuration_handler->GetGlobalConfigFromPolicy(
+ std::string() /* no username hash, device policy */);
+ bool policy_prohibites_unmanaged = false;
+ global_network_config->GetBooleanWithoutPathExpansion(
+ ::onc::global_network_config::kAllowOnlyPolicyNetworksToConnect,
+ &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(
for (size_t i = 0; i < network_list_.size(); ++i) {
NetworkInfo* info = network_list_[i];
const chromeos::NetworkState* network =
handler->GetNetworkState(info->service_path);
if (!network)
continue;
+ bool prohibited_by_policy =
+ (!NetworkTypePattern::Ethernet().MatchesType(network->type()) &&
+ LoginState::IsInitialized() && LoginState::Get()->IsUserLoggedIn() &&
+ policy_prohibites_unmanaged &&
+ !managed_configuration_handler->FindPolicyByGuidAndProfile(
+ network->guid(), network->profile_path()));
stevenjb 2015/11/23 18:10:34 This too.
fqj 2015/11/23 19:21:47 Merged into one
info->image =
network_icon::GetImageForNetwork(network, network_icon::ICON_TYPE_LIST);
info->label =
@@ -96,7 +117,11 @@ void NetworkListView::UpdateNetworkIcons() {
info->highlight =
network->IsConnectedState() || network->IsConnectingState();
info->disable =
- network->activation_state() == shill::kActivationStateActivating;
+ (network->activation_state() == shill::kActivationStateActivating) ||
+ prohibited_by_policy;
+ if (prohibited_by_policy)
+ info->tooltip =
+ l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_PROHIBITED);
stevenjb 2015/11/23 18:10:34 {}
fqj 2015/11/23 19:21:47 Done.
if (!animating && network->IsConnectingState())
animating = true;
}

Powered by Google App Engine
This is Rietveld 408576698