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 24 matching lines...) Expand all Loading... |
35 settings_(new ExtensionManagement(pref_service_.get())), | 35 settings_(new ExtensionManagement(pref_service_.get())), |
36 provider_(settings_.get()) {} | 36 provider_(settings_.get()) {} |
37 | 37 |
38 void SetUp() override { | 38 void SetUp() override { |
39 ChromeAPIPermissions api_permissions; | 39 ChromeAPIPermissions api_permissions; |
40 perm_list_ = api_permissions.GetAllPermissions(); | 40 perm_list_ = api_permissions.GetAllPermissions(); |
41 pref_service_->registry()->RegisterDictionaryPref( | 41 pref_service_->registry()->RegisterDictionaryPref( |
42 pref_names::kExtensionManagement); | 42 pref_names::kExtensionManagement); |
43 } | 43 } |
44 | 44 |
45 void TearDown() override { | 45 void TearDown() override { base::STLDeleteElements(&perm_list_); } |
46 STLDeleteElements(&perm_list_); | |
47 } | |
48 | 46 |
49 // Get API permissions name for |id|, we cannot use arbitrary strings since | 47 // Get API permissions name for |id|, we cannot use arbitrary strings since |
50 // they will be ignored by ExtensionManagementService. | 48 // they will be ignored by ExtensionManagementService. |
51 std::string GetAPIPermissionName(APIPermission::ID id) { | 49 std::string GetAPIPermissionName(APIPermission::ID id) { |
52 for (auto* perm : perm_list_) { | 50 for (auto* perm : perm_list_) { |
53 if (perm->id() == id) | 51 if (perm->id() == id) |
54 return perm->name(); | 52 return perm->name(); |
55 } | 53 } |
56 ADD_FAILURE() << "Permission not found: " << id; | 54 ADD_FAILURE() << "Permission not found: " << id; |
57 return std::string(); | 55 return std::string(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 pref.ClearBlockedPermissions("*"); | 159 pref.ClearBlockedPermissions("*"); |
162 pref.AddBlockedPermission("*", | 160 pref.AddBlockedPermission("*", |
163 GetAPIPermissionName(APIPermission::kDownloads)); | 161 GetAPIPermissionName(APIPermission::kDownloads)); |
164 } | 162 } |
165 error16.clear(); | 163 error16.clear(); |
166 EXPECT_FALSE(provider_.UserMayLoad(extension.get(), &error16)); | 164 EXPECT_FALSE(provider_.UserMayLoad(extension.get(), &error16)); |
167 EXPECT_FALSE(error16.empty()); | 165 EXPECT_FALSE(error16.empty()); |
168 } | 166 } |
169 | 167 |
170 } // namespace extensions | 168 } // namespace extensions |
OLD | NEW |