Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Side by Side Diff: chrome/browser/ui/webui/policy_ui_handler.cc

Issue 1825173003: [Policy Experimental] Add "recommended" policies for URL exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 extension_values->Set(extension->id(), extension_policies); 643 extension_values->Set(extension->id(), extension_policies);
644 } 644 }
645 all_policies.Set("extensionPolicies", extension_values); 645 all_policies.Set("extensionPolicies", extension_values);
646 #endif 646 #endif
647 web_ui()->CallJavascriptFunction("policy.Page.setPolicyValues", all_policies); 647 web_ui()->CallJavascriptFunction("policy.Page.setPolicyValues", all_policies);
648 } 648 }
649 649
650 void PolicyUIHandler::GetPolicyValues(const policy::PolicyMap& map, 650 void PolicyUIHandler::GetPolicyValues(const policy::PolicyMap& map,
651 policy::PolicyErrorMap* errors, 651 policy::PolicyErrorMap* errors,
652 base::DictionaryValue* values) const { 652 base::DictionaryValue* values) const {
653 for (policy::PolicyMap::const_iterator entry = map.begin(); 653 for (policy::PolicyMap::const_iterator it = map.begin();
654 entry != map.end(); ++entry) { 654 it != map.end(); map.next_dominant(&it)) {
655 base::DictionaryValue* value = new base::DictionaryValue; 655 policy::PolicyMap::const_iterator tail_it = it;
656 value->Set("value", CopyAndConvert(entry->second.value).release()); 656 map.next_dominant(&tail_it);
657 if (entry->second.scope == policy::POLICY_SCOPE_USER) 657 base::ListValue* value_list = new base::ListValue;
658 value->SetString("scope", "user"); 658 for (; it != tail_it; map.next_all(&it)) {
659 else 659 base::DictionaryValue* value = new base::DictionaryValue;
660 value->SetString("scope", "machine"); 660 value->Set("value", CopyAndConvert(it->second.value).release());
661 if (entry->second.level == policy::POLICY_LEVEL_RECOMMENDED) 661 if (it->second.scope == policy::POLICY_SCOPE_USER)
662 value->SetString("level", "recommended"); 662 value->SetString("scope", "user");
663 else 663 else
664 value->SetString("level", "mandatory"); 664 value->SetString("scope", "machine");
665 value->SetString("source", kPolicySources[entry->second.source].key); 665 if (it->second.level == policy::POLICY_LEVEL_RECOMMENDED)
666 base::string16 error = errors->GetErrors(entry->first); 666 value->SetString("level", "recommended");
667 if (!error.empty()) 667 else
668 value->SetString("error", error); 668 value->SetString("level", "mandatory");
669 values->Set(entry->first, value); 669 value->SetString("source", kPolicySources[it->second.source].key);
670 base::string16 error = errors->GetErrors(it->first.name);
671 if (!error.empty())
672 value->SetString("error", error);
673 value_list->Append(value);
674 }
675 values->Set(it->first.name, value_list);
670 } 676 }
671 } 677 }
672 678
673 void PolicyUIHandler::GetChromePolicyValues( 679 void PolicyUIHandler::GetChromePolicyValues(
674 base::DictionaryValue* values) const { 680 base::DictionaryValue* values) const {
675 policy::PolicyService* policy_service = GetPolicyService(); 681 policy::PolicyService* policy_service = GetPolicyService();
676 policy::PolicyMap map; 682 policy::PolicyMap map;
677 683
678 // Make a copy that can be modified, since some policy values are modified 684 // Make a copy that can be modified, since some policy values are modified
679 // before being displayed. 685 // before being displayed.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 } 745 }
740 746
741 void PolicyUIHandler::OnRefreshPoliciesDone() const { 747 void PolicyUIHandler::OnRefreshPoliciesDone() const {
742 web_ui()->CallJavascriptFunction("policy.Page.reloadPoliciesDone"); 748 web_ui()->CallJavascriptFunction("policy.Page.reloadPoliciesDone");
743 } 749 }
744 750
745 policy::PolicyService* PolicyUIHandler::GetPolicyService() const { 751 policy::PolicyService* PolicyUIHandler::GetPolicyService() const {
746 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext( 752 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext(
747 web_ui()->GetWebContents()->GetBrowserContext())->policy_service(); 753 web_ui()->GetWebContents()->GetBrowserContext())->policy_service();
748 } 754 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698