OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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.h" | 5 #include "chromeos/network/managed_network_configuration_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 const base::DictionaryValue& shill_properties) { | 287 const base::DictionaryValue& shill_properties) { |
288 scoped_ptr<base::DictionaryValue> onc_network( | 288 scoped_ptr<base::DictionaryValue> onc_network( |
289 onc::TranslateShillServiceToONCPart( | 289 onc::TranslateShillServiceToONCPart( |
290 shill_properties, | 290 shill_properties, |
291 &onc::kNetworkWithStateSignature)); | 291 &onc::kNetworkWithStateSignature)); |
292 callback.Run(service_path, *onc_network); | 292 callback.Run(service_path, *onc_network); |
293 } | 293 } |
294 | 294 |
295 } // namespace | 295 } // namespace |
296 | 296 |
297 static ManagedNetworkConfigurationHandler* | |
298 g_configuration_handler_instance = NULL; | |
299 | |
300 // static | |
301 void ManagedNetworkConfigurationHandler::Initialize( | |
302 NetworkProfileHandler* profile_handler) { | |
303 CHECK(!g_configuration_handler_instance); | |
304 g_configuration_handler_instance = | |
305 new ManagedNetworkConfigurationHandler(profile_handler); | |
306 } | |
307 | |
308 // static | |
309 bool ManagedNetworkConfigurationHandler::IsInitialized() { | |
310 return g_configuration_handler_instance; | |
311 } | |
312 | |
313 // static | |
314 void ManagedNetworkConfigurationHandler::Shutdown() { | |
315 CHECK(g_configuration_handler_instance); | |
316 delete g_configuration_handler_instance; | |
317 g_configuration_handler_instance = NULL; | |
318 } | |
319 | |
320 // static | |
321 ManagedNetworkConfigurationHandler* ManagedNetworkConfigurationHandler::Get() { | |
322 CHECK(g_configuration_handler_instance); | |
323 return g_configuration_handler_instance; | |
324 } | |
325 | 297 |
326 // static | 298 // static |
327 scoped_ptr<NetworkUIData> ManagedNetworkConfigurationHandler::GetUIData( | 299 scoped_ptr<NetworkUIData> ManagedNetworkConfigurationHandler::GetUIData( |
328 const base::DictionaryValue& shill_dictionary) { | 300 const base::DictionaryValue& shill_dictionary) { |
329 std::string ui_data_blob; | 301 std::string ui_data_blob; |
330 if (shill_dictionary.GetStringWithoutPathExpansion( | 302 if (shill_dictionary.GetStringWithoutPathExpansion( |
331 flimflam::kUIDataProperty, | 303 flimflam::kUIDataProperty, |
332 &ui_data_blob) && | 304 &ui_data_blob) && |
333 !ui_data_blob.empty()) { | 305 !ui_data_blob.empty()) { |
334 scoped_ptr<base::DictionaryValue> ui_data_dict = | 306 scoped_ptr<base::DictionaryValue> ui_data_dict = |
(...skipping 12 matching lines...) Expand all Loading... |
347 const std::string& service_path, | 319 const std::string& service_path, |
348 const network_handler::DictionaryResultCallback& callback, | 320 const network_handler::DictionaryResultCallback& callback, |
349 const network_handler::ErrorCallback& error_callback) { | 321 const network_handler::ErrorCallback& error_callback) { |
350 if (!GetPoliciesForUser(userhash) || !GetPoliciesForUser(std::string())) { | 322 if (!GetPoliciesForUser(userhash) || !GetPoliciesForUser(std::string())) { |
351 RunErrorCallback(service_path, | 323 RunErrorCallback(service_path, |
352 kPoliciesNotInitialized, | 324 kPoliciesNotInitialized, |
353 kPoliciesNotInitializedMessage, | 325 kPoliciesNotInitializedMessage, |
354 error_callback); | 326 error_callback); |
355 return; | 327 return; |
356 } | 328 } |
357 NetworkConfigurationHandler::Get()->GetProperties( | 329 network_configuration_handler_->GetProperties( |
358 service_path, | 330 service_path, |
359 base::Bind( | 331 base::Bind( |
360 &ManagedNetworkConfigurationHandler::GetManagedPropertiesCallback, | 332 &ManagedNetworkConfigurationHandler::GetManagedPropertiesCallback, |
361 weak_ptr_factory_.GetWeakPtr(), | 333 weak_ptr_factory_.GetWeakPtr(), |
362 callback, | 334 callback, |
363 error_callback), | 335 error_callback), |
364 error_callback); | 336 error_callback); |
365 } | 337 } |
366 | 338 |
367 void ManagedNetworkConfigurationHandler::GetManagedPropertiesCallback( | 339 void ManagedNetworkConfigurationHandler::GetManagedPropertiesCallback( |
368 const network_handler::DictionaryResultCallback& callback, | 340 const network_handler::DictionaryResultCallback& callback, |
369 const network_handler::ErrorCallback& error_callback, | 341 const network_handler::ErrorCallback& error_callback, |
370 const std::string& service_path, | 342 const std::string& service_path, |
371 const base::DictionaryValue& shill_properties) { | 343 const base::DictionaryValue& shill_properties) { |
372 std::string profile_path; | 344 std::string profile_path; |
373 shill_properties.GetStringWithoutPathExpansion(flimflam::kProfileProperty, | 345 shill_properties.GetStringWithoutPathExpansion(flimflam::kProfileProperty, |
374 &profile_path); | 346 &profile_path); |
| 347 LOG(ERROR) << "Profile: " << profile_path; |
375 const NetworkProfile* profile = | 348 const NetworkProfile* profile = |
376 profile_handler_->GetProfileForPath(profile_path); | 349 network_profile_handler_->GetProfileForPath(profile_path); |
377 if (!profile) { | 350 if (!profile) { |
378 VLOG(1) << "No or no known profile received for service " | 351 LOG(ERROR) << "No or no known profile received for service " |
379 << service_path << "."; | 352 << service_path << "."; |
380 } | 353 } |
381 | 354 |
382 scoped_ptr<NetworkUIData> ui_data = GetUIData(shill_properties); | 355 scoped_ptr<NetworkUIData> ui_data = GetUIData(shill_properties); |
383 | 356 |
384 const base::DictionaryValue* user_settings = NULL; | 357 const base::DictionaryValue* user_settings = NULL; |
385 const base::DictionaryValue* shared_settings = NULL; | 358 const base::DictionaryValue* shared_settings = NULL; |
386 | 359 |
387 if (ui_data && profile) { | 360 if (ui_data && profile) { |
388 if (profile->type() == NetworkProfile::TYPE_SHARED) | 361 if (profile->type() == NetworkProfile::TYPE_SHARED) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 user_settings, | 410 user_settings, |
438 shared_settings, | 411 shared_settings, |
439 active_settings.get()); | 412 active_settings.get()); |
440 callback.Run(service_path, *augmented_properties); | 413 callback.Run(service_path, *augmented_properties); |
441 } | 414 } |
442 | 415 |
443 void ManagedNetworkConfigurationHandler::GetProperties( | 416 void ManagedNetworkConfigurationHandler::GetProperties( |
444 const std::string& service_path, | 417 const std::string& service_path, |
445 const network_handler::DictionaryResultCallback& callback, | 418 const network_handler::DictionaryResultCallback& callback, |
446 const network_handler::ErrorCallback& error_callback) const { | 419 const network_handler::ErrorCallback& error_callback) const { |
447 NetworkConfigurationHandler::Get()->GetProperties( | 420 network_configuration_handler_->GetProperties( |
448 service_path, | 421 service_path, |
449 base::Bind(&TranslatePropertiesToOncAndRunCallback, callback), | 422 base::Bind(&TranslatePropertiesToOncAndRunCallback, callback), |
450 error_callback); | 423 error_callback); |
451 } | 424 } |
452 | 425 |
453 void ManagedNetworkConfigurationHandler::SetProperties( | 426 void ManagedNetworkConfigurationHandler::SetProperties( |
454 const std::string& service_path, | 427 const std::string& service_path, |
455 const base::DictionaryValue& user_settings, | 428 const base::DictionaryValue& user_settings, |
456 const base::Closure& callback, | 429 const base::Closure& callback, |
457 const network_handler::ErrorCallback& error_callback) const { | 430 const network_handler::ErrorCallback& error_callback) const { |
458 const NetworkState* state = | 431 const NetworkState* state = |
459 NetworkStateHandler::Get()->GetNetworkState(service_path); | 432 network_state_handler_->GetNetworkState(service_path); |
460 | 433 |
461 if (!state) { | 434 if (!state) { |
462 RunErrorCallback(service_path, | 435 RunErrorCallback(service_path, |
463 kUnknownServicePath, | 436 kUnknownServicePath, |
464 kUnknownServicePathMessage, | 437 kUnknownServicePathMessage, |
465 error_callback); | 438 error_callback); |
466 return; | 439 return; |
467 } | 440 } |
468 | 441 |
469 std::string guid = state->guid(); | 442 std::string guid = state->guid(); |
470 if (guid.empty()) { | 443 if (guid.empty()) { |
471 // TODO(pneubeck): create an initial configuration in this case. As for | 444 // TODO(pneubeck): create an initial configuration in this case. As for |
472 // CreateConfiguration, user settings from older ChromeOS versions have to | 445 // CreateConfiguration, user settings from older ChromeOS versions have to |
473 // determined here. | 446 // determined here. |
474 RunErrorCallback(service_path, | 447 RunErrorCallback(service_path, |
475 kSetOnUnconfiguredNetwork, | 448 kSetOnUnconfiguredNetwork, |
476 kSetOnUnconfiguredNetworkMessage, | 449 kSetOnUnconfiguredNetworkMessage, |
477 error_callback); | 450 error_callback); |
478 return; | 451 return; |
479 } | 452 } |
480 | 453 |
481 const std::string& profile_path = state->profile_path(); | 454 const std::string& profile_path = state->profile_path(); |
482 const NetworkProfile *profile = | 455 const NetworkProfile *profile = |
483 profile_handler_->GetProfileForPath(profile_path); | 456 network_profile_handler_->GetProfileForPath(profile_path); |
484 if (!profile) { | 457 if (!profile) { |
485 RunErrorCallback(service_path, | 458 RunErrorCallback(service_path, |
486 kUnknownProfilePath, | 459 kUnknownProfilePath, |
487 kUnknownProfilePathMessage, | 460 kUnknownProfilePathMessage, |
488 error_callback); | 461 error_callback); |
489 return; | 462 return; |
490 } | 463 } |
491 | 464 |
492 VLOG(2) << "SetProperties: Found GUID " << guid << " and profile " | 465 VLOG(2) << "SetProperties: Found GUID " << guid << " and profile " |
493 << profile->ToDebugString(); | 466 << profile->ToDebugString(); |
(...skipping 30 matching lines...) Expand all Loading... |
524 } | 497 } |
525 if (validation_result == onc::Validator::VALID_WITH_WARNINGS) | 498 if (validation_result == onc::Validator::VALID_WITH_WARNINGS) |
526 LOG(WARNING) << "Validation of ONC user settings produced warnings."; | 499 LOG(WARNING) << "Validation of ONC user settings produced warnings."; |
527 | 500 |
528 const base::DictionaryValue* policy = GetByGUID(*policies, guid); | 501 const base::DictionaryValue* policy = GetByGUID(*policies, guid); |
529 VLOG(2) << "This configuration is " << (policy ? "" : "not ") << "managed."; | 502 VLOG(2) << "This configuration is " << (policy ? "" : "not ") << "managed."; |
530 | 503 |
531 scoped_ptr<base::DictionaryValue> shill_dictionary( | 504 scoped_ptr<base::DictionaryValue> shill_dictionary( |
532 CreateShillConfiguration(*profile, guid, policy, &user_settings)); | 505 CreateShillConfiguration(*profile, guid, policy, &user_settings)); |
533 | 506 |
534 NetworkConfigurationHandler::Get()->SetProperties(service_path, | 507 network_configuration_handler_->SetProperties( |
535 *shill_dictionary, | 508 service_path, *shill_dictionary, callback, error_callback); |
536 callback, | |
537 error_callback); | |
538 } | 509 } |
539 | 510 |
540 void ManagedNetworkConfigurationHandler::CreateConfiguration( | 511 void ManagedNetworkConfigurationHandler::CreateConfiguration( |
541 const std::string& userhash, | 512 const std::string& userhash, |
542 const base::DictionaryValue& properties, | 513 const base::DictionaryValue& properties, |
543 const network_handler::StringResultCallback& callback, | 514 const network_handler::StringResultCallback& callback, |
544 const network_handler::ErrorCallback& error_callback) const { | 515 const network_handler::ErrorCallback& error_callback) const { |
545 const GuidToPolicyMap* policies = GetPoliciesForUser(userhash); | 516 const GuidToPolicyMap* policies = GetPoliciesForUser(userhash); |
546 if (!policies) { | 517 if (!policies) { |
547 RunErrorCallback("", | 518 RunErrorCallback("", |
548 kPoliciesNotInitialized, | 519 kPoliciesNotInitialized, |
549 kPoliciesNotInitializedMessage, | 520 kPoliciesNotInitializedMessage, |
550 error_callback); | 521 error_callback); |
551 return; | 522 return; |
552 } | 523 } |
553 | 524 |
554 if (FindMatchingPolicy(*policies, properties)) { | 525 if (FindMatchingPolicy(*policies, properties)) { |
555 RunErrorCallback("", | 526 RunErrorCallback("", |
556 kNetworkAlreadyConfigured, | 527 kNetworkAlreadyConfigured, |
557 kNetworkAlreadyConfiguredMessage, | 528 kNetworkAlreadyConfiguredMessage, |
558 error_callback); | 529 error_callback); |
559 } | 530 } |
560 | 531 |
561 const NetworkProfile* profile = | 532 const NetworkProfile* profile = |
562 profile_handler_->GetProfileForUserhash(userhash); | 533 network_profile_handler_->GetProfileForUserhash(userhash); |
563 if (!profile) { | 534 if (!profile) { |
564 RunErrorCallback("", | 535 RunErrorCallback("", |
565 kProfileNotInitialized, | 536 kProfileNotInitialized, |
566 kProfileNotInitializedMessage, | 537 kProfileNotInitializedMessage, |
567 error_callback); | 538 error_callback); |
568 } | 539 } |
569 | 540 |
570 // TODO(pneubeck): In case of WiFi, check that no other configuration for the | 541 // TODO(pneubeck): In case of WiFi, check that no other configuration for the |
571 // same {SSID, mode, security} exists. We don't support such multiple | 542 // same {SSID, mode, security} exists. We don't support such multiple |
572 // configurations, yet. | 543 // configurations, yet. |
573 | 544 |
574 // Generate a new GUID for this configuration. Ignore the maybe provided GUID | 545 // Generate a new GUID for this configuration. Ignore the maybe provided GUID |
575 // in |properties| as it is not our own and from an untrusted source. | 546 // in |properties| as it is not our own and from an untrusted source. |
576 std::string guid = base::GenerateGUID(); | 547 std::string guid = base::GenerateGUID(); |
577 scoped_ptr<base::DictionaryValue> shill_dictionary( | 548 scoped_ptr<base::DictionaryValue> shill_dictionary( |
578 CreateShillConfiguration(*profile, guid, NULL /*no policy*/, | 549 CreateShillConfiguration(*profile, guid, NULL /*no policy*/, |
579 &properties)); | 550 &properties)); |
580 | 551 |
581 NetworkConfigurationHandler::Get()->CreateConfiguration(*shill_dictionary, | 552 network_configuration_handler_->CreateConfiguration( |
582 callback, | 553 *shill_dictionary, callback, error_callback); |
583 error_callback); | |
584 } | 554 } |
585 | 555 |
586 void ManagedNetworkConfigurationHandler::RemoveConfiguration( | 556 void ManagedNetworkConfigurationHandler::RemoveConfiguration( |
587 const std::string& service_path, | 557 const std::string& service_path, |
588 const base::Closure& callback, | 558 const base::Closure& callback, |
589 const network_handler::ErrorCallback& error_callback) const { | 559 const network_handler::ErrorCallback& error_callback) const { |
590 NetworkConfigurationHandler::Get()->RemoveConfiguration(service_path, | 560 network_configuration_handler_->RemoveConfiguration( |
591 callback, | 561 service_path, callback, error_callback); |
592 error_callback); | |
593 } | 562 } |
594 | 563 |
595 // This class compares (entry point is Run()) |modified_policies| with the | 564 // This class compares (entry point is Run()) |modified_policies| with the |
596 // existing entries in the provided Shill profile |profile|. It fetches all | 565 // existing entries in the provided Shill profile |profile|. It fetches all |
597 // entries in parallel (GetProfileProperties), compares each entry with the | 566 // entries in parallel (GetProfileProperties), compares each entry with the |
598 // current policies (GetEntry) and adds all missing policies | 567 // current policies (GetEntry) and adds all missing policies |
599 // (~PolicyApplicator). | 568 // (~PolicyApplicator). |
600 class ManagedNetworkConfigurationHandler::PolicyApplicator | 569 class ManagedNetworkConfigurationHandler::PolicyApplicator |
601 : public base::RefCounted<PolicyApplicator> { | 570 : public base::RefCounted<PolicyApplicator> { |
602 public: | 571 public: |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 } else { | 698 } else { |
730 VLOG_IF(1, old_guid == new_guid) | 699 VLOG_IF(1, old_guid == new_guid) |
731 << "Updating previously managed configuration with the updated " | 700 << "Updating previously managed configuration with the updated " |
732 << "policy " << new_guid << "."; | 701 << "policy " << new_guid << "."; |
733 | 702 |
734 // Update the existing configuration with the maybe changed | 703 // Update the existing configuration with the maybe changed |
735 // policy. Thereby the GUID might change. | 704 // policy. Thereby the GUID might change. |
736 scoped_ptr<base::DictionaryValue> shill_dictionary = | 705 scoped_ptr<base::DictionaryValue> shill_dictionary = |
737 CreateShillConfiguration(profile_, new_guid, new_policy, | 706 CreateShillConfiguration(profile_, new_guid, new_policy, |
738 ui_data->user_settings()); | 707 ui_data->user_settings()); |
739 NetworkConfigurationHandler::Get()->CreateConfiguration( | 708 handler_->network_configuration_handler()-> |
740 *shill_dictionary, | 709 CreateConfiguration(*shill_dictionary, |
741 base::Bind(&IgnoreString), | 710 base::Bind(&IgnoreString), |
742 base::Bind(&LogErrorWithDict, FROM_HERE)); | 711 base::Bind(&LogErrorWithDict, FROM_HERE)); |
743 remaining_policies_.erase(new_guid); | 712 remaining_policies_.erase(new_guid); |
744 } | 713 } |
745 } else if (was_managed) { | 714 } else if (was_managed) { |
746 VLOG(1) << "Removing configuration previously managed by policy " | 715 VLOG(1) << "Removing configuration previously managed by policy " |
747 << old_guid << ", because the policy was removed."; | 716 << old_guid << ", because the policy was removed."; |
748 | 717 |
749 // Remove the entry, because the network was managed but isn't anymore. | 718 // Remove the entry, because the network was managed but isn't anymore. |
750 // Note: An alternative might be to preserve the user settings, but it's | 719 // Note: An alternative might be to preserve the user settings, but it's |
751 // unclear which values originating the policy should be removed. | 720 // unclear which values originating the policy should be removed. |
752 DeleteEntry(entry); | 721 DeleteEntry(entry); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 LOG(ERROR) << "Policy " << *it << " doesn't exist anymore."; | 763 LOG(ERROR) << "Policy " << *it << " doesn't exist anymore."; |
795 continue; | 764 continue; |
796 } | 765 } |
797 | 766 |
798 VLOG(1) << "Creating new configuration managed by policy " << *it | 767 VLOG(1) << "Creating new configuration managed by policy " << *it |
799 << " in profile " << profile_.ToDebugString() << "."; | 768 << " in profile " << profile_.ToDebugString() << "."; |
800 | 769 |
801 scoped_ptr<base::DictionaryValue> shill_dictionary = | 770 scoped_ptr<base::DictionaryValue> shill_dictionary = |
802 CreateShillConfiguration(profile_, *it, policy, | 771 CreateShillConfiguration(profile_, *it, policy, |
803 NULL /* no user settings */); | 772 NULL /* no user settings */); |
804 NetworkConfigurationHandler::Get()->CreateConfiguration( | 773 handler_->network_configuration_handler()->CreateConfiguration( |
805 *shill_dictionary, | 774 *shill_dictionary, |
806 base::Bind(&IgnoreString), | 775 base::Bind(&IgnoreString), |
807 base::Bind(&LogErrorWithDict, FROM_HERE)); | 776 base::Bind(&LogErrorWithDict, FROM_HERE)); |
808 } | 777 } |
809 } | 778 } |
810 | 779 |
811 std::set<std::string> remaining_policies_; | 780 std::set<std::string> remaining_policies_; |
812 base::WeakPtr<ManagedNetworkConfigurationHandler> handler_; | 781 base::WeakPtr<ManagedNetworkConfigurationHandler> handler_; |
813 NetworkProfile profile_; | 782 NetworkProfile profile_; |
814 | 783 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 policies[guid] = new_entry; | 822 policies[guid] = new_entry; |
854 | 823 |
855 const base::DictionaryValue* old_entry = old_policies[guid]; | 824 const base::DictionaryValue* old_entry = old_policies[guid]; |
856 if (!old_entry || !old_entry->Equals(new_entry)) | 825 if (!old_entry || !old_entry->Equals(new_entry)) |
857 modified_policies.insert(guid); | 826 modified_policies.insert(guid); |
858 } | 827 } |
859 | 828 |
860 STLDeleteValues(&old_policies); | 829 STLDeleteValues(&old_policies); |
861 | 830 |
862 const NetworkProfile* profile = | 831 const NetworkProfile* profile = |
863 profile_handler_->GetProfileForUserhash(userhash); | 832 network_profile_handler_->GetProfileForUserhash(userhash); |
864 if (!profile) { | 833 if (!profile) { |
865 VLOG(1) << "The relevant Shill profile isn't initialized yet, postponing " | 834 VLOG(1) << "The relevant Shill profile isn't initialized yet, postponing " |
866 << "policy application."; | 835 << "policy application."; |
867 return; | 836 return; |
868 } | 837 } |
869 | 838 |
870 scoped_refptr<PolicyApplicator> applicator = new PolicyApplicator( | 839 scoped_refptr<PolicyApplicator> applicator = new PolicyApplicator( |
871 weak_ptr_factory_.GetWeakPtr(), | 840 weak_ptr_factory_.GetWeakPtr(), |
872 *profile, | 841 *profile, |
873 &modified_policies); | 842 &modified_policies); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 } | 882 } |
914 | 883 |
915 const ManagedNetworkConfigurationHandler::GuidToPolicyMap* | 884 const ManagedNetworkConfigurationHandler::GuidToPolicyMap* |
916 ManagedNetworkConfigurationHandler::GetPoliciesForProfile( | 885 ManagedNetworkConfigurationHandler::GetPoliciesForProfile( |
917 const NetworkProfile& profile) const { | 886 const NetworkProfile& profile) const { |
918 DCHECK(profile.type() != NetworkProfile::TYPE_SHARED || | 887 DCHECK(profile.type() != NetworkProfile::TYPE_SHARED || |
919 profile.userhash.empty()); | 888 profile.userhash.empty()); |
920 return GetPoliciesForUser(profile.userhash); | 889 return GetPoliciesForUser(profile.userhash); |
921 } | 890 } |
922 | 891 |
923 ManagedNetworkConfigurationHandler::ManagedNetworkConfigurationHandler( | 892 ManagedNetworkConfigurationHandler::ManagedNetworkConfigurationHandler() |
924 NetworkProfileHandler* profile_handler) | 893 : network_state_handler_(NULL), |
925 : profile_handler_(profile_handler), | 894 network_profile_handler_(NULL), |
| 895 network_configuration_handler_(NULL), |
926 weak_ptr_factory_(this) { | 896 weak_ptr_factory_(this) { |
927 profile_handler_->AddObserver(this); | |
928 } | 897 } |
929 | 898 |
930 ManagedNetworkConfigurationHandler::~ManagedNetworkConfigurationHandler() { | 899 ManagedNetworkConfigurationHandler::~ManagedNetworkConfigurationHandler() { |
931 profile_handler_->RemoveObserver(this); | 900 network_profile_handler_->RemoveObserver(this); |
932 for (UserToPoliciesMap::iterator it = policies_by_user_.begin(); | 901 for (UserToPoliciesMap::iterator it = policies_by_user_.begin(); |
933 it != policies_by_user_.end(); ++it) { | 902 it != policies_by_user_.end(); ++it) { |
934 STLDeleteValues(&it->second); | 903 STLDeleteValues(&it->second); |
935 } | 904 } |
936 } | 905 } |
937 | 906 |
| 907 void ManagedNetworkConfigurationHandler::Init( |
| 908 NetworkStateHandler* network_state_handler, |
| 909 NetworkProfileHandler* network_profile_handler, |
| 910 NetworkConfigurationHandler* network_configuration_handler) { |
| 911 network_state_handler_ = network_state_handler; |
| 912 network_profile_handler_ = network_profile_handler; |
| 913 network_configuration_handler_ = network_configuration_handler; |
| 914 network_profile_handler_->AddObserver(this); |
| 915 } |
| 916 |
938 } // namespace chromeos | 917 } // namespace chromeos |
OLD | NEW |