| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_material_design_ui.h" | 5 #include "chrome/browser/ui/webui/policy_material_design_ui.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 PolicyMaterialDesignUIHandler::PolicyMaterialDesignUIHandler() { | 67 PolicyMaterialDesignUIHandler::PolicyMaterialDesignUIHandler() { |
| 68 } | 68 } |
| 69 | 69 |
| 70 PolicyMaterialDesignUIHandler::~PolicyMaterialDesignUIHandler() { | 70 PolicyMaterialDesignUIHandler::~PolicyMaterialDesignUIHandler() { |
| 71 } | 71 } |
| 72 | 72 |
| 73 void PolicyMaterialDesignUIHandler::AddPolicyName( | 73 void PolicyMaterialDesignUIHandler::AddPolicyName( |
| 74 const std::string& name, base::DictionaryValue* names) const { | 74 const std::string& name, base::DictionaryValue* names) const { |
| 75 scoped_ptr<base::ListValue> list(new base::ListValue()); | 75 std::unique_ptr<base::ListValue> list(new base::ListValue()); |
| 76 const policy::RiskTag* tags = policy::GetChromePolicyDetails(name)->risk_tags; | 76 const policy::RiskTag* tags = policy::GetChromePolicyDetails(name)->risk_tags; |
| 77 for (size_t i = 0; i < policy::kMaxRiskTagCount; ++i) { | 77 for (size_t i = 0; i < policy::kMaxRiskTagCount; ++i) { |
| 78 if (tags[i] != policy::RISK_TAG_NONE) | 78 if (tags[i] != policy::RISK_TAG_NONE) |
| 79 list->AppendString(kPolicyRiskTags[tags[i]].key); | 79 list->AppendString(kPolicyRiskTags[tags[i]].key); |
| 80 } | 80 } |
| 81 names->Set(name, std::move(list)); | 81 names->Set(name, std::move(list)); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void PolicyMaterialDesignUIHandler::SendPolicyNames() const { | 84 void PolicyMaterialDesignUIHandler::SendPolicyNames() const { |
| 85 base::ListValue tags; | 85 base::ListValue tags; |
| 86 for (size_t tag = 0; tag < policy::RISK_TAG_COUNT; ++tag) | 86 for (size_t tag = 0; tag < policy::RISK_TAG_COUNT; ++tag) |
| 87 tags.AppendString(kPolicyRiskTags[tag].key); | 87 tags.AppendString(kPolicyRiskTags[tag].key); |
| 88 | 88 |
| 89 web_ui()->CallJavascriptFunction("policy.Page.setPolicyGroups", tags); | 89 web_ui()->CallJavascriptFunction("policy.Page.setPolicyGroups", tags); |
| 90 PolicyUIHandler::SendPolicyNames(); | 90 PolicyUIHandler::SendPolicyNames(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 PolicyMaterialDesignUI::PolicyMaterialDesignUI(content::WebUI* web_ui) : | 93 PolicyMaterialDesignUI::PolicyMaterialDesignUI(content::WebUI* web_ui) : |
| 94 WebUIController(web_ui) { | 94 WebUIController(web_ui) { |
| 95 web_ui->AddMessageHandler(new PolicyMaterialDesignUIHandler); | 95 web_ui->AddMessageHandler(new PolicyMaterialDesignUIHandler); |
| 96 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 96 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
| 97 CreatePolicyMaterialDesignUIHtmlSource()); | 97 CreatePolicyMaterialDesignUIHtmlSource()); |
| 98 } | 98 } |
| 99 | 99 |
| 100 PolicyMaterialDesignUI::~PolicyMaterialDesignUI() { | 100 PolicyMaterialDesignUI::~PolicyMaterialDesignUI() { |
| 101 } | 101 } |
| OLD | NEW |