| OLD | NEW |
| 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/common/extensions/permissions/api_permission_set.h" | 5 #include "chrome/common/extensions/permissions/api_permission_set.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/common/extensions/extension_manifest_constants.h" | 10 #include "chrome/common/extensions/extension_manifest_constants.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 const base::Value* permission_value, | 26 const base::Value* permission_value, |
| 27 APIPermissionSet* api_permissions, | 27 APIPermissionSet* api_permissions, |
| 28 string16* error, | 28 string16* error, |
| 29 std::vector<std::string>* unhandled_permissions) { | 29 std::vector<std::string>* unhandled_permissions) { |
| 30 PermissionsInfo* info = PermissionsInfo::GetInstance(); | 30 PermissionsInfo* info = PermissionsInfo::GetInstance(); |
| 31 | 31 |
| 32 const APIPermissionInfo* permission_info = info->GetByName(permission_str); | 32 const APIPermissionInfo* permission_info = info->GetByName(permission_str); |
| 33 if (permission_info) { | 33 if (permission_info) { |
| 34 scoped_ptr<APIPermission> permission( | 34 scoped_ptr<APIPermission> permission( |
| 35 permission_info->CreateAPIPermission()); | 35 permission_info->CreateAPIPermission()); |
| 36 if (permission->ManifestEntryForbidden()) { | 36 if (!permission->FromValue(permission_value)) { |
| 37 if (error) { | |
| 38 *error = ErrorUtils::FormatErrorMessageUTF16( | |
| 39 errors::kPermissionNotAllowedInManifest, permission_info->name()); | |
| 40 return false; | |
| 41 } | |
| 42 LOG(WARNING) << "Permission not allowed in manifest."; | |
| 43 } else if (!permission->FromValue(permission_value)) { | |
| 44 if (error) { | 37 if (error) { |
| 45 *error = ErrorUtils::FormatErrorMessageUTF16( | 38 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 46 errors::kInvalidPermission, permission_info->name()); | 39 errors::kInvalidPermission, permission_info->name()); |
| 47 return false; | 40 return false; |
| 48 } | 41 } |
| 49 LOG(WARNING) << "Parse permission failed."; | 42 LOG(WARNING) << "Parse permission failed."; |
| 50 } else { | 43 } else { |
| 51 api_permissions->insert(permission.release()); | 44 api_permissions->insert(permission.release()); |
| 52 } | 45 } |
| 53 return true; | 46 return true; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 } | 316 } |
| 324 | 317 |
| 325 if (!CreateAPIPermission(permission_str, permission_value, | 318 if (!CreateAPIPermission(permission_str, permission_value, |
| 326 api_permissions, error, unhandled_permissions)) | 319 api_permissions, error, unhandled_permissions)) |
| 327 return false; | 320 return false; |
| 328 } | 321 } |
| 329 return true; | 322 return true; |
| 330 } | 323 } |
| 331 | 324 |
| 332 } // namespace extensions | 325 } // namespace extensions |
| OLD | NEW |