| 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 "extensions/common/permissions/media_galleries_permission.h" | 5 #include "extensions/common/permissions/media_galleries_permission.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 if (has_copy_to) | 89 if (has_copy_to) |
| 90 ids->insert(APIPermission::kMediaGalleriesAllGalleriesCopyTo); | 90 ids->insert(APIPermission::kMediaGalleriesAllGalleriesCopyTo); |
| 91 if (has_delete) | 91 if (has_delete) |
| 92 ids->insert(APIPermission::kMediaGalleriesAllGalleriesDelete); | 92 ids->insert(APIPermission::kMediaGalleriesAllGalleriesDelete); |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace | 95 } // namespace |
| 96 | 96 |
| 97 const char MediaGalleriesPermission::kAllAutoDetectedPermission[] = | 97 const char MediaGalleriesPermission::kAllAutoDetectedPermission[] = |
| 98 "allAutoDetected"; | 98 "allAutoDetected"; |
| 99 const char MediaGalleriesPermission::kScanPermission[] = "scan"; | |
| 100 const char MediaGalleriesPermission::kReadPermission[] = "read"; | 99 const char MediaGalleriesPermission::kReadPermission[] = "read"; |
| 101 const char MediaGalleriesPermission::kCopyToPermission[] = "copyTo"; | 100 const char MediaGalleriesPermission::kCopyToPermission[] = "copyTo"; |
| 102 const char MediaGalleriesPermission::kDeletePermission[] = "delete"; | 101 const char MediaGalleriesPermission::kDeletePermission[] = "delete"; |
| 103 | 102 |
| 104 MediaGalleriesPermission::MediaGalleriesPermission( | 103 MediaGalleriesPermission::MediaGalleriesPermission( |
| 105 const APIPermissionInfo* info) | 104 const APIPermissionInfo* info) |
| 106 : SetDisjunctionPermission<MediaGalleriesPermissionData, | 105 : SetDisjunctionPermission<MediaGalleriesPermissionData, |
| 107 MediaGalleriesPermission>(info) { | 106 MediaGalleriesPermission>(info) { |
| 108 } | 107 } |
| 109 | 108 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 130 } | 129 } |
| 131 } | 130 } |
| 132 if (!parsed_ok) | 131 if (!parsed_ok) |
| 133 return false; | 132 return false; |
| 134 | 133 |
| 135 bool has_read = false; | 134 bool has_read = false; |
| 136 bool has_copy_to = false; | 135 bool has_copy_to = false; |
| 137 bool has_delete = false; | 136 bool has_delete = false; |
| 138 for (std::set<MediaGalleriesPermissionData>::const_iterator it = | 137 for (std::set<MediaGalleriesPermissionData>::const_iterator it = |
| 139 data_set_.begin(); it != data_set_.end(); ++it) { | 138 data_set_.begin(); it != data_set_.end(); ++it) { |
| 140 if (it->permission() == kAllAutoDetectedPermission || | 139 if (it->permission() == kAllAutoDetectedPermission) { |
| 141 it->permission() == kScanPermission) { | |
| 142 continue; | 140 continue; |
| 143 } | 141 } |
| 144 if (it->permission() == kReadPermission) { | 142 if (it->permission() == kReadPermission) { |
| 145 has_read = true; | 143 has_read = true; |
| 146 continue; | 144 continue; |
| 147 } | 145 } |
| 148 if (it->permission() == kCopyToPermission) { | 146 if (it->permission() == kCopyToPermission) { |
| 149 has_copy_to = true; | 147 has_copy_to = true; |
| 150 continue; | 148 continue; |
| 151 } | 149 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 164 return IsValidPermissionSet(has_read, has_copy_to, has_delete, error); | 162 return IsValidPermissionSet(has_read, has_copy_to, has_delete, error); |
| 165 } | 163 } |
| 166 | 164 |
| 167 PermissionIDSet MediaGalleriesPermission::GetPermissions() const { | 165 PermissionIDSet MediaGalleriesPermission::GetPermissions() const { |
| 168 PermissionIDSet result; | 166 PermissionIDSet result; |
| 169 AddPermissionsToLists(data_set_, &result); | 167 AddPermissionsToLists(data_set_, &result); |
| 170 return result; | 168 return result; |
| 171 } | 169 } |
| 172 | 170 |
| 173 } // namespace extensions | 171 } // namespace extensions |
| OLD | NEW |