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