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

Unified Diff: chromeos/network/shill_property_handler.cc

Issue 1431563005: Handle prohibited technologies in device policy ONC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « chromeos/network/shill_property_handler.h ('k') | chromeos/network/shill_property_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/shill_property_handler.cc
diff --git a/chromeos/network/shill_property_handler.cc b/chromeos/network/shill_property_handler.cc
index 02b620d38e6e2895d65b0cccbf3752c4a1bbd5ca..eb73b832fc242fdb98e8287d61d1e60aa3a15b4a 100644
--- a/chromeos/network/shill_property_handler.cc
+++ b/chromeos/network/shill_property_handler.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/format_macros.h"
#include "base/stl_util.h"
+#include "base/strings/string_util.h"
#include "base/values.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/shill_device_client.h"
@@ -104,8 +105,7 @@ class ShillPropertyObserver : public ShillPropertyChangedObserver {
ShillPropertyHandler::ShillPropertyHandler(Listener* listener)
: listener_(listener),
- shill_manager_(DBusThreadManager::Get()->GetShillManagerClient()) {
-}
+ shill_manager_(DBusThreadManager::Get()->GetShillManagerClient()) {}
ShillPropertyHandler::~ShillPropertyHandler() {
// Delete network service observers.
@@ -153,6 +153,14 @@ void ShillPropertyHandler::SetTechnologyEnabled(
bool enabled,
const network_handler::ErrorCallback& error_callback) {
if (enabled) {
+ if (prohibited_technologies_.find(technology) !=
+ prohibited_technologies_.end()) {
+ chromeos::network_handler::RunErrorCallback(
+ error_callback, "", "prohibited_technologies",
+ "Ignored: Attempt to enable prohibited network technology " +
+ technology);
+ return;
+ }
enabling_technologies_.insert(technology);
shill_manager_->EnableTechnology(
technology, base::Bind(&base::DoNothing),
@@ -169,6 +177,35 @@ void ShillPropertyHandler::SetTechnologyEnabled(
}
}
+void ShillPropertyHandler::SetProhibitedTechnologies(
+ const std::vector<std::string>& prohibited_technologies,
+ const network_handler::ErrorCallback& error_callback) {
+ prohibited_technologies_.clear();
+ prohibited_technologies_.insert(prohibited_technologies.begin(),
+ prohibited_technologies.end());
+
+ // Remove technologies from the other lists.
+ // And manually disable them.
+ for (const auto& technology : prohibited_technologies) {
+ enabling_technologies_.erase(technology);
+ enabled_technologies_.erase(technology);
+ shill_manager_->DisableTechnology(
+ technology, base::Bind(&base::DoNothing),
+ base::Bind(&network_handler::ShillErrorCallbackFunction,
+ "DisableTechnology Failed", technology, error_callback));
+ }
+
+ // Send updated prohibited technology list to shill.
+ const std::string prohibited_list =
+ base::JoinString(prohibited_technologies, ",");
+ base::StringValue value(prohibited_list);
+ shill_manager_->SetProperty(
+ "ProhibitedTechnologies", value, base::Bind(&base::DoNothing),
+ base::Bind(&network_handler::ShillErrorCallbackFunction,
+ "SetTechnologiesProhibited Failed", prohibited_list,
+ error_callback));
+}
+
void ShillPropertyHandler::SetCheckPortalList(
const std::string& check_portal_list) {
base::StringValue value(check_portal_list);
« no previous file with comments | « chromeos/network/shill_property_handler.h ('k') | chromeos/network/shill_property_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698