| 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 #ifndef EXTENSIONS_COMMON_PERMISSIONS_MANIFEST_PERMISSION_SET_H_ | 5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_MANIFEST_PERMISSION_SET_H_ |
| 6 #define EXTENSIONS_COMMON_PERMISSIONS_MANIFEST_PERMISSION_SET_H_ | 6 #define EXTENSIONS_COMMON_PERMISSIONS_MANIFEST_PERMISSION_SET_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "extensions/common/permissions/base_set_operators.h" | 12 #include "extensions/common/permissions/base_set_operators.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class ListValue; | 15 class ListValue; |
| 16 } // namespace base | 16 } // namespace base |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 | 19 |
| 20 class Extension; | |
| 21 class ManifestPermission; | 20 class ManifestPermission; |
| 22 class ManifestPermissionSet; | 21 class ManifestPermissionSet; |
| 23 | 22 |
| 24 template<> | 23 template<> |
| 25 struct BaseSetOperatorsTraits<ManifestPermissionSet> { | 24 struct BaseSetOperatorsTraits<ManifestPermissionSet> { |
| 26 typedef ManifestPermission ElementType; | 25 typedef ManifestPermission ElementType; |
| 27 typedef std::string ElementIDType; | 26 typedef std::string ElementIDType; |
| 28 }; | 27 }; |
| 29 | 28 |
| 30 class ManifestPermissionSet : public BaseSetOperators<ManifestPermissionSet> { | 29 class ManifestPermissionSet : public BaseSetOperators<ManifestPermissionSet> { |
| 31 public: | 30 public: |
| 32 // Parses permissions from |permissions| and adds the parsed permissions to | 31 // Parses permissions from |permissions| and adds the parsed permissions to |
| 33 // |manifest_permissions|. If |unhandled_permissions| is not NULL, the names | 32 // |manifest_permissions|. If |unhandled_permissions| is not NULL, the names |
| 34 // of all permissions that couldn't be parsed will be added to this vector. | 33 // of all permissions that couldn't be parsed will be added to this vector. |
| 35 // If |error| is NULL, parsing will continue with the next permission if | 34 // If |error| is NULL, parsing will continue with the next permission if |
| 36 // invalid data is detected. If |error| is not NULL, it will be set to an | 35 // invalid data is detected. If |error| is not NULL, it will be set to an |
| 37 // error message and false is returned when an invalid permission is found. | 36 // error message and false is returned when an invalid permission is found. |
| 38 static bool ParseFromJSON( | 37 static bool ParseFromJSON( |
| 39 const base::ListValue* permissions, | 38 const base::ListValue* permissions, |
| 40 ManifestPermissionSet* manifest_permissions, | 39 ManifestPermissionSet* manifest_permissions, |
| 41 base::string16* error, | 40 base::string16* error, |
| 42 std::vector<std::string>* unhandled_permissions); | 41 std::vector<std::string>* unhandled_permissions); |
| 43 }; | 42 }; |
| 44 | 43 |
| 45 } // namespace extensions | 44 } // namespace extensions |
| 46 | 45 |
| 47 #endif // EXTENSIONS_COMMON_PERMISSIONS_MANIFEST_PERMISSION_SET_H_ | 46 #endif // EXTENSIONS_COMMON_PERMISSIONS_MANIFEST_PERMISSION_SET_H_ |
| OLD | NEW |