| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/api/messaging/native_messaging_policy_handle
r.h" | 5 #include "chrome/browser/extensions/api/messaging/native_messaging_policy_handle
r.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "base/prefs/pref_value_map.h" | 10 #include "base/prefs/pref_value_map.h" |
| 9 #include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest
.h" | 11 #include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest
.h" |
| 10 #include "chrome/browser/extensions/external_policy_loader.h" | 12 #include "chrome/browser/extensions/external_policy_loader.h" |
| 11 #include "components/policy/core/browser/policy_error_map.h" | 13 #include "components/policy/core/browser/policy_error_map.h" |
| 12 #include "components/policy/core/common/policy_map.h" | 14 #include "components/policy/core/common/policy_map.h" |
| 13 #include "grit/components_strings.h" | 15 #include "grit/components_strings.h" |
| 14 #include "policy/policy_constants.h" | 16 #include "policy/policy_constants.h" |
| 15 | 17 |
| 16 namespace extensions { | 18 namespace extensions { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 30 policy::PolicyErrorMap* errors) { | 32 policy::PolicyErrorMap* errors) { |
| 31 return CheckAndGetList(policies, errors, NULL); | 33 return CheckAndGetList(policies, errors, NULL); |
| 32 } | 34 } |
| 33 | 35 |
| 34 void NativeMessagingHostListPolicyHandler::ApplyPolicySettings( | 36 void NativeMessagingHostListPolicyHandler::ApplyPolicySettings( |
| 35 const policy::PolicyMap& policies, | 37 const policy::PolicyMap& policies, |
| 36 PrefValueMap* prefs) { | 38 PrefValueMap* prefs) { |
| 37 scoped_ptr<base::ListValue> list; | 39 scoped_ptr<base::ListValue> list; |
| 38 policy::PolicyErrorMap errors; | 40 policy::PolicyErrorMap errors; |
| 39 if (CheckAndGetList(policies, &errors, &list) && list) | 41 if (CheckAndGetList(policies, &errors, &list) && list) |
| 40 prefs->SetValue(pref_path(), list.Pass()); | 42 prefs->SetValue(pref_path(), std::move(list)); |
| 41 } | 43 } |
| 42 | 44 |
| 43 const char* NativeMessagingHostListPolicyHandler::pref_path() const { | 45 const char* NativeMessagingHostListPolicyHandler::pref_path() const { |
| 44 return pref_path_; | 46 return pref_path_; |
| 45 } | 47 } |
| 46 | 48 |
| 47 bool NativeMessagingHostListPolicyHandler::CheckAndGetList( | 49 bool NativeMessagingHostListPolicyHandler::CheckAndGetList( |
| 48 const policy::PolicyMap& policies, | 50 const policy::PolicyMap& policies, |
| 49 policy::PolicyErrorMap* errors, | 51 policy::PolicyErrorMap* errors, |
| 50 scoped_ptr<base::ListValue>* names) { | 52 scoped_ptr<base::ListValue>* names) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 77 !NativeMessagingHostManifest::IsValidName(name)) { | 79 !NativeMessagingHostManifest::IsValidName(name)) { |
| 78 errors->AddError(policy_name(), | 80 errors->AddError(policy_name(), |
| 79 entry - list_value->begin(), | 81 entry - list_value->begin(), |
| 80 IDS_POLICY_VALUE_FORMAT_ERROR); | 82 IDS_POLICY_VALUE_FORMAT_ERROR); |
| 81 continue; | 83 continue; |
| 82 } | 84 } |
| 83 filtered_list->Append(new base::StringValue(name)); | 85 filtered_list->Append(new base::StringValue(name)); |
| 84 } | 86 } |
| 85 | 87 |
| 86 if (names) | 88 if (names) |
| 87 *names = filtered_list.Pass(); | 89 *names = std::move(filtered_list); |
| 88 | 90 |
| 89 return true; | 91 return true; |
| 90 } | 92 } |
| 91 | 93 |
| 92 } // namespace extensions | 94 } // namespace extensions |
| OLD | NEW |