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

Side by Side Diff: chromeos/network/managed_network_configuration_handler_impl.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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chromeos/network/managed_network_configuration_handler_impl.h" 5 #include "chromeos/network/managed_network_configuration_handler_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/guid.h" 10 #include "base/guid.h"
(...skipping 16 matching lines...) Expand all
27 #include "chromeos/network/network_state.h" 27 #include "chromeos/network/network_state.h"
28 #include "chromeos/network/network_state_handler.h" 28 #include "chromeos/network/network_state_handler.h"
29 #include "chromeos/network/network_ui_data.h" 29 #include "chromeos/network/network_ui_data.h"
30 #include "chromeos/network/network_util.h" 30 #include "chromeos/network/network_util.h"
31 #include "chromeos/network/onc/onc_merger.h" 31 #include "chromeos/network/onc/onc_merger.h"
32 #include "chromeos/network/onc/onc_signature.h" 32 #include "chromeos/network/onc/onc_signature.h"
33 #include "chromeos/network/onc/onc_translator.h" 33 #include "chromeos/network/onc/onc_translator.h"
34 #include "chromeos/network/onc/onc_utils.h" 34 #include "chromeos/network/onc/onc_utils.h"
35 #include "chromeos/network/onc/onc_validator.h" 35 #include "chromeos/network/onc/onc_validator.h"
36 #include "chromeos/network/policy_util.h" 36 #include "chromeos/network/policy_util.h"
37 #include "chromeos/network/prohibited_technologies_handler.h"
37 #include "chromeos/network/shill_property_util.h" 38 #include "chromeos/network/shill_property_util.h"
38 #include "components/onc/onc_constants.h" 39 #include "components/onc/onc_constants.h"
39 #include "third_party/cros_system_api/dbus/service_constants.h" 40 #include "third_party/cros_system_api/dbus/service_constants.h"
40 41
41 namespace chromeos { 42 namespace chromeos {
42 43
43 namespace { 44 namespace {
44 45
45 using GuidToPolicyMap = ManagedNetworkConfigurationHandler::GuidToPolicyMap; 46 using GuidToPolicyMap = ManagedNetworkConfigurationHandler::GuidToPolicyMap;
46 47
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 Policies* policies = NULL; 420 Policies* policies = NULL;
420 if (ContainsKey(policies_by_user_, userhash)) { 421 if (ContainsKey(policies_by_user_, userhash)) {
421 policies = policies_by_user_[userhash].get(); 422 policies = policies_by_user_[userhash].get();
422 } else { 423 } else {
423 policies = new Policies; 424 policies = new Policies;
424 policies_by_user_[userhash] = make_linked_ptr(policies); 425 policies_by_user_[userhash] = make_linked_ptr(policies);
425 } 426 }
426 427
427 policies->global_network_config.MergeDictionary(&global_network_config); 428 policies->global_network_config.MergeDictionary(&global_network_config);
428 429
430 // Update prohibited technologies.
431 const base::ListValue* prohibited_list = nullptr;
432 if (policies->global_network_config.GetListWithoutPathExpansion(
433 ::onc::global_network_config::kDisableNetworkTypes,
434 &prohibited_list) &&
435 prohibited_technologies_handler_) {
436 // Prohobited technologies are only allowed in user policy.
437 DCHECK_EQ(::onc::ONC_SOURCE_DEVICE_POLICY, onc_source);
438
439 // Build up prohibited network type list and update NetworkStateHandler.
stevenjb 2015/11/11 18:07:31 Comment out of date.
fqj 2015/11/12 10:23:01 Done.
440 std::vector<std::string> prohibited_technologies;
441 for (const base::Value* item : *prohibited_list) {
442 std::string prohibited_technology;
443 item->GetAsString(&prohibited_technology);
444 std::string translated_tech =
445 network_util::TranslateONCTypeToShill(prohibited_technology);
446 if (translated_tech.length())
stevenjb 2015/11/11 18:07:31 !translated_tech.empty()
fqj 2015/11/12 10:23:01 Done.
447 prohibited_technologies.push_back(translated_tech);
448 }
449 prohibited_technologies_handler_->SetProhibitedTechnologies(
450 prohibited_technologies);
stevenjb 2015/11/11 18:07:31 Since we have a separate handler now we should mov
fqj 2015/11/12 10:23:01 Done.
451 }
452
429 GuidToPolicyMap old_per_network_config; 453 GuidToPolicyMap old_per_network_config;
430 policies->per_network_config.swap(old_per_network_config); 454 policies->per_network_config.swap(old_per_network_config);
431 455
432 // This stores all GUIDs of policies that have changed or are new. 456 // This stores all GUIDs of policies that have changed or are new.
433 std::set<std::string> modified_policies; 457 std::set<std::string> modified_policies;
434 458
435 for (base::ListValue::const_iterator it = network_configs_onc.begin(); 459 for (base::ListValue::const_iterator it = network_configs_onc.begin();
436 it != network_configs_onc.end(); ++it) { 460 it != network_configs_onc.end(); ++it) {
437 const base::DictionaryValue* network = NULL; 461 const base::DictionaryValue* network = NULL;
438 (*it)->GetAsDictionary(&network); 462 (*it)->GetAsDictionary(&network);
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 ManagedNetworkConfigurationHandlerImpl:: 726 ManagedNetworkConfigurationHandlerImpl::
703 ~ManagedNetworkConfigurationHandlerImpl() { 727 ~ManagedNetworkConfigurationHandlerImpl() {
704 if (network_profile_handler_) 728 if (network_profile_handler_)
705 network_profile_handler_->RemoveObserver(this); 729 network_profile_handler_->RemoveObserver(this);
706 } 730 }
707 731
708 void ManagedNetworkConfigurationHandlerImpl::Init( 732 void ManagedNetworkConfigurationHandlerImpl::Init(
709 NetworkStateHandler* network_state_handler, 733 NetworkStateHandler* network_state_handler,
710 NetworkProfileHandler* network_profile_handler, 734 NetworkProfileHandler* network_profile_handler,
711 NetworkConfigurationHandler* network_configuration_handler, 735 NetworkConfigurationHandler* network_configuration_handler,
712 NetworkDeviceHandler* network_device_handler) { 736 NetworkDeviceHandler* network_device_handler,
737 ProhibitedTechnologiesHandler* prohibited_technologies_handler) {
713 network_state_handler_ = network_state_handler; 738 network_state_handler_ = network_state_handler;
714 network_profile_handler_ = network_profile_handler; 739 network_profile_handler_ = network_profile_handler;
715 network_configuration_handler_ = network_configuration_handler; 740 network_configuration_handler_ = network_configuration_handler;
716 network_device_handler_ = network_device_handler; 741 network_device_handler_ = network_device_handler;
717 network_profile_handler_->AddObserver(this); 742 network_profile_handler_->AddObserver(this);
743 prohibited_technologies_handler_ = prohibited_technologies_handler;
718 } 744 }
719 745
720 void ManagedNetworkConfigurationHandlerImpl::OnPolicyAppliedToNetwork( 746 void ManagedNetworkConfigurationHandlerImpl::OnPolicyAppliedToNetwork(
721 const std::string& service_path) { 747 const std::string& service_path) {
722 if (service_path.empty()) 748 if (service_path.empty())
723 return; 749 return;
724 FOR_EACH_OBSERVER( 750 FOR_EACH_OBSERVER(
725 NetworkPolicyObserver, observers_, PolicyAppliedToNetwork(service_path)); 751 NetworkPolicyObserver, observers_, PolicyAppliedToNetwork(service_path));
726 } 752 }
727 753
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 scoped_ptr<base::DictionaryValue> network_properties, 869 scoped_ptr<base::DictionaryValue> network_properties,
844 GetDevicePropertiesCallback send_callback, 870 GetDevicePropertiesCallback send_callback,
845 const std::string& error_name, 871 const std::string& error_name,
846 scoped_ptr<base::DictionaryValue> error_data) { 872 scoped_ptr<base::DictionaryValue> error_data) {
847 NET_LOG_ERROR("Error getting device properties", service_path); 873 NET_LOG_ERROR("Error getting device properties", service_path);
848 send_callback.Run(service_path, network_properties.Pass()); 874 send_callback.Run(service_path, network_properties.Pass());
849 } 875 }
850 876
851 877
852 } // namespace chromeos 878 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698