| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" | 57 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" |
| 58 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" | 58 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 61 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 62 #include "chrome/browser/extensions/extension_service.h" | 62 #include "chrome/browser/extensions/extension_service.h" |
| 63 #include "chrome/browser/extensions/extension_system.h" | 63 #include "chrome/browser/extensions/extension_system.h" |
| 64 #include "chrome/browser/policy/policy_domain_descriptor.h" | 64 #include "chrome/browser/policy/policy_domain_descriptor.h" |
| 65 #include "chrome/common/extensions/extension.h" | 65 #include "chrome/common/extensions/extension.h" |
| 66 #include "chrome/common/extensions/extension_set.h" | 66 #include "chrome/common/extensions/extension_set.h" |
| 67 #include "components/policy/core/common/policy_schema.h" | 67 #include "components/policy/core/common/schema.h" |
| 68 #include "extensions/common/manifest.h" | 68 #include "extensions/common/manifest.h" |
| 69 #include "extensions/common/manifest_constants.h" | 69 #include "extensions/common/manifest_constants.h" |
| 70 #endif | 70 #endif |
| 71 | 71 |
| 72 namespace em = enterprise_management; | 72 namespace em = enterprise_management; |
| 73 | 73 |
| 74 namespace { | 74 namespace { |
| 75 | 75 |
| 76 content::WebUIDataSource* CreatePolicyUIHTMLSource() { | 76 content::WebUIDataSource* CreatePolicyUIHTMLSource() { |
| 77 content::WebUIDataSource* source = | 77 content::WebUIDataSource* source = |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 extensions::manifest_keys::kStorageManagedSchema)) | 572 extensions::manifest_keys::kStorageManagedSchema)) |
| 573 continue; | 573 continue; |
| 574 base::DictionaryValue* extension_value = new base::DictionaryValue; | 574 base::DictionaryValue* extension_value = new base::DictionaryValue; |
| 575 extension_value->SetString("name", extension->name()); | 575 extension_value->SetString("name", extension->name()); |
| 576 policy::PolicyDomainDescriptor::SchemaMap::const_iterator schema = | 576 policy::PolicyDomainDescriptor::SchemaMap::const_iterator schema = |
| 577 schema_map.find(extension->id()); | 577 schema_map.find(extension->id()); |
| 578 base::DictionaryValue* policy_names = new base::DictionaryValue; | 578 base::DictionaryValue* policy_names = new base::DictionaryValue; |
| 579 if (schema != schema_map.end()) { | 579 if (schema != schema_map.end()) { |
| 580 // Get policy names from the extension's policy schema. | 580 // Get policy names from the extension's policy schema. |
| 581 // Store in a map, not an array, for faster lookup on JS side. | 581 // Store in a map, not an array, for faster lookup on JS side. |
| 582 const policy::PolicySchemaMap* policies = schema->second->GetProperties(); | 582 policy::Schema policy_schema = schema->second; |
| 583 policy::PolicySchemaMap::const_iterator it_policies; | 583 for (policy::Schema::Iterator it_policies = |
| 584 for (it_policies = policies->begin(); it_policies != policies->end(); | 584 policy_schema.GetPropertiesIterator(); |
| 585 ++it_policies) { | 585 !it_policies.IsAtEnd(); it_policies.Advance()) { |
| 586 policy_names->SetBoolean(it_policies->first, true); | 586 policy_names->SetBoolean(it_policies.key(), true); |
| 587 } | 587 } |
| 588 } | 588 } |
| 589 extension_value->Set("policyNames", policy_names); | 589 extension_value->Set("policyNames", policy_names); |
| 590 extension_policy_names->Set(extension->id(), extension_value); | 590 extension_policy_names->Set(extension->id(), extension_value); |
| 591 } | 591 } |
| 592 names.Set("extensionPolicyNames", extension_policy_names); | 592 names.Set("extensionPolicyNames", extension_policy_names); |
| 593 #endif | 593 #endif |
| 594 | 594 |
| 595 web_ui()->CallJavascriptFunction("policy.Page.setPolicyNames", names); | 595 web_ui()->CallJavascriptFunction("policy.Page.setPolicyNames", names); |
| 596 } | 596 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 } | 718 } |
| 719 | 719 |
| 720 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 720 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 721 web_ui->AddMessageHandler(new PolicyUIHandler); | 721 web_ui->AddMessageHandler(new PolicyUIHandler); |
| 722 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 722 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
| 723 CreatePolicyUIHTMLSource()); | 723 CreatePolicyUIHTMLSource()); |
| 724 } | 724 } |
| 725 | 725 |
| 726 PolicyUI::~PolicyUI() { | 726 PolicyUI::~PolicyUI() { |
| 727 } | 727 } |
| OLD | NEW |