summaryrefslogtreecommitdiffstats
path: root/ui/chromeos
diff options
context:
space:
mode:
authorfqj <fqj@chromium.org>2015-11-24 03:48:22 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-24 11:49:10 +0000
commit59355922b037b0e94738980d2e8828f6ecf5c5f1 (patch)
treece164013d2bb7d9a0c1ce424d2aad4ac42083235 /ui/chromeos
parentd97c21a2738efb1f2f0caf90bbc6be3c067cae21 (diff)
downloadchromium_src-59355922b037b0e94738980d2e8828f6ecf5c5f1.zip
chromium_src-59355922b037b0e94738980d2e8828f6ecf5c5f1.tar.gz
chromium_src-59355922b037b0e94738980d2e8828f6ecf5c5f1.tar.bz2
system tray ui change for AllowOnlyPolicyNetworksToConnect
This commit grays out unmanaged WiFis and button to joining other WiFis when AllowOnlyPolicyNetworksToConnect is true after user logged in, as well as adds the tooltip to tell users why. BUG=208378 Review URL: https://codereview.chromium.org/1469733003 Cr-Commit-Position: refs/heads/master@{#361319}
Diffstat (limited to 'ui/chromeos')
-rw-r--r--ui/chromeos/BUILD.gn1
-rw-r--r--ui/chromeos/network/network_info.h1
-rw-r--r--ui/chromeos/network/network_list.cc40
-rw-r--r--ui/chromeos/ui_chromeos.gyp1
-rw-r--r--ui/chromeos/ui_chromeos_strings.grd6
5 files changed, 48 insertions, 1 deletions
diff --git a/ui/chromeos/BUILD.gn b/ui/chromeos/BUILD.gn
index 39412f1..69ebacb 100644
--- a/ui/chromeos/BUILD.gn
+++ b/ui/chromeos/BUILD.gn
@@ -49,6 +49,7 @@ component("ui_chromeos") {
"//chromeos:chromeos",
"//chromeos:power_manager_proto",
"//components/device_event_log",
+ "//components/onc",
"//skia",
"//ui/aura",
"//ui/base",
diff --git a/ui/chromeos/network/network_info.h b/ui/chromeos/network/network_info.h
index 700e415..6ffe87d 100644
--- a/ui/chromeos/network/network_info.h
+++ b/ui/chromeos/network/network_info.h
@@ -26,6 +26,7 @@ struct UI_CHROMEOS_EXPORT NetworkInfo {
std::string service_path;
base::string16 label;
+ base::string16 tooltip;
gfx::ImageSkia image;
bool disable;
bool highlight;
diff --git a/ui/chromeos/network/network_list.cc b/ui/chromeos/network/network_list.cc
index 76cbaf6..0941205 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,12 +24,40 @@
#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 {
+namespace {
+
+bool IsProhibitedByPolicy(const chromeos::NetworkState* network) {
+ if (!NetworkTypePattern::WiFi().MatchesType(network->type()))
+ return false;
+ if (!LoginState::IsInitialized() || !LoginState::Get()->IsUserLoggedIn())
+ return false;
+ ManagedNetworkConfigurationHandler* managed_configuration_handler =
+ NetworkHandler::Get()->managed_network_configuration_handler();
+ const base::DictionaryValue* global_network_config =
+ managed_configuration_handler->GetGlobalConfigFromPolicy(
+ std::string() /* no username hash, device policy */);
+ bool policy_prohibites_unmanaged = false;
+ if (global_network_config) {
+ global_network_config->GetBooleanWithoutPathExpansion(
+ ::onc::global_network_config::kAllowOnlyPolicyNetworksToConnect,
+ &policy_prohibites_unmanaged);
+ }
+ if (!policy_prohibites_unmanaged)
+ return false;
+ return !managed_configuration_handler->FindPolicyByGuidAndProfile(
+ network->guid(), network->profile_path());
+}
+
+} // namespace
+
// NetworkListView:
NetworkListView::NetworkListView(NetworkListDelegate* delegate)
@@ -83,12 +114,14 @@ void NetworkListView::UpdateNetworkIcons() {
// First, update state for all networks
bool animating = false;
+
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 = IsProhibitedByPolicy(network);
info->image =
network_icon::GetImageForNetwork(network, network_icon::ICON_TYPE_LIST);
info->label =
@@ -96,7 +129,12 @@ 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);
+ }
if (!animating && network->IsConnectingState())
animating = true;
}
diff --git a/ui/chromeos/ui_chromeos.gyp b/ui/chromeos/ui_chromeos.gyp
index 2aeec8c..ea0c3dc 100644
--- a/ui/chromeos/ui_chromeos.gyp
+++ b/ui/chromeos/ui_chromeos.gyp
@@ -50,6 +50,7 @@
'../../chromeos/chromeos.gyp:chromeos',
'../../chromeos/chromeos.gyp:power_manager_proto',
'../../components/components.gyp:device_event_log_component',
+ '../../components/components.gyp:onc_component',
'../../skia/skia.gyp:skia',
'../aura/aura.gyp:aura',
'../base/ime/ui_base_ime.gyp:ui_base_ime',
diff --git a/ui/chromeos/ui_chromeos_strings.grd b/ui/chromeos/ui_chromeos_strings.grd
index 7e36839..67f0971 100644
--- a/ui/chromeos/ui_chromeos_strings.grd
+++ b/ui/chromeos/ui_chromeos_strings.grd
@@ -150,6 +150,12 @@
<message name="IDS_ASH_STATUS_TRAY_NETWORK_NOT_CONNECTED" desc="Description in status area or network list when no network is connected.">
No network
</message>
+ <message name="IDS_ASH_STATUS_TRAY_NETWORK_PROHIBITED" desc="Tooltip in network list when no network is prohibited by policy.">
+ This network is disabled by your administrator.
+ </message>
+ <message name="IDS_ASH_STATUS_TRAY_NETWORK_PROHIBITED_OTHER" desc="Tooltip in network list for joining other network when connecting unmanaged network is prohibited">
+ Connecting to other networks is disabled by your administrator.
+ </message>
<message name="IDS_ASH_STATUS_TRAY_NO_NETWORKS" desc="The message to display in the network info bubble when it is otherwise empty.">
No network information available