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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 // Skip this extension if it's not an enterprise extension. | 578 // Skip this extension if it's not an enterprise extension. |
579 if (!extension->manifest()->HasPath( | 579 if (!extension->manifest()->HasPath( |
580 extensions::manifest_keys::kStorageManagedSchema)) | 580 extensions::manifest_keys::kStorageManagedSchema)) |
581 continue; | 581 continue; |
582 base::DictionaryValue* extension_value = new base::DictionaryValue; | 582 base::DictionaryValue* extension_value = new base::DictionaryValue; |
583 extension_value->SetString("name", extension->name()); | 583 extension_value->SetString("name", extension->name()); |
584 const policy::Schema* schema = | 584 const policy::Schema* schema = |
585 schema_map->GetSchema(policy::PolicyNamespace( | 585 schema_map->GetSchema(policy::PolicyNamespace( |
586 policy::POLICY_DOMAIN_EXTENSIONS, extension->id())); | 586 policy::POLICY_DOMAIN_EXTENSIONS, extension->id())); |
587 base::DictionaryValue* policy_names = new base::DictionaryValue; | 587 base::DictionaryValue* policy_names = new base::DictionaryValue; |
588 if (schema) { | 588 if (schema && schema->valid()) { |
589 // Get policy names from the extension's policy schema. | 589 // Get policy names from the extension's policy schema. |
590 // Store in a map, not an array, for faster lookup on JS side. | 590 // Store in a map, not an array, for faster lookup on JS side. |
591 for (policy::Schema::Iterator prop = schema->GetPropertiesIterator(); | 591 for (policy::Schema::Iterator prop = schema->GetPropertiesIterator(); |
592 !prop.IsAtEnd(); prop.Advance()) { | 592 !prop.IsAtEnd(); prop.Advance()) { |
593 policy_names->SetBoolean(prop.key(), true); | 593 policy_names->SetBoolean(prop.key(), true); |
594 } | 594 } |
595 } | 595 } |
596 extension_value->Set("policyNames", policy_names); | 596 extension_value->Set("policyNames", policy_names); |
597 extension_policy_names->Set(extension->id(), extension_value); | 597 extension_policy_names->Set(extension->id(), extension_value); |
598 } | 598 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 } | 725 } |
726 | 726 |
727 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 727 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
728 web_ui->AddMessageHandler(new PolicyUIHandler); | 728 web_ui->AddMessageHandler(new PolicyUIHandler); |
729 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 729 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
730 CreatePolicyUIHTMLSource()); | 730 CreatePolicyUIHTMLSource()); |
731 } | 731 } |
732 | 732 |
733 PolicyUI::~PolicyUI() { | 733 PolicyUI::~PolicyUI() { |
734 } | 734 } |
OLD | NEW |