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 | 9 |
9 #include "base/macros.h" | 10 #include "base/macros.h" |
10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/webui/policy_ui_handler.h" | 12 #include "chrome/browser/ui/webui/policy_ui_handler.h" |
12 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
13 #include "components/policy/core/common/policy_types.h" | 14 #include "components/policy/core/common/policy_types.h" |
14 #include "grit/components_strings.h" | 15 #include "grit/components_strings.h" |
15 #include "grit/policy_resources.h" | 16 #include "grit/policy_resources.h" |
16 #include "grit/policy_resources_map.h" | 17 #include "grit/policy_resources_map.h" |
17 #include "policy/policy_constants.h" | 18 #include "policy/policy_constants.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 71 } |
71 | 72 |
72 void PolicyMaterialDesignUIHandler::AddPolicyName( | 73 void PolicyMaterialDesignUIHandler::AddPolicyName( |
73 const std::string& name, base::DictionaryValue* names) const { | 74 const std::string& name, base::DictionaryValue* names) const { |
74 scoped_ptr<base::ListValue> list(new base::ListValue()); | 75 scoped_ptr<base::ListValue> list(new base::ListValue()); |
75 const policy::RiskTag* tags = policy::GetChromePolicyDetails(name)->risk_tags; | 76 const policy::RiskTag* tags = policy::GetChromePolicyDetails(name)->risk_tags; |
76 for (size_t i = 0; i < policy::kMaxRiskTagCount; ++i) { | 77 for (size_t i = 0; i < policy::kMaxRiskTagCount; ++i) { |
77 if (tags[i] != policy::RISK_TAG_NONE) | 78 if (tags[i] != policy::RISK_TAG_NONE) |
78 list->AppendString(kPolicyRiskTags[tags[i]].key); | 79 list->AppendString(kPolicyRiskTags[tags[i]].key); |
79 } | 80 } |
80 names->Set(name, list.Pass()); | 81 names->Set(name, std::move(list)); |
81 } | 82 } |
82 | 83 |
83 void PolicyMaterialDesignUIHandler::SendPolicyNames() const { | 84 void PolicyMaterialDesignUIHandler::SendPolicyNames() const { |
84 base::ListValue tags; | 85 base::ListValue tags; |
85 for (size_t tag = 0; tag < policy::RISK_TAG_COUNT; ++tag) | 86 for (size_t tag = 0; tag < policy::RISK_TAG_COUNT; ++tag) |
86 tags.AppendString(kPolicyRiskTags[tag].key); | 87 tags.AppendString(kPolicyRiskTags[tag].key); |
87 | 88 |
88 web_ui()->CallJavascriptFunction("policy.Page.setPolicyGroups", tags); | 89 web_ui()->CallJavascriptFunction("policy.Page.setPolicyGroups", tags); |
89 PolicyUIHandler::SendPolicyNames(); | 90 PolicyUIHandler::SendPolicyNames(); |
90 } | 91 } |
91 | 92 |
92 PolicyMaterialDesignUI::PolicyMaterialDesignUI(content::WebUI* web_ui) : | 93 PolicyMaterialDesignUI::PolicyMaterialDesignUI(content::WebUI* web_ui) : |
93 WebUIController(web_ui) { | 94 WebUIController(web_ui) { |
94 web_ui->AddMessageHandler(new PolicyMaterialDesignUIHandler); | 95 web_ui->AddMessageHandler(new PolicyMaterialDesignUIHandler); |
95 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 96 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
96 CreatePolicyMaterialDesignUIHtmlSource()); | 97 CreatePolicyMaterialDesignUIHtmlSource()); |
97 } | 98 } |
98 | 99 |
99 PolicyMaterialDesignUI::~PolicyMaterialDesignUI() { | 100 PolicyMaterialDesignUI::~PolicyMaterialDesignUI() { |
100 } | 101 } |
OLD | NEW |