OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extensions_service_unittest.h" | 5 #include "chrome/browser/extensions/extensions_service_unittest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 ASSERT_EQ(1u, service_->extensions()->size()); | 1172 ASSERT_EQ(1u, service_->extensions()->size()); |
1173 std::string extension_id = service_->extensions()->at(0)->id(); | 1173 std::string extension_id = service_->extensions()->at(0)->id(); |
1174 EXPECT_EQ(permissions_crx, extension_id); | 1174 EXPECT_EQ(permissions_crx, extension_id); |
1175 | 1175 |
1176 | 1176 |
1177 // Verify that the valid API permissions have been recognized. | 1177 // Verify that the valid API permissions have been recognized. |
1178 expected_api_perms.insert("tabs"); | 1178 expected_api_perms.insert("tabs"); |
1179 | 1179 |
1180 AddPattern(&expected_host_perms, "http://*.google.com/*"); | 1180 AddPattern(&expected_host_perms, "http://*.google.com/*"); |
1181 AddPattern(&expected_host_perms, "https://*.google.com/*"); | 1181 AddPattern(&expected_host_perms, "https://*.google.com/*"); |
| 1182 AddPattern(&expected_host_perms, "http://*.google.com.hk/*"); |
1182 AddPattern(&expected_host_perms, "http://www.example.com/*"); | 1183 AddPattern(&expected_host_perms, "http://www.example.com/*"); |
1183 | 1184 |
1184 EXPECT_TRUE(prefs->GetGrantedPermissions(extension_id, | 1185 EXPECT_TRUE(prefs->GetGrantedPermissions(extension_id, |
1185 &full_access, | 1186 &full_access, |
1186 &known_api_perms, | 1187 &known_api_perms, |
1187 &known_host_perms)); | 1188 &known_host_perms)); |
1188 | 1189 |
1189 EXPECT_EQ(expected_api_perms, known_api_perms); | 1190 EXPECT_EQ(expected_api_perms, known_api_perms); |
1190 EXPECT_FALSE(full_access); | 1191 EXPECT_FALSE(full_access); |
1191 AssertEqualExtents(&expected_host_perms, &known_host_perms); | 1192 AssertEqualExtents(&expected_host_perms, &known_host_perms); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 std::string extension_id = extension->id(); | 1251 std::string extension_id = extension->id(); |
1251 | 1252 |
1252 ExtensionPrefs* prefs = service_->extension_prefs(); | 1253 ExtensionPrefs* prefs = service_->extension_prefs(); |
1253 | 1254 |
1254 std::set<std::string> expected_api_permissions; | 1255 std::set<std::string> expected_api_permissions; |
1255 ExtensionExtent expected_host_permissions; | 1256 ExtensionExtent expected_host_permissions; |
1256 | 1257 |
1257 expected_api_permissions.insert("tabs"); | 1258 expected_api_permissions.insert("tabs"); |
1258 AddPattern(&expected_host_permissions, "http://*.google.com/*"); | 1259 AddPattern(&expected_host_permissions, "http://*.google.com/*"); |
1259 AddPattern(&expected_host_permissions, "https://*.google.com/*"); | 1260 AddPattern(&expected_host_permissions, "https://*.google.com/*"); |
| 1261 AddPattern(&expected_host_permissions, "http://*.google.com.hk/*"); |
1260 AddPattern(&expected_host_permissions, "http://www.example.com/*"); | 1262 AddPattern(&expected_host_permissions, "http://www.example.com/*"); |
1261 | 1263 |
1262 std::set<std::string> api_permissions; | 1264 std::set<std::string> api_permissions; |
1263 std::set<std::string> host_permissions; | 1265 std::set<std::string> host_permissions; |
1264 | 1266 |
1265 // Test that the extension is disabled when an API permission is missing from | 1267 // Test that the extension is disabled when an API permission is missing from |
1266 // the extension's granted api permissions preference. (This simulates | 1268 // the extension's granted api permissions preference. (This simulates |
1267 // updating the browser to a version which recognizes a new API permission). | 1269 // updating the browser to a version which recognizes a new API permission). |
1268 SetPrefStringSet(extension_id, "granted_permissions.api", api_permissions); | 1270 SetPrefStringSet(extension_id, "granted_permissions.api", api_permissions); |
1269 | 1271 |
(...skipping 29 matching lines...) Expand all Loading... |
1299 // updating the browser to a version which recognizes additional host | 1301 // updating the browser to a version which recognizes additional host |
1300 // permissions). | 1302 // permissions). |
1301 api_permissions.clear(); | 1303 api_permissions.clear(); |
1302 host_permissions.clear(); | 1304 host_permissions.clear(); |
1303 current_api_permissions.clear(); | 1305 current_api_permissions.clear(); |
1304 current_host_permissions.ClearPaths(); | 1306 current_host_permissions.ClearPaths(); |
1305 | 1307 |
1306 api_permissions.insert("tabs"); | 1308 api_permissions.insert("tabs"); |
1307 host_permissions.insert("http://*.google.com/*"); | 1309 host_permissions.insert("http://*.google.com/*"); |
1308 host_permissions.insert("https://*.google.com/*"); | 1310 host_permissions.insert("https://*.google.com/*"); |
| 1311 host_permissions.insert("http://*.google.com.hk/*"); |
1309 | 1312 |
1310 SetPrefStringSet(extension_id, "granted_permissions.api", api_permissions); | 1313 SetPrefStringSet(extension_id, "granted_permissions.api", api_permissions); |
1311 SetPrefStringSet(extension_id, "granted_permissions.host", host_permissions); | 1314 SetPrefStringSet(extension_id, "granted_permissions.host", host_permissions); |
1312 | 1315 |
1313 service_->ReloadExtensions(); | 1316 service_->ReloadExtensions(); |
1314 | 1317 |
1315 EXPECT_EQ(1u, service_->disabled_extensions()->size()); | 1318 EXPECT_EQ(1u, service_->disabled_extensions()->size()); |
1316 extension = service_->disabled_extensions()->at(0); | 1319 extension = service_->disabled_extensions()->at(0); |
1317 | 1320 |
1318 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::DISABLED); | 1321 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::DISABLED); |
(...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3173 // Component extensions shouldn't get recourded in the prefs. | 3176 // Component extensions shouldn't get recourded in the prefs. |
3174 ValidatePrefKeyCount(0); | 3177 ValidatePrefKeyCount(0); |
3175 | 3178 |
3176 // Reload all extensions, and make sure it comes back. | 3179 // Reload all extensions, and make sure it comes back. |
3177 std::string extension_id = service_->extensions()->at(0)->id(); | 3180 std::string extension_id = service_->extensions()->at(0)->id(); |
3178 loaded_.clear(); | 3181 loaded_.clear(); |
3179 service_->ReloadExtensions(); | 3182 service_->ReloadExtensions(); |
3180 ASSERT_EQ(1u, service_->extensions()->size()); | 3183 ASSERT_EQ(1u, service_->extensions()->size()); |
3181 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); | 3184 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); |
3182 } | 3185 } |
OLD | NEW |