| 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/permissions_based_management_policy_provider
.h" | 5 #include "chrome/browser/extensions/permissions_based_management_policy_provider
.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 pref_names::kExtensionManagement); | 42 pref_names::kExtensionManagement); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void TearDown() override { | 45 void TearDown() override { |
| 46 STLDeleteElements(&perm_list_); | 46 STLDeleteElements(&perm_list_); |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Get API permissions name for |id|, we cannot use arbitrary strings since | 49 // Get API permissions name for |id|, we cannot use arbitrary strings since |
| 50 // they will be ignored by ExtensionManagementService. | 50 // they will be ignored by ExtensionManagementService. |
| 51 std::string GetAPIPermissionName(APIPermission::ID id) { | 51 std::string GetAPIPermissionName(APIPermission::ID id) { |
| 52 for (const auto& perm : perm_list_) { | 52 for (auto* perm : perm_list_) { |
| 53 if (perm->id() == id) | 53 if (perm->id() == id) |
| 54 return perm->name(); | 54 return perm->name(); |
| 55 } | 55 } |
| 56 ADD_FAILURE() << "Permission not found: " << id; | 56 ADD_FAILURE() << "Permission not found: " << id; |
| 57 return std::string(); | 57 return std::string(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Create an extension with specified |location|, |required_permissions| and | 60 // Create an extension with specified |location|, |required_permissions| and |
| 61 // |optional_permissions|. | 61 // |optional_permissions|. |
| 62 scoped_refptr<const Extension> CreateExtensionWithPermission( | 62 scoped_refptr<const Extension> CreateExtensionWithPermission( |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 pref.ClearBlockedPermissions("*"); | 161 pref.ClearBlockedPermissions("*"); |
| 162 pref.AddBlockedPermission("*", | 162 pref.AddBlockedPermission("*", |
| 163 GetAPIPermissionName(APIPermission::kDownloads)); | 163 GetAPIPermissionName(APIPermission::kDownloads)); |
| 164 } | 164 } |
| 165 error16.clear(); | 165 error16.clear(); |
| 166 EXPECT_FALSE(provider_.UserMayLoad(extension.get(), &error16)); | 166 EXPECT_FALSE(provider_.UserMayLoad(extension.get(), &error16)); |
| 167 EXPECT_FALSE(error16.empty()); | 167 EXPECT_FALSE(error16.empty()); |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace extensions | 170 } // namespace extensions |
| OLD | NEW |