| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/common/permissions/api_permission_set.h" | 5 #include "extensions/common/permissions/api_permission_set.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 if (source != APIPermissionSet::kAllowInternalPermissions && | 34 if (source != APIPermissionSet::kAllowInternalPermissions && |
| 35 permission_info->is_internal()) { | 35 permission_info->is_internal()) { |
| 36 // An internal permission specified in permissions list is an error. | 36 // An internal permission specified in permissions list is an error. |
| 37 if (error) { | 37 if (error) { |
| 38 *error = ErrorUtils::FormatErrorMessageUTF16( | 38 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 39 errors::kPermissionNotAllowedInManifest, permission_str); | 39 errors::kPermissionNotAllowedInManifest, permission_str); |
| 40 } | 40 } |
| 41 return false; | 41 return false; |
| 42 } | 42 } |
| 43 | 43 |
| 44 if (!permission->FromValue(permission_value)) { | 44 std::string error_details; |
| 45 if (!permission->FromValue(permission_value, &error_details)) { |
| 45 if (error) { | 46 if (error) { |
| 46 *error = ErrorUtils::FormatErrorMessageUTF16( | 47 if (error_details.empty()) { |
| 47 errors::kInvalidPermission, permission_info->name()); | 48 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 49 errors::kInvalidPermission, |
| 50 permission_info->name()); |
| 51 } else { |
| 52 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 53 errors::kInvalidPermissionWithDetail, |
| 54 permission_info->name(), |
| 55 error_details); |
| 56 } |
| 48 return false; | 57 return false; |
| 49 } | 58 } |
| 50 LOG(WARNING) << "Parse permission failed."; | 59 LOG(WARNING) << "Parse permission failed."; |
| 51 } else { | 60 } else { |
| 52 api_permissions->insert(permission.release()); | 61 api_permissions->insert(permission.release()); |
| 53 } | 62 } |
| 54 return true; | 63 return true; |
| 55 } | 64 } |
| 56 | 65 |
| 57 if (unhandled_permissions) | 66 if (unhandled_permissions) |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 // The fileSystem.write and fileSystem.directory permissions imply | 175 // The fileSystem.write and fileSystem.directory permissions imply |
| 167 // fileSystem.writeDirectory. | 176 // fileSystem.writeDirectory. |
| 168 // TODO(sammc): Remove this. See http://crbug.com/284849. | 177 // TODO(sammc): Remove this. See http://crbug.com/284849. |
| 169 if (ContainsKey(map(), APIPermission::kFileSystemWrite) && | 178 if (ContainsKey(map(), APIPermission::kFileSystemWrite) && |
| 170 ContainsKey(map(), APIPermission::kFileSystemDirectory)) { | 179 ContainsKey(map(), APIPermission::kFileSystemDirectory)) { |
| 171 insert(APIPermission::kFileSystemWriteDirectory); | 180 insert(APIPermission::kFileSystemWriteDirectory); |
| 172 } | 181 } |
| 173 } | 182 } |
| 174 | 183 |
| 175 } // namespace extensions | 184 } // namespace extensions |
| OLD | NEW |