Chromium Code Reviews| 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" | 
| 11 #include "base/logging.h" | 11 #include "base/logging.h" | 
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" | 
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" | 
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" | 
| 15 #include "base/time.h" | 15 #include "base/time.h" | 
| 16 #include "base/values.h" | 16 #include "base/values.h" | 
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" | 
| 18 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" | 
| 19 #include "chrome/browser/extensions/extension_system.h" | 19 #include "chrome/browser/extensions/extension_system.h" | 
| 20 #include "chrome/browser/policy/browser_policy_connector.h" | 20 #include "chrome/browser/policy/browser_policy_connector.h" | 
| 21 #include "chrome/browser/policy/cloud/cloud_policy_client.h" | 21 #include "chrome/browser/policy/cloud/cloud_policy_client.h" | 
| 22 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" | 22 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" | 
| 23 #include "chrome/browser/policy/cloud/cloud_policy_core.h" | 23 #include "chrome/browser/policy/cloud/cloud_policy_core.h" | 
| 24 #include "chrome/browser/policy/cloud/cloud_policy_refresh_scheduler.h" | 24 #include "chrome/browser/policy/cloud/cloud_policy_refresh_scheduler.h" | 
| 25 #include "chrome/browser/policy/cloud/cloud_policy_store.h" | 25 #include "chrome/browser/policy/cloud/cloud_policy_store.h" | 
| 26 #include "chrome/browser/policy/cloud/cloud_policy_validator.h" | 26 #include "chrome/browser/policy/cloud/cloud_policy_validator.h" | 
| 27 #include "chrome/browser/policy/cloud/message_util.h" | 27 #include "chrome/browser/policy/cloud/message_util.h" | 
| 28 #include "chrome/browser/policy/configuration_policy_handler_list.h" | 28 #include "chrome/browser/policy/configuration_policy_handler_list.h" | 
| 29 #include "chrome/browser/policy/policy_domain_descriptor.h" | |
| 29 #include "chrome/browser/policy/policy_error_map.h" | 30 #include "chrome/browser/policy/policy_error_map.h" | 
| 30 #include "chrome/browser/policy/policy_map.h" | 31 #include "chrome/browser/policy/policy_map.h" | 
| 32 #include "chrome/browser/policy/policy_schema.h" | |
| 31 #include "chrome/browser/policy/policy_service.h" | 33 #include "chrome/browser/policy/policy_service.h" | 
| 32 #include "chrome/browser/policy/policy_types.h" | 34 #include "chrome/browser/policy/policy_types.h" | 
| 33 #include "chrome/browser/policy/profile_policy_connector.h" | 35 #include "chrome/browser/policy/profile_policy_connector.h" | 
| 34 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 36 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 
| 35 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" | 37 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" | 
| 36 #include "chrome/browser/profiles/profile.h" | 38 #include "chrome/browser/profiles/profile.h" | 
| 37 #include "chrome/common/extensions/extension.h" | 39 #include "chrome/common/extensions/extension.h" | 
| 38 #include "chrome/common/extensions/extension_set.h" | 40 #include "chrome/common/extensions/extension_set.h" | 
| 39 #include "chrome/common/extensions/manifest.h" | 41 #include "chrome/common/extensions/manifest.h" | 
| 40 #include "chrome/common/time_format.h" | 42 #include "chrome/common/time_format.h" | 
| 41 #include "chrome/common/url_constants.h" | 43 #include "chrome/common/url_constants.h" | 
| 44 #include "content/public/browser/notification_registrar.h" | |
| 42 #include "content/public/browser/web_ui.h" | 45 #include "content/public/browser/web_ui.h" | 
| 43 #include "content/public/browser/web_ui_data_source.h" | 46 #include "content/public/browser/web_ui_data_source.h" | 
| 44 #include "content/public/browser/web_ui_message_handler.h" | 47 #include "content/public/browser/web_ui_message_handler.h" | 
| 45 #include "google_apis/gaia/gaia_auth_util.h" | 48 #include "google_apis/gaia/gaia_auth_util.h" | 
| 46 #include "grit/browser_resources.h" | 49 #include "grit/browser_resources.h" | 
| 47 #include "grit/generated_resources.h" | 50 #include "grit/generated_resources.h" | 
| 48 #include "policy/policy_constants.h" | 51 #include "policy/policy_constants.h" | 
| 49 #include "ui/base/l10n/l10n_util.h" | 52 #include "ui/base/l10n/l10n_util.h" | 
| 50 | 53 | 
| 51 #if defined(OS_CHROMEOS) | 54 #if defined(OS_CHROMEOS) | 
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 | 259 | 
| 257 private: | 260 private: | 
| 258 const std::string user_id_; | 261 const std::string user_id_; | 
| 259 policy::DeviceLocalAccountPolicyService* service_; | 262 policy::DeviceLocalAccountPolicyService* service_; | 
| 260 | 263 | 
| 261 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyStatusProvider); | 264 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyStatusProvider); | 
| 262 }; | 265 }; | 
| 263 #endif | 266 #endif | 
| 264 | 267 | 
| 265 // The JavaScript message handler for the chrome://policy page. | 268 // The JavaScript message handler for the chrome://policy page. | 
| 266 class PolicyUIHandler : public content::WebUIMessageHandler, | 269 class PolicyUIHandler : public content::NotificationObserver, | 
| 
 
Joao da Silva
2013/06/19 16:35:17
#include "content/public/browser/notification_obse
 
anitawoodruff
2013/06/20 09:13:32
Done.
 
 | |
| 270 public content::WebUIMessageHandler, | |
| 267 public policy::PolicyService::Observer { | 271 public policy::PolicyService::Observer { | 
| 268 public: | 272 public: | 
| 269 PolicyUIHandler(); | 273 PolicyUIHandler(); | 
| 270 virtual ~PolicyUIHandler(); | 274 virtual ~PolicyUIHandler(); | 
| 271 | 275 | 
| 276 // content::NotificationObserver implementation. | |
| 277 virtual void Observe(int type, | |
| 278 const content::NotificationSource& source, | |
| 279 const content::NotificationDetails& details) OVERRIDE; | |
| 280 | |
| 272 // content::WebUIMessageHandler implementation. | 281 // content::WebUIMessageHandler implementation. | 
| 273 virtual void RegisterMessages() OVERRIDE; | 282 virtual void RegisterMessages() OVERRIDE; | 
| 274 | 283 | 
| 275 // policy::PolicyService::Observer implementation. | 284 // policy::PolicyService::Observer implementation. | 
| 276 virtual void OnPolicyUpdated(const policy::PolicyNamespace& ns, | 285 virtual void OnPolicyUpdated(const policy::PolicyNamespace& ns, | 
| 277 const policy::PolicyMap& previous, | 286 const policy::PolicyMap& previous, | 
| 278 const policy::PolicyMap& current) OVERRIDE; | 287 const policy::PolicyMap& current) OVERRIDE; | 
| 279 | 288 | 
| 280 private: | 289 private: | 
| 281 // Send a dictionary containing the names of all known policies to the UI. | 290 // Send a dictionary containing the names of all known policies to the UI. | 
| (...skipping 27 matching lines...) Expand all Loading... | |
| 309 bool initialized_; | 318 bool initialized_; | 
| 310 std::string device_domain_; | 319 std::string device_domain_; | 
| 311 base::WeakPtrFactory<PolicyUIHandler> weak_factory_; | 320 base::WeakPtrFactory<PolicyUIHandler> weak_factory_; | 
| 312 | 321 | 
| 313 // Providers that supply status dictionaries for user and device policy, | 322 // Providers that supply status dictionaries for user and device policy, | 
| 314 // respectively. These are created on initialization time as appropriate for | 323 // respectively. These are created on initialization time as appropriate for | 
| 315 // the platform (Chrome OS / desktop) and type of policy that is in effect. | 324 // the platform (Chrome OS / desktop) and type of policy that is in effect. | 
| 316 scoped_ptr<CloudPolicyStatusProvider> user_status_provider_; | 325 scoped_ptr<CloudPolicyStatusProvider> user_status_provider_; | 
| 317 scoped_ptr<CloudPolicyStatusProvider> device_status_provider_; | 326 scoped_ptr<CloudPolicyStatusProvider> device_status_provider_; | 
| 318 | 327 | 
| 319 DISALLOW_COPY_AND_ASSIGN(PolicyUIHandler); | 328 DISALLOW_COPY_AND_ASSIGN(PolicyUIHandler); | 
| 
 
Joao da Silva
2013/06/19 16:35:17
This should be the last statement within the class
 
anitawoodruff
2013/06/20 09:13:32
Done.
 
 | |
| 329 | |
| 330 content::NotificationRegistrar registrar_; | |
| 320 }; | 331 }; | 
| 321 | 332 | 
| 322 CloudPolicyStatusProvider::CloudPolicyStatusProvider() { | 333 CloudPolicyStatusProvider::CloudPolicyStatusProvider() { | 
| 323 } | 334 } | 
| 324 | 335 | 
| 325 CloudPolicyStatusProvider::~CloudPolicyStatusProvider() { | 336 CloudPolicyStatusProvider::~CloudPolicyStatusProvider() { | 
| 326 } | 337 } | 
| 327 | 338 | 
| 328 void CloudPolicyStatusProvider::SetStatusChangeCallback( | 339 void CloudPolicyStatusProvider::SetStatusChangeCallback( | 
| 329 const base::Closure& callback) { | 340 const base::Closure& callback) { | 
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 } | 443 } | 
| 433 #endif | 444 #endif | 
| 434 | 445 | 
| 435 PolicyUIHandler::PolicyUIHandler() | 446 PolicyUIHandler::PolicyUIHandler() | 
| 436 : weak_factory_(this) { | 447 : weak_factory_(this) { | 
| 437 } | 448 } | 
| 438 | 449 | 
| 439 PolicyUIHandler::~PolicyUIHandler() { | 450 PolicyUIHandler::~PolicyUIHandler() { | 
| 440 GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_CHROME, this); | 451 GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_CHROME, this); | 
| 441 GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_EXTENSIONS, this); | 452 GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_EXTENSIONS, this); | 
| 453 registrar_.Remove(this, chrome::NOTIFICATION_EXTENSION_LOADED, | |
| 454 content::NotificationService::AllSources()); | |
| 455 registrar_.Remove(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | |
| 456 content::NotificationService::AllSources()); | |
| 
 
Joao da Silva
2013/06/19 16:35:17
This is not needed, the registrar_ does it automat
 
anitawoodruff
2013/06/20 09:13:32
Done.
 
 | |
| 442 } | 457 } | 
| 443 | 458 | 
| 444 void PolicyUIHandler::RegisterMessages() { | 459 void PolicyUIHandler::RegisterMessages() { | 
| 445 #if defined(OS_CHROMEOS) | 460 #if defined(OS_CHROMEOS) | 
| 446 policy::BrowserPolicyConnector* connector = | 461 policy::BrowserPolicyConnector* connector = | 
| 447 g_browser_process->browser_policy_connector(); | 462 g_browser_process->browser_policy_connector(); | 
| 448 if (connector->IsEnterpriseManaged()) | 463 if (connector->IsEnterpriseManaged()) | 
| 449 device_status_provider_.reset(new DevicePolicyStatusProvider(connector)); | 464 device_status_provider_.reset(new DevicePolicyStatusProvider(connector)); | 
| 450 | 465 | 
| 451 const chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | 466 const chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | 
| (...skipping 29 matching lines...) Expand all Loading... | |
| 481 if (!device_status_provider_.get()) | 496 if (!device_status_provider_.get()) | 
| 482 device_status_provider_.reset(new CloudPolicyStatusProvider()); | 497 device_status_provider_.reset(new CloudPolicyStatusProvider()); | 
| 483 | 498 | 
| 484 base::Closure update_callback(base::Bind(&PolicyUIHandler::SendStatus, | 499 base::Closure update_callback(base::Bind(&PolicyUIHandler::SendStatus, | 
| 485 base::Unretained(this))); | 500 base::Unretained(this))); | 
| 486 user_status_provider_->SetStatusChangeCallback(update_callback); | 501 user_status_provider_->SetStatusChangeCallback(update_callback); | 
| 487 device_status_provider_->SetStatusChangeCallback(update_callback); | 502 device_status_provider_->SetStatusChangeCallback(update_callback); | 
| 488 GetPolicyService()->AddObserver(policy::POLICY_DOMAIN_CHROME, this); | 503 GetPolicyService()->AddObserver(policy::POLICY_DOMAIN_CHROME, this); | 
| 489 GetPolicyService()->AddObserver(policy::POLICY_DOMAIN_EXTENSIONS, this); | 504 GetPolicyService()->AddObserver(policy::POLICY_DOMAIN_EXTENSIONS, this); | 
| 490 | 505 | 
| 506 registrar_.Add(this, | |
| 507 chrome::NOTIFICATION_EXTENSION_LOADED, | |
| 508 content::NotificationService::AllSources()); | |
| 509 registrar_.Add(this, | |
| 510 chrome::NOTIFICATION_EXTENSION_UNLOADED, | |
| 511 content::NotificationService::AllSources()); | |
| 512 | |
| 491 web_ui()->RegisterMessageCallback( | 513 web_ui()->RegisterMessageCallback( | 
| 492 "initialized", | 514 "initialized", | 
| 493 base::Bind(&PolicyUIHandler::HandleInitialized, base::Unretained(this))); | 515 base::Bind(&PolicyUIHandler::HandleInitialized, base::Unretained(this))); | 
| 494 web_ui()->RegisterMessageCallback( | 516 web_ui()->RegisterMessageCallback( | 
| 495 "reloadPolicies", | 517 "reloadPolicies", | 
| 496 base::Bind(&PolicyUIHandler::HandleReloadPolicies, | 518 base::Bind(&PolicyUIHandler::HandleReloadPolicies, | 
| 497 base::Unretained(this))); | 519 base::Unretained(this))); | 
| 498 } | 520 } | 
| 499 | 521 | 
| 522 void PolicyUIHandler::Observe(int type, | |
| 523 const content::NotificationSource& source, | |
| 524 const content::NotificationDetails& details) { | |
| 525 switch (type) { | |
| 
 
Joao da Silva
2013/06/19 16:35:17
Since this method always takes the same action the
 
anitawoodruff
2013/06/20 09:13:32
Done.
 
 | |
| 526 case chrome::NOTIFICATION_EXTENSION_LOADED: | |
| 527 case chrome::NOTIFICATION_EXTENSION_UNLOADED: | |
| 528 SendPolicyNames(); | |
| 529 SendPolicyValues(); | |
| 530 break; | |
| 531 default: | |
| 532 NOTREACHED(); // Unexpected notification. | |
| 533 break; | |
| 534 } | |
| 535 } | |
| 536 | |
| 500 void PolicyUIHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, | 537 void PolicyUIHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, | 
| 501 const policy::PolicyMap& previous, | 538 const policy::PolicyMap& previous, | 
| 502 const policy::PolicyMap& current) { | 539 const policy::PolicyMap& current) { | 
| 503 SendPolicyValues(); | 540 SendPolicyValues(); | 
| 504 } | 541 } | 
| 505 | 542 | 
| 506 void PolicyUIHandler::SendPolicyNames() const { | 543 void PolicyUIHandler::SendPolicyNames() const { | 
| 507 base::DictionaryValue names; | 544 base::DictionaryValue names; | 
| 545 | |
| 546 // Add Chrome policy names. | |
| 547 base::DictionaryValue* chrome_policy_names = new base::DictionaryValue; | |
| 508 const policy::PolicyDefinitionList* list = | 548 const policy::PolicyDefinitionList* list = | 
| 509 policy::GetChromePolicyDefinitionList(); | 549 policy::GetChromePolicyDefinitionList(); | 
| 510 for (const policy::PolicyDefinitionList::Entry* entry = list->begin; | 550 for (const policy::PolicyDefinitionList::Entry* entry = list->begin; | 
| 511 entry != list->end; ++entry) { | 551 entry != list->end; ++entry) { | 
| 512 names.SetBoolean(entry->name, true); | 552 chrome_policy_names->SetBoolean(entry->name, true); | 
| 513 } | 553 } | 
| 554 names.Set("chromePolicyNames", chrome_policy_names); | |
| 555 | |
| 556 // Add extension policy names. | |
| 557 base::DictionaryValue* extension_policy_names = new base::DictionaryValue; | |
| 558 | |
| 559 // Get extensions. | |
| 560 extensions::ExtensionSystem* extension_system = | |
| 561 extensions::ExtensionSystem::Get(Profile::FromWebUI(web_ui())); | |
| 
 
Joao da Silva
2013/06/19 16:35:17
nit: indent (4 spaces)
 
anitawoodruff
2013/06/20 09:13:32
Done.
 
 | |
| 562 const ExtensionSet* extensions = | |
| 563 extension_system->extension_service()->extensions(); | |
| 564 | |
| 565 // Get the policy schema map. | |
| 566 scoped_refptr<const policy::PolicyDomainDescriptor> policy_domain_descriptor; | |
| 567 policy_domain_descriptor = GetPolicyService()-> | |
| 568 GetPolicyDomainDescriptor(policy::POLICY_DOMAIN_EXTENSIONS); | |
| 569 const policy::PolicyDomainDescriptor::SchemaMap& schema_map = | |
| 570 policy_domain_descriptor->components(); | |
| 571 | |
| 572 // Add extension names and policies to the map. | |
| 573 for (ExtensionSet::const_iterator it = extensions->begin(); | |
| 574 it != extensions->end(); ++it) { | |
| 575 const extensions::Extension* extension = *it; | |
| 576 | |
| 577 // Skip this extension if it's a component extension. | |
| 578 if (extension->location() == extensions::Manifest::COMPONENT) | |
| 579 continue; | |
| 580 | |
| 581 // Add extension name to map. | |
| 582 base::DictionaryValue* extension_value = new base::DictionaryValue; | |
| 583 extension_value->SetString("name", extension->name()); | |
| 584 | |
| 585 // Get extension's policy schema. | |
| 586 policy::PolicyDomainDescriptor::SchemaMap::const_iterator it = | |
| 587 schema_map.find(extension->id()); | |
| 
 
Joao da Silva
2013/06/19 16:35:17
nit: indent (4 spaces)
 
anitawoodruff
2013/06/20 09:13:32
Done.
 
 | |
| 588 base::DictionaryValue* policy_names = new base::DictionaryValue; | |
| 589 if (it != schema_map.end()) { | |
| 590 // Get policy names from the extension's policy schema. | |
| 591 // Store in a map, not an array, for faster lookup on JS side. | |
| 592 const policy::PolicySchemaMap* policies = it->second->GetProperties(); | |
| 593 policy::PolicySchemaMap::const_iterator it_policies; | |
| 594 for (it_policies = policies->begin(); it_policies != policies->end(); | |
| 595 it_policies++) { | |
| 596 policy_names->SetBoolean(it_policies->first, true); | |
| 597 } | |
| 598 } | |
| 599 extension_value->Set("policyNames", policy_names); | |
| 600 | |
| 601 // Add extension's entry to the map. | |
| 602 extension_policy_names->Set(extension->id(), extension_value); | |
| 603 } | |
| 604 | |
| 605 names.Set("extensionPolicyNames", extension_policy_names); | |
| 514 web_ui()->CallJavascriptFunction("policy.Page.setPolicyNames", names); | 606 web_ui()->CallJavascriptFunction("policy.Page.setPolicyNames", names); | 
| 515 } | 607 } | 
| 516 | 608 | 
| 517 void PolicyUIHandler::SendPolicyValues() const { | 609 void PolicyUIHandler::SendPolicyValues() const { | 
| 518 base::DictionaryValue all_policies; | 610 base::DictionaryValue all_policies; | 
| 519 | 611 | 
| 520 // Add chrome policies. | 612 // Add chrome policies. | 
| 521 base::DictionaryValue* chrome_policies = new base::DictionaryValue; | 613 base::DictionaryValue* chrome_policies = new base::DictionaryValue; | 
| 522 GetChromePolicyValues(chrome_policies); | 614 GetChromePolicyValues(chrome_policies); | 
| 523 all_policies.Set("chromePolicies", chrome_policies); | 615 all_policies.Set("chromePolicies", chrome_policies); | 
| 524 | 616 | 
| 525 // Get extensions. | 617 // Get extensions. | 
| 526 extensions::ExtensionSystem* extension_system = | 618 extensions::ExtensionSystem* extension_system = | 
| 527 extensions::ExtensionSystem::Get(Profile::FromWebUI(web_ui())); | 619 extensions::ExtensionSystem::Get(Profile::FromWebUI(web_ui())); | 
| 528 const ExtensionSet* extensions = | 620 const ExtensionSet* extensions = | 
| 529 extension_system->extension_service()->extensions(); | 621 extension_system->extension_service()->extensions(); | 
| 530 | 622 | 
| 531 // Add policies for each extension. | 623 // Add policies for each extension. | 
| 532 base::DictionaryValue* extension_values = new base::DictionaryValue; | 624 base::DictionaryValue* extension_values = new base::DictionaryValue; | 
| 533 for (ExtensionSet::const_iterator it = extensions->begin(); | 625 for (ExtensionSet::const_iterator it = extensions->begin(); | 
| 534 it != extensions->end(); ++it) { | 626 it != extensions->end(); ++it) { | 
| 535 const extensions::Extension* extension = *it; | 627 const extensions::Extension* extension = *it; | 
| 536 | 628 | 
| 537 // Skip this extension if it's a component extension. | 629 // Skip this extension if it's a component extension. | 
| 538 if (extension->location() == extensions::Manifest::COMPONENT) | 630 if (extension->location() == extensions::Manifest::COMPONENT) | 
| 539 continue; | 631 continue; | 
| 540 | 632 | 
| 541 base::DictionaryValue* extension_value = new base::DictionaryValue; | 633 // Add policies values. | 
| 542 | 634 // Store in a map, not an array, for faster lookup on JS side. | 
| 543 // Add name. | |
| 544 extension_value->SetString("name", extension->name()); | |
| 545 | |
| 546 // Add policies. | |
| 547 base::DictionaryValue* extension_policies = new base::DictionaryValue; | 635 base::DictionaryValue* extension_policies = new base::DictionaryValue; | 
| 548 policy::PolicyNamespace policy_namespace = policy::PolicyNamespace( | 636 policy::PolicyNamespace policy_namespace = policy::PolicyNamespace( | 
| 549 policy::POLICY_DOMAIN_EXTENSIONS, extension->id()); | 637 policy::POLICY_DOMAIN_EXTENSIONS, extension->id()); | 
| 550 policy::PolicyErrorMap empty_error_map; | 638 policy::PolicyErrorMap empty_error_map; | 
| 551 GetPolicyValues(GetPolicyService()->GetPolicies(policy_namespace), | 639 GetPolicyValues(GetPolicyService()->GetPolicies(policy_namespace), | 
| 552 &empty_error_map, extension_policies); | 640 &empty_error_map, extension_policies); | 
| 553 extension_value->Set("policies", extension_policies); | |
| 554 | 641 | 
| 555 // Add entry to the dictionary. | 642 // Add entry to the dictionary. | 
| 556 extension_values->Set(extension->id(), extension_value); | 643 extension_values->Set(extension->id(), extension_policies); | 
| 557 } | 644 } | 
| 558 all_policies.Set("extensionPolicies", extension_values); | 645 all_policies.Set("extensionPolicies", extension_values); | 
| 559 | 646 | 
| 560 web_ui()->CallJavascriptFunction("policy.Page.setPolicyValues", all_policies); | 647 web_ui()->CallJavascriptFunction("policy.Page.setPolicyValues", all_policies); | 
| 561 } | 648 } | 
| 562 | 649 | 
| 563 void PolicyUIHandler::GetPolicyValues(const policy::PolicyMap& map, | 650 void PolicyUIHandler::GetPolicyValues(const policy::PolicyMap& map, | 
| 564 policy::PolicyErrorMap* errors, | 651 policy::PolicyErrorMap* errors, | 
| 565 base::DictionaryValue* values) const { | 652 base::DictionaryValue* values) const { | 
| 566 for (policy::PolicyMap::const_iterator entry = map.begin(); | 653 for (policy::PolicyMap::const_iterator entry = map.begin(); | 
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 647 } | 734 } | 
| 648 | 735 | 
| 649 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 736 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 
| 650 web_ui->AddMessageHandler(new PolicyUIHandler); | 737 web_ui->AddMessageHandler(new PolicyUIHandler); | 
| 651 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 738 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 
| 652 CreatePolicyUIHTMLSource()); | 739 CreatePolicyUIHTMLSource()); | 
| 653 } | 740 } | 
| 654 | 741 | 
| 655 PolicyUI::~PolicyUI() { | 742 PolicyUI::~PolicyUI() { | 
| 656 } | 743 } | 
| OLD | NEW |