Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(634)

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 7003098: Start refractoring extension permissions into ExtensionPermissionSet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix a bad merge Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_service_unittest.h" 5 #include "chrome/browser/extensions/extension_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 std::stable_sort(ret_val.begin(), ret_val.end()); 107 std::stable_sort(ret_val.begin(), ret_val.end());
108 108
109 return ret_val; 109 return ret_val;
110 } 110 }
111 111
112 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { 112 static void AddPattern(URLPatternSet* extent, const std::string& pattern) {
113 int schemes = URLPattern::SCHEME_ALL; 113 int schemes = URLPattern::SCHEME_ALL;
114 extent->AddPattern(URLPattern(schemes, pattern)); 114 extent->AddPattern(URLPattern(schemes, pattern));
115 } 115 }
116 116
117 static void AssertEqualExtents(URLPatternSet* extent1, 117 static void AssertEqualExtents(const URLPatternSet& extent1,
118 URLPatternSet* extent2) { 118 const URLPatternSet& extent2) {
119 URLPatternList patterns1 = extent1->patterns(); 119 URLPatternList patterns1 = extent1.patterns();
120 URLPatternList patterns2 = extent2->patterns(); 120 URLPatternList patterns2 = extent2.patterns();
121 std::set<std::string> strings1; 121 std::set<std::string> strings1;
122 EXPECT_EQ(patterns1.size(), patterns2.size()); 122 EXPECT_EQ(patterns1.size(), patterns2.size());
123 123
124 for (size_t i = 0; i < patterns1.size(); ++i) 124 for (size_t i = 0; i < patterns1.size(); ++i)
125 strings1.insert(patterns1.at(i).GetAsString()); 125 strings1.insert(patterns1.at(i).GetAsString());
126 126
127 std::set<std::string> strings2; 127 std::set<std::string> strings2;
128 for (size_t i = 0; i < patterns2.size(); ++i) 128 for (size_t i = 0; i < patterns2.size(); ++i)
129 strings2.insert(patterns2.at(i).GetAsString()); 129 strings2.insert(patterns2.at(i).GetAsString());
130 130
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 1365
1366 FilePath pem_path = path.AppendASCII("unknown.pem"); 1366 FilePath pem_path = path.AppendASCII("unknown.pem");
1367 path = path.AppendASCII("unknown"); 1367 path = path.AppendASCII("unknown");
1368 1368
1369 ASSERT_TRUE(file_util::PathExists(pem_path)); 1369 ASSERT_TRUE(file_util::PathExists(pem_path));
1370 ASSERT_TRUE(file_util::PathExists(path)); 1370 ASSERT_TRUE(file_util::PathExists(path));
1371 1371
1372 ExtensionPrefs* prefs = service_->extension_prefs(); 1372 ExtensionPrefs* prefs = service_->extension_prefs();
1373 1373
1374 std::set<std::string> expected_api_perms; 1374 std::set<std::string> expected_api_perms;
1375 std::set<std::string> known_api_perms;
1376 bool full_access;
1377 URLPatternSet expected_host_perms; 1375 URLPatternSet expected_host_perms;
1378 URLPatternSet known_host_perms; 1376 bool initialized = false;
1379 1377
1380 // Make sure there aren't any granted permissions before the 1378 // Make sure there aren't any granted permissions before the
1381 // extension is installed. 1379 // extension is installed.
1382 EXPECT_FALSE(prefs->GetGrantedPermissions( 1380 scoped_ptr<ExtensionPermissionSet> known_perms(
1383 permissions_crx, &full_access, &known_api_perms, &known_host_perms)); 1381 prefs->GetGrantedPermissions(permissions_crx, &initialized));
1384 EXPECT_TRUE(known_api_perms.empty()); 1382 EXPECT_FALSE(initialized);
1385 EXPECT_TRUE(known_host_perms.is_empty()); 1383 EXPECT_TRUE(known_perms->IsEmpty());
1386 1384
1387 PackAndInstallCrx(path, pem_path, true); 1385 PackAndInstallCrx(path, pem_path, true);
1388 1386
1389 EXPECT_EQ(0u, GetErrors().size()); 1387 EXPECT_EQ(0u, GetErrors().size());
1390 ASSERT_EQ(1u, service_->extensions()->size()); 1388 ASSERT_EQ(1u, service_->extensions()->size());
1391 std::string extension_id = service_->extensions()->at(0)->id(); 1389 std::string extension_id = service_->extensions()->at(0)->id();
1392 EXPECT_EQ(permissions_crx, extension_id); 1390 EXPECT_EQ(permissions_crx, extension_id);
1393 1391
1394
1395 // Verify that the valid API permissions have been recognized. 1392 // Verify that the valid API permissions have been recognized.
1396 expected_api_perms.insert("tabs"); 1393 expected_api_perms.insert("tabs");
1397 1394
1398 AddPattern(&expected_host_perms, "http://*.google.com/*"); 1395 AddPattern(&expected_host_perms, "http://*.google.com/*");
1399 AddPattern(&expected_host_perms, "https://*.google.com/*"); 1396 AddPattern(&expected_host_perms, "https://*.google.com/*");
1400 AddPattern(&expected_host_perms, "http://*.google.com.hk/*"); 1397 AddPattern(&expected_host_perms, "http://*.google.com.hk/*");
1401 AddPattern(&expected_host_perms, "http://www.example.com/*"); 1398 AddPattern(&expected_host_perms, "http://www.example.com/*");
1402 1399
1403 EXPECT_TRUE(prefs->GetGrantedPermissions(extension_id, 1400 known_perms.reset(prefs->GetGrantedPermissions(extension_id, &initialized));
1404 &full_access, 1401 EXPECT_TRUE(initialized);
1405 &known_api_perms, 1402 EXPECT_FALSE(known_perms->IsEmpty());
1406 &known_host_perms)); 1403 EXPECT_EQ(ExtensionAPIPermission::GetAllByName(expected_api_perms),
1407 1404 known_perms->apis());
1408 EXPECT_EQ(expected_api_perms, known_api_perms); 1405 EXPECT_FALSE(known_perms->native_code());
1409 EXPECT_FALSE(full_access); 1406 AssertEqualExtents(expected_host_perms, known_perms->effective_hosts());
1410 AssertEqualExtents(&expected_host_perms, &known_host_perms);
1411 } 1407 }
1412 1408
1413 #if !defined(OS_CHROMEOS) 1409 #if !defined(OS_CHROMEOS)
1414 // Tests that the granted permissions full_access bit gets set correctly when 1410 // Tests that the granted permissions full_access bit gets set correctly when
1415 // an extension contains an NPAPI plugin. Don't run this test on Chrome OS 1411 // an extension contains an NPAPI plugin. Don't run this test on Chrome OS
1416 // since they don't support plugins. 1412 // since they don't support plugins.
1417 TEST_F(ExtensionServiceTest, GrantedFullAccessPermissions) { 1413 TEST_F(ExtensionServiceTest, GrantedFullAccessPermissions) {
1418 InitializeEmptyExtensionService(); 1414 InitializeEmptyExtensionService();
1419 1415
1420 FilePath path = data_dir_ 1416 FilePath path = data_dir_
1421 .AppendASCII("good") 1417 .AppendASCII("good")
1422 .AppendASCII("Extensions") 1418 .AppendASCII("Extensions")
1423 .AppendASCII(good1) 1419 .AppendASCII(good1)
1424 .AppendASCII("2"); 1420 .AppendASCII("2");
1425 1421
1426 ASSERT_TRUE(file_util::PathExists(path)); 1422 ASSERT_TRUE(file_util::PathExists(path));
1427 1423
1428 PackAndInstallCrx(path, true); 1424 PackAndInstallCrx(path, true);
1429 1425
1430 EXPECT_EQ(0u, GetErrors().size()); 1426 EXPECT_EQ(0u, GetErrors().size());
1431 EXPECT_EQ(1u, service_->extensions()->size()); 1427 EXPECT_EQ(1u, service_->extensions()->size());
1432 const Extension* extension = service_->extensions()->at(0); 1428 const Extension* extension = service_->extensions()->at(0);
1433 std::string extension_id = extension->id(); 1429 std::string extension_id = extension->id();
1434 ExtensionPrefs* prefs = service_->extension_prefs(); 1430 ExtensionPrefs* prefs = service_->extension_prefs();
1435 1431
1436 bool full_access; 1432 scoped_ptr<ExtensionPermissionSet> permissions(
1437 std::set<std::string> api_permissions; 1433 prefs->GetGrantedPermissions(extension_id, NULL));
1438 URLPatternSet host_permissions; 1434 EXPECT_FALSE(permissions->IsEmpty());
1439 EXPECT_TRUE(prefs->GetGrantedPermissions( 1435 EXPECT_TRUE(permissions->native_code());
1440 extension_id, &full_access, &api_permissions, &host_permissions)); 1436 EXPECT_TRUE(permissions->apis().empty());
1441 1437 EXPECT_TRUE(permissions->effective_hosts().is_empty());
1442 EXPECT_TRUE(full_access);
1443 EXPECT_TRUE(api_permissions.empty());
1444 EXPECT_TRUE(host_permissions.is_empty());
1445 } 1438 }
1446 #endif 1439 #endif
1447 1440
1448 // Tests that the extension is disabled when permissions are missing from 1441 // Tests that the extension is disabled when permissions are missing from
1449 // the extension's granted permissions preferences. (This simulates updating 1442 // the extension's granted permissions preferences. (This simulates updating
1450 // the browser to a version which recognizes more permissions). 1443 // the browser to a version which recognizes more permissions).
1451 TEST_F(ExtensionServiceTest, GrantedAPIAndHostPermissions) { 1444 TEST_F(ExtensionServiceTest, GrantedAPIAndHostPermissions) {
1452 InitializeEmptyExtensionService(); 1445 InitializeEmptyExtensionService();
1453 1446
1454 FilePath path = data_dir_ 1447 FilePath path = data_dir_
1455 .AppendASCII("permissions") 1448 .AppendASCII("permissions")
1456 .AppendASCII("unknown"); 1449 .AppendASCII("unknown");
1457 1450
1458 ASSERT_TRUE(file_util::PathExists(path)); 1451 ASSERT_TRUE(file_util::PathExists(path));
1459 1452
1460 PackAndInstallCrx(path, true); 1453 PackAndInstallCrx(path, true);
1461 1454
1462 EXPECT_EQ(0u, GetErrors().size()); 1455 EXPECT_EQ(0u, GetErrors().size());
1463 EXPECT_EQ(1u, service_->extensions()->size()); 1456 EXPECT_EQ(1u, service_->extensions()->size());
1464 const Extension* extension = service_->extensions()->at(0); 1457 const Extension* extension = service_->extensions()->at(0);
1465 std::string extension_id = extension->id(); 1458 std::string extension_id = extension->id();
1466 1459
1467 ExtensionPrefs* prefs = service_->extension_prefs(); 1460 ExtensionPrefs* prefs = service_->extension_prefs();
1468 1461
1469 std::set<std::string> expected_api_permissions; 1462 std::set<std::string> expected_api_permissions;
1470 URLPatternSet expected_host_permissions; 1463 URLPatternSet expected_host_permissions;
1464 bool initialized = false;
1471 1465
1472 expected_api_permissions.insert("tabs"); 1466 expected_api_permissions.insert("tabs");
1473 AddPattern(&expected_host_permissions, "http://*.google.com/*"); 1467 AddPattern(&expected_host_permissions, "http://*.google.com/*");
1474 AddPattern(&expected_host_permissions, "https://*.google.com/*"); 1468 AddPattern(&expected_host_permissions, "https://*.google.com/*");
1475 AddPattern(&expected_host_permissions, "http://*.google.com.hk/*"); 1469 AddPattern(&expected_host_permissions, "http://*.google.com.hk/*");
1476 AddPattern(&expected_host_permissions, "http://www.example.com/*"); 1470 AddPattern(&expected_host_permissions, "http://www.example.com/*");
1477 1471
1478 std::set<std::string> api_permissions; 1472 std::set<std::string> api_permissions;
1479 std::set<std::string> host_permissions; 1473 std::set<std::string> host_permissions;
1480 1474
1481 // Test that the extension is disabled when an API permission is missing from 1475 // Test that the extension is disabled when an API permission is missing from
1482 // the extension's granted api permissions preference. (This simulates 1476 // the extension's granted api permissions preference. (This simulates
1483 // updating the browser to a version which recognizes a new API permission). 1477 // updating the browser to a version which recognizes a new API permission).
1484 SetPrefStringSet(extension_id, "granted_permissions.api", api_permissions); 1478 SetPrefStringSet(extension_id, "granted_permissions.api", api_permissions);
1485 1479
1486 service_->ReloadExtensions(); 1480 service_->ReloadExtensions();
1487 1481
1488 EXPECT_EQ(1u, service_->disabled_extensions()->size()); 1482 EXPECT_EQ(1u, service_->disabled_extensions()->size());
1489 extension = service_->disabled_extensions()->at(0); 1483 extension = service_->disabled_extensions()->at(0);
1490 1484
1491 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::DISABLED); 1485 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::DISABLED);
1492 ASSERT_TRUE(prefs->DidExtensionEscalatePermissions(extension_id)); 1486 ASSERT_TRUE(prefs->DidExtensionEscalatePermissions(extension_id));
1493 1487
1494 // Now grant and re-enable the extension, making sure the prefs are updated. 1488 // Now grant and re-enable the extension, making sure the prefs are updated.
1495 service_->GrantPermissionsAndEnableExtension(extension); 1489 service_->GrantPermissionsAndEnableExtension(extension);
1496 1490
1497 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::ENABLED); 1491 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::ENABLED);
1498 ASSERT_FALSE(prefs->DidExtensionEscalatePermissions(extension_id)); 1492 ASSERT_FALSE(prefs->DidExtensionEscalatePermissions(extension_id));
1499 1493
1500 std::set<std::string> current_api_permissions; 1494 scoped_ptr<ExtensionPermissionSet> current_perms(
1501 URLPatternSet current_host_permissions; 1495 prefs->GetGrantedPermissions(extension_id, &initialized));
1502 bool current_full_access; 1496 ASSERT_FALSE(current_perms->IsEmpty());
1503 1497 ASSERT_TRUE(initialized);
1504 ASSERT_TRUE(prefs->GetGrantedPermissions(extension_id, 1498 ASSERT_FALSE(current_perms->native_code());
1505 &current_full_access, 1499 ASSERT_EQ(ExtensionAPIPermission::GetAllByName(expected_api_permissions),
1506 &current_api_permissions, 1500 current_perms->apis());
1507 &current_host_permissions)); 1501 AssertEqualExtents(expected_host_permissions,
1508 1502 current_perms->effective_hosts());
1509 ASSERT_FALSE(current_full_access);
1510 ASSERT_EQ(expected_api_permissions, current_api_permissions);
1511 AssertEqualExtents(&expected_host_permissions, &current_host_permissions);
1512 1503
1513 // Tests that the extension is disabled when a host permission is missing from 1504 // Tests that the extension is disabled when a host permission is missing from
1514 // the extension's granted host permissions preference. (This simulates 1505 // the extension's granted host permissions preference. (This simulates
1515 // updating the browser to a version which recognizes additional host 1506 // updating the browser to a version which recognizes additional host
1516 // permissions). 1507 // permissions).
1517 api_permissions.clear(); 1508 api_permissions.clear();
1518 host_permissions.clear(); 1509 host_permissions.clear();
1519 current_api_permissions.clear(); 1510 current_perms.reset();
1520 current_host_permissions.ClearPatterns();
1521 1511
1522 api_permissions.insert("tabs"); 1512 api_permissions.insert("tabs");
1523 host_permissions.insert("http://*.google.com/*"); 1513 host_permissions.insert("http://*.google.com/*");
1524 host_permissions.insert("https://*.google.com/*"); 1514 host_permissions.insert("https://*.google.com/*");
1525 host_permissions.insert("http://*.google.com.hk/*"); 1515 host_permissions.insert("http://*.google.com.hk/*");
1526 1516
1527 SetPrefStringSet(extension_id, "granted_permissions.api", api_permissions); 1517 SetPrefStringSet(extension_id, "granted_permissions.api", api_permissions);
1528 SetPrefStringSet(extension_id, "granted_permissions.host", host_permissions); 1518 SetPrefStringSet(extension_id, "granted_permissions.host", host_permissions);
1529 1519
1530 service_->ReloadExtensions(); 1520 service_->ReloadExtensions();
1531 1521
1532 EXPECT_EQ(1u, service_->disabled_extensions()->size()); 1522 EXPECT_EQ(1u, service_->disabled_extensions()->size());
1533 extension = service_->disabled_extensions()->at(0); 1523 extension = service_->disabled_extensions()->at(0);
1534 1524
1535 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::DISABLED); 1525 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::DISABLED);
1536 ASSERT_TRUE(prefs->DidExtensionEscalatePermissions(extension_id)); 1526 ASSERT_TRUE(prefs->DidExtensionEscalatePermissions(extension_id));
1537 1527
1538 // Now grant and re-enable the extension, making sure the prefs are updated. 1528 // Now grant and re-enable the extension, making sure the prefs are updated.
1539 service_->GrantPermissionsAndEnableExtension(extension); 1529 service_->GrantPermissionsAndEnableExtension(extension);
1540 1530
1541 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::ENABLED); 1531 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::ENABLED);
1542 ASSERT_FALSE(prefs->DidExtensionEscalatePermissions(extension_id)); 1532 ASSERT_FALSE(prefs->DidExtensionEscalatePermissions(extension_id));
1543 1533
1544 ASSERT_TRUE(prefs->GetGrantedPermissions(extension_id, 1534 current_perms.reset(
1545 &current_full_access, 1535 prefs->GetGrantedPermissions(extension_id, &initialized));
1546 &current_api_permissions, 1536 ASSERT_TRUE(initialized);
1547 &current_host_permissions)); 1537 ASSERT_FALSE(current_perms->IsEmpty());
1548 1538 ASSERT_FALSE(current_perms->native_code());
1549 ASSERT_FALSE(current_full_access); 1539 ASSERT_EQ(ExtensionAPIPermission::GetAllByName(expected_api_permissions),
1550 ASSERT_EQ(expected_api_permissions, current_api_permissions); 1540 current_perms->apis());
1551 AssertEqualExtents(&expected_host_permissions, &current_host_permissions); 1541 AssertEqualExtents(expected_host_permissions,
1542 current_perms->effective_hosts());
1552 1543
1553 // Tests that the granted permissions preferences are initialized when 1544 // Tests that the granted permissions preferences are initialized when
1554 // migrating from the old pref schema. 1545 // migrating from the old pref schema.
1555 current_api_permissions.clear(); 1546 current_perms.reset();
1556 current_host_permissions.ClearPatterns();
1557 1547
1558 ClearPref(extension_id, "granted_permissions"); 1548 ClearPref(extension_id, "granted_permissions");
1559 1549
1560 service_->ReloadExtensions(); 1550 service_->ReloadExtensions();
1561 1551
1562 EXPECT_EQ(1u, service_->extensions()->size()); 1552 EXPECT_EQ(1u, service_->extensions()->size());
1563 extension = service_->extensions()->at(0); 1553 extension = service_->extensions()->at(0);
1564 1554
1565 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::ENABLED); 1555 ASSERT_TRUE(prefs->GetExtensionState(extension_id) == Extension::ENABLED);
1566 ASSERT_FALSE(prefs->DidExtensionEscalatePermissions(extension_id)); 1556 ASSERT_FALSE(prefs->DidExtensionEscalatePermissions(extension_id));
1567 1557
1568 ASSERT_TRUE(prefs->GetGrantedPermissions(extension_id, 1558 current_perms.reset(prefs->GetGrantedPermissions(extension_id, NULL));
1569 &current_full_access, 1559 ASSERT_FALSE(current_perms->IsEmpty());
1570 &current_api_permissions, 1560 ASSERT_FALSE(current_perms->native_code());
1571 &current_host_permissions)); 1561 ASSERT_EQ(ExtensionAPIPermission::GetAllByName(expected_api_permissions),
1572 1562 current_perms->apis());
1573 ASSERT_FALSE(current_full_access); 1563 AssertEqualExtents(expected_host_permissions,
1574 ASSERT_EQ(expected_api_permissions, current_api_permissions); 1564 current_perms->effective_hosts());
1575 AssertEqualExtents(&expected_host_permissions, &current_host_permissions);
1576 } 1565 }
1577 1566
1578 // Test Packaging and installing an extension. 1567 // Test Packaging and installing an extension.
1579 TEST_F(ExtensionServiceTest, PackExtension) { 1568 TEST_F(ExtensionServiceTest, PackExtension) {
1580 InitializeEmptyExtensionService(); 1569 InitializeEmptyExtensionService();
1581 FilePath input_directory = data_dir_ 1570 FilePath input_directory = data_dir_
1582 .AppendASCII("good") 1571 .AppendASCII("good")
1583 .AppendASCII("Extensions") 1572 .AppendASCII("Extensions")
1584 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 1573 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
1585 .AppendASCII("1.0.0.0"); 1574 .AppendASCII("1.0.0.0");
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 1817
1829 int pref_count = 0; 1818 int pref_count = 0;
1830 1819
1831 // Install app1 with unlimited storage. 1820 // Install app1 with unlimited storage.
1832 PackAndInstallCrx(data_dir_.AppendASCII("app1"), true); 1821 PackAndInstallCrx(data_dir_.AppendASCII("app1"), true);
1833 ValidatePrefKeyCount(++pref_count); 1822 ValidatePrefKeyCount(++pref_count);
1834 ASSERT_EQ(1u, service_->extensions()->size()); 1823 ASSERT_EQ(1u, service_->extensions()->size());
1835 const Extension* extension = service_->extensions()->at(0); 1824 const Extension* extension = service_->extensions()->at(0);
1836 const std::string id1 = extension->id(); 1825 const std::string id1 = extension->id();
1837 EXPECT_TRUE(extension->HasApiPermission( 1826 EXPECT_TRUE(extension->HasApiPermission(
1838 Extension::kUnlimitedStoragePermission)); 1827 ExtensionAPIPermission::UnlimitedStorage()));
1839 EXPECT_TRUE(extension->web_extent().MatchesURL( 1828 EXPECT_TRUE(extension->web_extent().MatchesURL(
1840 extension->GetFullLaunchURL())); 1829 extension->GetFullLaunchURL()));
1841 const GURL origin1(extension->GetFullLaunchURL().GetOrigin()); 1830 const GURL origin1(extension->GetFullLaunchURL().GetOrigin());
1842 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 1831 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
1843 IsStorageUnlimited(origin1)); 1832 IsStorageUnlimited(origin1));
1844 1833
1845 // Install app2 from the same origin with unlimited storage. 1834 // Install app2 from the same origin with unlimited storage.
1846 PackAndInstallCrx(data_dir_.AppendASCII("app2"), true); 1835 PackAndInstallCrx(data_dir_.AppendASCII("app2"), true);
1847 ValidatePrefKeyCount(++pref_count); 1836 ValidatePrefKeyCount(++pref_count);
1848 ASSERT_EQ(2u, service_->extensions()->size()); 1837 ASSERT_EQ(2u, service_->extensions()->size());
1849 extension = service_->extensions()->at(1); 1838 extension = service_->extensions()->at(1);
1850 const std::string id2 = extension->id(); 1839 const std::string id2 = extension->id();
1851 EXPECT_TRUE(extension->HasApiPermission( 1840 EXPECT_TRUE(extension->HasApiPermission(
1852 Extension::kUnlimitedStoragePermission)); 1841 ExtensionAPIPermission::UnlimitedStorage()));
1853 EXPECT_TRUE(extension->web_extent().MatchesURL( 1842 EXPECT_TRUE(extension->web_extent().MatchesURL(
1854 extension->GetFullLaunchURL())); 1843 extension->GetFullLaunchURL()));
1855 const GURL origin2(extension->GetFullLaunchURL().GetOrigin()); 1844 const GURL origin2(extension->GetFullLaunchURL().GetOrigin());
1856 EXPECT_EQ(origin1, origin2); 1845 EXPECT_EQ(origin1, origin2);
1857 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 1846 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
1858 IsStorageUnlimited(origin2)); 1847 IsStorageUnlimited(origin2));
1859 1848
1860 1849
1861 // Uninstall one of them, unlimited storage should still be granted 1850 // Uninstall one of them, unlimited storage should still be granted
1862 // to the origin. 1851 // to the origin.
(...skipping 1937 matching lines...) Expand 10 before | Expand all | Expand 10 after
3800 ASSERT_FALSE(AddPendingSyncInstall()); 3789 ASSERT_FALSE(AddPendingSyncInstall());
3801 3790
3802 // Wait for the external source to install. 3791 // Wait for the external source to install.
3803 WaitForCrxInstall(crx_path_, true); 3792 WaitForCrxInstall(crx_path_, true);
3804 ASSERT_TRUE(IsCrxInstalled()); 3793 ASSERT_TRUE(IsCrxInstalled());
3805 3794
3806 // Now that the extension is installed, sync request should fail 3795 // Now that the extension is installed, sync request should fail
3807 // because the extension is already installed. 3796 // because the extension is already installed.
3808 ASSERT_FALSE(AddPendingSyncInstall()); 3797 ASSERT_FALSE(AddPendingSyncInstall());
3809 } 3798 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698