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

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
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..38b06fe86d16dc89fe54b761c1942d5f6ae50823 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();
+ for (const auto& technology : prohibited_technologies)
+ prohibited_technologies_.insert(technology);
stevenjb 2015/11/12 18:20:38 prohibited_technologies_.insert(prohibited_technol
fqj 2015/11/13 13:53:49 Done.
+
+ // 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);

Powered by Google App Engine
This is Rietveld 408576698