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.h" | 5 #include "chrome/browser/ui/webui/policy_ui.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 33 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
34 #include "components/policy/core/common/cloud/cloud_policy_validator.h" | 34 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
35 #include "components/policy/core/common/policy_map.h" | 35 #include "components/policy/core/common/policy_map.h" |
36 #include "components/policy/core/common/policy_namespace.h" | 36 #include "components/policy/core/common/policy_namespace.h" |
37 #include "components/policy/core/common/policy_service.h" | 37 #include "components/policy/core/common/policy_service.h" |
38 #include "components/policy/core/common/policy_types.h" | 38 #include "components/policy/core/common/policy_types.h" |
39 #include "components/policy/core/common/remote_commands/remote_commands_service.
h" | 39 #include "components/policy/core/common/remote_commands/remote_commands_service.
h" |
40 #include "components/policy/core/common/schema.h" | 40 #include "components/policy/core/common/schema.h" |
41 #include "components/policy/core/common/schema_map.h" | 41 #include "components/policy/core/common/schema_map.h" |
42 #include "components/policy/core/common/schema_registry.h" | 42 #include "components/policy/core/common/schema_registry.h" |
| 43 #include "components/user_manager/user_id.h" |
43 #include "content/public/browser/web_contents.h" | 44 #include "content/public/browser/web_contents.h" |
44 #include "content/public/browser/web_ui.h" | 45 #include "content/public/browser/web_ui.h" |
45 #include "content/public/browser/web_ui_data_source.h" | 46 #include "content/public/browser/web_ui_data_source.h" |
46 #include "content/public/browser/web_ui_message_handler.h" | 47 #include "content/public/browser/web_ui_message_handler.h" |
47 #include "google_apis/gaia/gaia_auth_util.h" | 48 #include "google_apis/gaia/gaia_auth_util.h" |
48 #include "grit/browser_resources.h" | 49 #include "grit/browser_resources.h" |
49 #include "grit/components_strings.h" | 50 #include "grit/components_strings.h" |
50 #include "policy/policy_constants.h" | 51 #include "policy/policy_constants.h" |
51 #include "policy/proto/device_management_backend.pb.h" | 52 #include "policy/proto/device_management_backend.pb.h" |
52 #include "ui/base/l10n/l10n_util.h" | 53 #include "ui/base/l10n/l10n_util.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 // associated with the device-local account specified by |user_id| at | 325 // associated with the device-local account specified by |user_id| at |
325 // construction time. The indirection via user ID and | 326 // construction time. The indirection via user ID and |
326 // DeviceLocalAccountPolicyService is necessary because the device-local account | 327 // DeviceLocalAccountPolicyService is necessary because the device-local account |
327 // may go away any time behind the scenes, at which point the status message | 328 // may go away any time behind the scenes, at which point the status message |
328 // text will indicate CloudPolicyStore::STATUS_BAD_STATE. | 329 // text will indicate CloudPolicyStore::STATUS_BAD_STATE. |
329 class DeviceLocalAccountPolicyStatusProvider | 330 class DeviceLocalAccountPolicyStatusProvider |
330 : public CloudPolicyStatusProvider, | 331 : public CloudPolicyStatusProvider, |
331 public policy::DeviceLocalAccountPolicyService::Observer { | 332 public policy::DeviceLocalAccountPolicyService::Observer { |
332 public: | 333 public: |
333 DeviceLocalAccountPolicyStatusProvider( | 334 DeviceLocalAccountPolicyStatusProvider( |
334 const std::string& user_id, | 335 const user_manager::UserID& user_id, |
335 policy::DeviceLocalAccountPolicyService* service); | 336 policy::DeviceLocalAccountPolicyService* service); |
336 ~DeviceLocalAccountPolicyStatusProvider() override; | 337 ~DeviceLocalAccountPolicyStatusProvider() override; |
337 | 338 |
338 // CloudPolicyStatusProvider implementation. | 339 // CloudPolicyStatusProvider implementation. |
339 void GetStatus(base::DictionaryValue* dict) override; | 340 void GetStatus(base::DictionaryValue* dict) override; |
340 | 341 |
341 // policy::DeviceLocalAccountPolicyService::Observer implementation. | 342 // policy::DeviceLocalAccountPolicyService::Observer implementation. |
342 void OnPolicyUpdated(const std::string& user_id) override; | 343 void OnPolicyUpdated(const user_manager::UserID& user_id) override; |
343 void OnDeviceLocalAccountsChanged() override; | 344 void OnDeviceLocalAccountsChanged() override; |
344 | 345 |
345 private: | 346 private: |
346 const std::string user_id_; | 347 const user_manager::UserID user_id_; |
347 policy::DeviceLocalAccountPolicyService* service_; | 348 policy::DeviceLocalAccountPolicyService* service_; |
348 | 349 |
349 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyStatusProvider); | 350 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyStatusProvider); |
350 }; | 351 }; |
351 #endif | 352 #endif |
352 | 353 |
353 // The JavaScript message handler for the chrome://policy page. | 354 // The JavaScript message handler for the chrome://policy page. |
354 class PolicyUIHandler : public content::WebUIMessageHandler, | 355 class PolicyUIHandler : public content::WebUIMessageHandler, |
355 #if defined(ENABLE_EXTENSIONS) | 356 #if defined(ENABLE_EXTENSIONS) |
356 public extensions::ExtensionRegistryObserver, | 357 public extensions::ExtensionRegistryObserver, |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 | 490 |
490 DevicePolicyStatusProvider::~DevicePolicyStatusProvider() { | 491 DevicePolicyStatusProvider::~DevicePolicyStatusProvider() { |
491 } | 492 } |
492 | 493 |
493 void DevicePolicyStatusProvider::GetStatus(base::DictionaryValue* dict) { | 494 void DevicePolicyStatusProvider::GetStatus(base::DictionaryValue* dict) { |
494 GetStatusFromCore(core_, dict); | 495 GetStatusFromCore(core_, dict); |
495 dict->SetString("domain", domain_); | 496 dict->SetString("domain", domain_); |
496 } | 497 } |
497 | 498 |
498 DeviceLocalAccountPolicyStatusProvider::DeviceLocalAccountPolicyStatusProvider( | 499 DeviceLocalAccountPolicyStatusProvider::DeviceLocalAccountPolicyStatusProvider( |
499 const std::string& user_id, | 500 const user_manager::UserID& user_id, |
500 policy::DeviceLocalAccountPolicyService* service) | 501 policy::DeviceLocalAccountPolicyService* service) |
501 : user_id_(user_id), | 502 : user_id_(user_id), |
502 service_(service) { | 503 service_(service) { |
503 service_->AddObserver(this); | 504 service_->AddObserver(this); |
504 } | 505 } |
505 | 506 |
506 DeviceLocalAccountPolicyStatusProvider:: | 507 DeviceLocalAccountPolicyStatusProvider:: |
507 ~DeviceLocalAccountPolicyStatusProvider() { | 508 ~DeviceLocalAccountPolicyStatusProvider() { |
508 service_->RemoveObserver(this); | 509 service_->RemoveObserver(this); |
509 } | 510 } |
(...skipping 10 matching lines...) Expand all Loading... |
520 policy::FormatStoreStatus( | 521 policy::FormatStoreStatus( |
521 policy::CloudPolicyStore::STATUS_BAD_STATE, | 522 policy::CloudPolicyStore::STATUS_BAD_STATE, |
522 policy::CloudPolicyValidatorBase::VALIDATION_OK)); | 523 policy::CloudPolicyValidatorBase::VALIDATION_OK)); |
523 dict->SetString("username", std::string()); | 524 dict->SetString("username", std::string()); |
524 } | 525 } |
525 ExtractDomainFromUsername(dict); | 526 ExtractDomainFromUsername(dict); |
526 dict->SetBoolean("publicAccount", true); | 527 dict->SetBoolean("publicAccount", true); |
527 } | 528 } |
528 | 529 |
529 void DeviceLocalAccountPolicyStatusProvider::OnPolicyUpdated( | 530 void DeviceLocalAccountPolicyStatusProvider::OnPolicyUpdated( |
530 const std::string& user_id) { | 531 const user_manager::UserID& user_id) { |
531 if (user_id == user_id_) | 532 if (user_id == user_id_) |
532 NotifyStatusChange(); | 533 NotifyStatusChange(); |
533 } | 534 } |
534 | 535 |
535 void DeviceLocalAccountPolicyStatusProvider::OnDeviceLocalAccountsChanged() { | 536 void DeviceLocalAccountPolicyStatusProvider::OnDeviceLocalAccountsChanged() { |
536 NotifyStatusChange(); | 537 NotifyStatusChange(); |
537 } | 538 } |
538 #endif | 539 #endif |
539 | 540 |
540 PolicyUIHandler::PolicyUIHandler() | 541 PolicyUIHandler::PolicyUIHandler() |
(...skipping 22 matching lines...) Expand all Loading... |
563 device_status_provider_.reset(new DevicePolicyStatusProvider(connector)); | 564 device_status_provider_.reset(new DevicePolicyStatusProvider(connector)); |
564 | 565 |
565 const user_manager::UserManager* user_manager = | 566 const user_manager::UserManager* user_manager = |
566 user_manager::UserManager::Get(); | 567 user_manager::UserManager::Get(); |
567 if (user_manager->IsLoggedInAsPublicAccount()) { | 568 if (user_manager->IsLoggedInAsPublicAccount()) { |
568 policy::DeviceLocalAccountPolicyService* local_account_service = | 569 policy::DeviceLocalAccountPolicyService* local_account_service = |
569 connector->GetDeviceLocalAccountPolicyService(); | 570 connector->GetDeviceLocalAccountPolicyService(); |
570 if (local_account_service) { | 571 if (local_account_service) { |
571 user_status_provider_.reset( | 572 user_status_provider_.reset( |
572 new DeviceLocalAccountPolicyStatusProvider( | 573 new DeviceLocalAccountPolicyStatusProvider( |
573 user_manager->GetLoggedInUser()->email(), local_account_service)); | 574 user_manager->GetLoggedInUser()->GetUserID(), local_account_servic
e)); |
574 } | 575 } |
575 } else { | 576 } else { |
576 policy::UserCloudPolicyManagerChromeOS* user_cloud_policy_manager = | 577 policy::UserCloudPolicyManagerChromeOS* user_cloud_policy_manager = |
577 policy::UserCloudPolicyManagerFactoryChromeOS::GetForProfile( | 578 policy::UserCloudPolicyManagerFactoryChromeOS::GetForProfile( |
578 Profile::FromWebUI(web_ui())); | 579 Profile::FromWebUI(web_ui())); |
579 if (user_cloud_policy_manager) { | 580 if (user_cloud_policy_manager) { |
580 user_status_provider_.reset( | 581 user_status_provider_.reset( |
581 new UserPolicyStatusProvider(user_cloud_policy_manager->core())); | 582 new UserPolicyStatusProvider(user_cloud_policy_manager->core())); |
582 } | 583 } |
583 } | 584 } |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 } | 838 } |
838 | 839 |
839 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 840 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
840 web_ui->AddMessageHandler(new PolicyUIHandler); | 841 web_ui->AddMessageHandler(new PolicyUIHandler); |
841 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 842 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
842 CreatePolicyUIHTMLSource()); | 843 CreatePolicyUIHTMLSource()); |
843 } | 844 } |
844 | 845 |
845 PolicyUI::~PolicyUI() { | 846 PolicyUI::~PolicyUI() { |
846 } | 847 } |
OLD | NEW |