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 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 ASSERT_EQ(1u, service_->extensions()->size()); | 1131 ASSERT_EQ(1u, service_->extensions()->size()); |
1132 std::string extension_id = service_->extensions()->at(0)->id(); | 1132 std::string extension_id = service_->extensions()->at(0)->id(); |
1133 EXPECT_EQ(permissions_crx, extension_id); | 1133 EXPECT_EQ(permissions_crx, extension_id); |
1134 | 1134 |
1135 | 1135 |
1136 // Verify that the valid API permissions have been recognized. | 1136 // Verify that the valid API permissions have been recognized. |
1137 expected_api_perms.insert("tabs"); | 1137 expected_api_perms.insert("tabs"); |
1138 | 1138 |
1139 AddPattern(&expected_host_perms, "http://*.google.com/*"); | 1139 AddPattern(&expected_host_perms, "http://*.google.com/*"); |
1140 AddPattern(&expected_host_perms, "https://*.google.com/*"); | 1140 AddPattern(&expected_host_perms, "https://*.google.com/*"); |
| 1141 AddPattern(&expected_host_perms, "http://*.google.com.hk/*"); |
1141 AddPattern(&expected_host_perms, "http://www.example.com/*"); | 1142 AddPattern(&expected_host_perms, "http://www.example.com/*"); |
1142 | 1143 |
1143 EXPECT_TRUE(prefs->GetGrantedPermissions(extension_id, | 1144 EXPECT_TRUE(prefs->GetGrantedPermissions(extension_id, |
1144 &full_access, | 1145 &full_access, |
1145 &known_api_perms, | 1146 &known_api_perms, |
1146 &known_host_perms)); | 1147 &known_host_perms)); |
1147 | 1148 |
1148 EXPECT_EQ(expected_api_perms, known_api_perms); | 1149 EXPECT_EQ(expected_api_perms, known_api_perms); |
1149 EXPECT_FALSE(full_access); | 1150 EXPECT_FALSE(full_access); |
1150 AssertEqualExtents(&expected_host_perms, &known_host_perms); | 1151 AssertEqualExtents(&expected_host_perms, &known_host_perms); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 std::string extension_id = extension->id(); | 1210 std::string extension_id = extension->id(); |
1210 | 1211 |
1211 ExtensionPrefs* prefs = service_->extension_prefs(); | 1212 ExtensionPrefs* prefs = service_->extension_prefs(); |
1212 | 1213 |
1213 std::set<std::string> expected_api_permissions; | 1214 std::set<std::string> expected_api_permissions; |
1214 ExtensionExtent expected_host_permissions; | 1215 ExtensionExtent expected_host_permissions; |
1215 | 1216 |
1216 expected_api_permissions.insert("tabs"); | 1217 expected_api_permissions.insert("tabs"); |
1217 AddPattern(&expected_host_permissions, "http://*.google.com/*"); | 1218 AddPattern(&expected_host_permissions, "http://*.google.com/*"); |
1218 AddPattern(&expected_host_permissions, "https://*.google.com/*"); | 1219 AddPattern(&expected_host_permissions, "https://*.google.com/*"); |
| 1220 AddPattern(&expected_host_permissions, "http://*.google.com.hk/*"); |
1219 AddPattern(&expected_host_permissions, "http://www.example.com/*"); | 1221 AddPattern(&expected_host_permissions, "http://www.example.com/*"); |
1220 | 1222 |
1221 std::set<std::string> api_permissions; | 1223 std::set<std::string> api_permissions; |
1222 std::set<std::string> host_permissions; | 1224 std::set<std::string> host_permissions; |
1223 | 1225 |
1224 // Test that the extension is disabled when an API permission is missing from | 1226 // Test that the extension is disabled when an API permission is missing from |
1225 // the extension's granted api permissions preference. (This simulates | 1227 // the extension's granted api permissions preference. (This simulates |
1226 // updating the browser to a version which recognizes a new API permission). | 1228 // updating the browser to a version which recognizes a new API permission). |
1227 SetPrefStringSet(extension_id, "granted_permissions.api", api_permissions); | 1229 SetPrefStringSet(extension_id, "granted_permissions.api", api_permissions); |
1228 | 1230 |
(...skipping 29 matching lines...) Expand all Loading... |
1258 // updating the browser to a version which recognizes additional host | 1260 // updating the browser to a version which recognizes additional host |
1259 // permissions). | 1261 // permissions). |
1260 api_permissions.clear(); | 1262 api_permissions.clear(); |
1261 host_permissions.clear(); | 1263 host_permissions.clear(); |
1262 current_api_permissions.clear(); | 1264 current_api_permissions.clear(); |
1263 current_host_permissions.ClearPaths(); | 1265 current_host_permissions.ClearPaths(); |
1264 | 1266 |
1265 api_permissions.insert("tabs"); | 1267 api_permissions.insert("tabs"); |
1266 host_permissions.insert("http://*.google.com/*"); | 1268 host_permissions.insert("http://*.google.com/*"); |
1267 host_permissions.insert("https://*.google.com/*"); | 1269 host_permissions.insert("https://*.google.com/*"); |
| 1270 host_permissions.insert("http://*.google.com.hk/*"); |
1268 | 1271 |
1269 SetPrefStringSet(extension_id, "granted_permissions.api", api_permissions); | 1272 SetPrefStringSet(extension_id, "granted_permissions.api", api_permissions); |
1270 SetPrefStringSet(extension_id, "granted_permissions.host", host_permissions); | 1273 SetPrefStringSet(extension_id, "granted_permissions.host", host_permissions); |
1271 | 1274 |
1272 service_->ReloadExtensions(); | 1275 service_->ReloadExtensions(); |
1273 | 1276 |
1274 EXPECT_EQ(1u, service_->disabled_extensions()->size()); | 1277 EXPECT_EQ(1u, service_->disabled_extensions()->size()); |
1275 extension = service_->disabled_extensions()->at(0); | 1278 extension = service_->disabled_extensions()->at(0); |
1276 | 1279 |
1277 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::DISABLED); | 1280 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::DISABLED); |
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3097 // Component extensions shouldn't get recourded in the prefs. | 3100 // Component extensions shouldn't get recourded in the prefs. |
3098 ValidatePrefKeyCount(0); | 3101 ValidatePrefKeyCount(0); |
3099 | 3102 |
3100 // Reload all extensions, and make sure it comes back. | 3103 // Reload all extensions, and make sure it comes back. |
3101 std::string extension_id = service_->extensions()->at(0)->id(); | 3104 std::string extension_id = service_->extensions()->at(0)->id(); |
3102 loaded_.clear(); | 3105 loaded_.clear(); |
3103 service_->ReloadExtensions(); | 3106 service_->ReloadExtensions(); |
3104 ASSERT_EQ(1u, service_->extensions()->size()); | 3107 ASSERT_EQ(1u, service_->extensions()->size()); |
3105 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); | 3108 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); |
3106 } | 3109 } |
OLD | NEW |