| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/webui/policy_ui_handler.h" | 5 #include "chrome/browser/ui/webui/policy_ui_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 void OnDeviceLocalAccountsChanged() override; | 302 void OnDeviceLocalAccountsChanged() override; |
| 303 | 303 |
| 304 private: | 304 private: |
| 305 const std::string user_id_; | 305 const std::string user_id_; |
| 306 policy::DeviceLocalAccountPolicyService* service_; | 306 policy::DeviceLocalAccountPolicyService* service_; |
| 307 | 307 |
| 308 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyStatusProvider); | 308 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyStatusProvider); |
| 309 }; | 309 }; |
| 310 | 310 |
| 311 // Provides status for DeviceActiveDirectoryPolicyManager. | 311 // Provides status for DeviceActiveDirectoryPolicyManager. |
| 312 class DeviceActiveDirectoryPolicyStatusProvider : public PolicyStatusProvider { | 312 class DeviceActiveDirectoryPolicyStatusProvider |
| 313 : public PolicyStatusProvider, |
| 314 public policy::CloudPolicyStore::Observer { |
| 313 public: | 315 public: |
| 314 explicit DeviceActiveDirectoryPolicyStatusProvider( | 316 explicit DeviceActiveDirectoryPolicyStatusProvider( |
| 315 policy::DeviceActiveDirectoryPolicyManager* manager); | 317 policy::DeviceActiveDirectoryPolicyManager* manager); |
| 316 ~DeviceActiveDirectoryPolicyStatusProvider() override; | 318 ~DeviceActiveDirectoryPolicyStatusProvider() override; |
| 317 | 319 |
| 318 // PolicyStatusProvider implementation. | 320 // PolicyStatusProvider implementation. |
| 319 void GetStatus(base::DictionaryValue* dict) override; | 321 void GetStatus(base::DictionaryValue* dict) override; |
| 320 | 322 |
| 323 // policy::CloudPolicyStore::Observer implementation. |
| 324 void OnStoreLoaded(policy::CloudPolicyStore* store) override; |
| 325 void OnStoreError(policy::CloudPolicyStore* store) override; |
| 326 |
| 321 private: | 327 private: |
| 322 const policy::CloudPolicyStore* store_; | 328 policy::CloudPolicyStore* store_; |
| 323 | 329 |
| 324 DISALLOW_COPY_AND_ASSIGN(DeviceActiveDirectoryPolicyStatusProvider); | 330 DISALLOW_COPY_AND_ASSIGN(DeviceActiveDirectoryPolicyStatusProvider); |
| 325 }; | 331 }; |
| 326 #endif | 332 #endif |
| 327 | 333 |
| 328 PolicyStatusProvider::PolicyStatusProvider() {} | 334 PolicyStatusProvider::PolicyStatusProvider() {} |
| 329 | 335 |
| 330 PolicyStatusProvider::~PolicyStatusProvider() {} | 336 PolicyStatusProvider::~PolicyStatusProvider() {} |
| 331 | 337 |
| 332 void PolicyStatusProvider::SetStatusChangeCallback( | 338 void PolicyStatusProvider::SetStatusChangeCallback( |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 NotifyStatusChange(); | 436 NotifyStatusChange(); |
| 431 } | 437 } |
| 432 | 438 |
| 433 void DeviceLocalAccountPolicyStatusProvider::OnDeviceLocalAccountsChanged() { | 439 void DeviceLocalAccountPolicyStatusProvider::OnDeviceLocalAccountsChanged() { |
| 434 NotifyStatusChange(); | 440 NotifyStatusChange(); |
| 435 } | 441 } |
| 436 | 442 |
| 437 DeviceActiveDirectoryPolicyStatusProvider:: | 443 DeviceActiveDirectoryPolicyStatusProvider:: |
| 438 DeviceActiveDirectoryPolicyStatusProvider( | 444 DeviceActiveDirectoryPolicyStatusProvider( |
| 439 policy::DeviceActiveDirectoryPolicyManager* manager) | 445 policy::DeviceActiveDirectoryPolicyManager* manager) |
| 440 : store_(manager->store()) {} | 446 : store_(manager->store()) { |
| 447 store_->AddObserver(this); |
| 448 } |
| 441 | 449 |
| 442 DeviceActiveDirectoryPolicyStatusProvider:: | 450 DeviceActiveDirectoryPolicyStatusProvider:: |
| 443 ~DeviceActiveDirectoryPolicyStatusProvider() {} | 451 ~DeviceActiveDirectoryPolicyStatusProvider() { |
| 452 store_->RemoveObserver(this); |
| 453 } |
| 444 | 454 |
| 445 // TODO(tnagel): Provide more details and/or remove unused fields from UI. See | 455 // TODO(tnagel): Provide more details and/or remove unused fields from UI. See |
| 446 // https://crbug.com/664747. | 456 // https://crbug.com/664747. |
| 447 void DeviceActiveDirectoryPolicyStatusProvider::GetStatus( | 457 void DeviceActiveDirectoryPolicyStatusProvider::GetStatus( |
| 448 base::DictionaryValue* dict) { | 458 base::DictionaryValue* dict) { |
| 449 base::string16 status = | 459 base::string16 status = |
| 450 policy::FormatStoreStatus(store_->status(), store_->validation_status()); | 460 policy::FormatStoreStatus(store_->status(), store_->validation_status()); |
| 451 dict->SetString("status", status); | 461 dict->SetString("status", status); |
| 452 } | 462 } |
| 453 | 463 |
| 464 void DeviceActiveDirectoryPolicyStatusProvider::OnStoreLoaded( |
| 465 policy::CloudPolicyStore* store) { |
| 466 NotifyStatusChange(); |
| 467 } |
| 468 |
| 469 void DeviceActiveDirectoryPolicyStatusProvider::OnStoreError( |
| 470 policy::CloudPolicyStore* store) { |
| 471 NotifyStatusChange(); |
| 472 } |
| 473 |
| 454 #endif // defined(OS_CHROMEOS) | 474 #endif // defined(OS_CHROMEOS) |
| 455 | 475 |
| 456 PolicyUIHandler::PolicyUIHandler() | 476 PolicyUIHandler::PolicyUIHandler() |
| 457 : weak_factory_(this) { | 477 : weak_factory_(this) { |
| 458 } | 478 } |
| 459 | 479 |
| 460 PolicyUIHandler::~PolicyUIHandler() { | 480 PolicyUIHandler::~PolicyUIHandler() { |
| 461 GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_CHROME, this); | 481 GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_CHROME, this); |
| 462 GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_EXTENSIONS, this); | 482 GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_EXTENSIONS, this); |
| 463 policy::SchemaRegistry* registry = | 483 policy::SchemaRegistry* registry = |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 } | 814 } |
| 795 | 815 |
| 796 void PolicyUIHandler::OnRefreshPoliciesDone() const { | 816 void PolicyUIHandler::OnRefreshPoliciesDone() const { |
| 797 web_ui()->CallJavascriptFunctionUnsafe("policy.Page.reloadPoliciesDone"); | 817 web_ui()->CallJavascriptFunctionUnsafe("policy.Page.reloadPoliciesDone"); |
| 798 } | 818 } |
| 799 | 819 |
| 800 policy::PolicyService* PolicyUIHandler::GetPolicyService() const { | 820 policy::PolicyService* PolicyUIHandler::GetPolicyService() const { |
| 801 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext( | 821 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext( |
| 802 web_ui()->GetWebContents()->GetBrowserContext())->policy_service(); | 822 web_ui()->GetWebContents()->GetBrowserContext())->policy_service(); |
| 803 } | 823 } |
| OLD | NEW |