OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 #include "extensions/browser/pref_names.h" | 97 #include "extensions/browser/pref_names.h" |
98 #include "extensions/browser/test_management_policy.h" | 98 #include "extensions/browser/test_management_policy.h" |
99 #include "extensions/common/constants.h" | 99 #include "extensions/common/constants.h" |
100 #include "extensions/common/extension.h" | 100 #include "extensions/common/extension.h" |
101 #include "extensions/common/extension_builder.h" | 101 #include "extensions/common/extension_builder.h" |
102 #include "extensions/common/extension_l10n_util.h" | 102 #include "extensions/common/extension_l10n_util.h" |
103 #include "extensions/common/extension_resource.h" | 103 #include "extensions/common/extension_resource.h" |
104 #include "extensions/common/manifest_constants.h" | 104 #include "extensions/common/manifest_constants.h" |
105 #include "extensions/common/manifest_handlers/background_info.h" | 105 #include "extensions/common/manifest_handlers/background_info.h" |
106 #include "extensions/common/permissions/permission_set.h" | 106 #include "extensions/common/permissions/permission_set.h" |
| 107 #include "extensions/common/permissions/permissions_data.h" |
107 #include "extensions/common/switches.h" | 108 #include "extensions/common/switches.h" |
108 #include "extensions/common/url_pattern.h" | 109 #include "extensions/common/url_pattern.h" |
109 #include "extensions/common/value_builder.h" | 110 #include "extensions/common/value_builder.h" |
110 #include "gpu/config/gpu_info.h" | 111 #include "gpu/config/gpu_info.h" |
111 #include "grit/browser_resources.h" | 112 #include "grit/browser_resources.h" |
112 #include "net/cookies/canonical_cookie.h" | 113 #include "net/cookies/canonical_cookie.h" |
113 #include "net/cookies/cookie_monster.h" | 114 #include "net/cookies/cookie_monster.h" |
114 #include "net/cookies/cookie_options.h" | 115 #include "net/cookies/cookie_options.h" |
115 #include "net/url_request/url_request_context.h" | 116 #include "net/url_request/url_request_context.h" |
116 #include "net/url_request/url_request_context_getter.h" | 117 #include "net/url_request/url_request_context_getter.h" |
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 scripts[1].js_scripts()[0].extension_root(), | 1395 scripts[1].js_scripts()[0].extension_root(), |
1395 scripts[1].js_scripts()[0].relative_path()); | 1396 scripts[1].js_scripts()[0].relative_path()); |
1396 expected_path = | 1397 expected_path = |
1397 extension->path().AppendASCII("js_files").AppendASCII("script3.js"); | 1398 extension->path().AppendASCII("js_files").AppendASCII("script3.js"); |
1398 expected_path = base::MakeAbsoluteFilePath(expected_path); | 1399 expected_path = base::MakeAbsoluteFilePath(expected_path); |
1399 EXPECT_TRUE(resource10.ComparePathWithDefault(expected_path)); | 1400 EXPECT_TRUE(resource10.ComparePathWithDefault(expected_path)); |
1400 | 1401 |
1401 expected_patterns.ClearPatterns(); | 1402 expected_patterns.ClearPatterns(); |
1402 AddPattern(&expected_patterns, "http://*.google.com/*"); | 1403 AddPattern(&expected_patterns, "http://*.google.com/*"); |
1403 AddPattern(&expected_patterns, "https://*.google.com/*"); | 1404 AddPattern(&expected_patterns, "https://*.google.com/*"); |
1404 EXPECT_EQ(expected_patterns, | 1405 EXPECT_EQ( |
1405 extension->GetActivePermissions()->explicit_hosts()); | 1406 expected_patterns, |
| 1407 extension->permissions_data()->active_permissions()->explicit_hosts()); |
1406 | 1408 |
1407 EXPECT_EQ(std::string(good1), loaded_[1]->id()); | 1409 EXPECT_EQ(std::string(good1), loaded_[1]->id()); |
1408 EXPECT_EQ(std::string("My extension 2"), loaded_[1]->name()); | 1410 EXPECT_EQ(std::string("My extension 2"), loaded_[1]->name()); |
1409 EXPECT_EQ(std::string(), loaded_[1]->description()); | 1411 EXPECT_EQ(std::string(), loaded_[1]->description()); |
1410 EXPECT_EQ(loaded_[1]->GetResourceURL("background.html"), | 1412 EXPECT_EQ(loaded_[1]->GetResourceURL("background.html"), |
1411 extensions::BackgroundInfo::GetBackgroundURL(loaded_[1].get())); | 1413 extensions::BackgroundInfo::GetBackgroundURL(loaded_[1].get())); |
1412 EXPECT_EQ(0u, | 1414 EXPECT_EQ(0u, |
1413 extensions::ContentScriptsInfo::GetContentScripts(loaded_[1].get()) | 1415 extensions::ContentScriptsInfo::GetContentScripts(loaded_[1].get()) |
1414 .size()); | 1416 .size()); |
1415 | 1417 |
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2598 EXPECT_TRUE(registry_->enabled_extensions().is_empty()); | 2600 EXPECT_TRUE(registry_->enabled_extensions().is_empty()); |
2599 | 2601 |
2600 int pref_count = 0; | 2602 int pref_count = 0; |
2601 | 2603 |
2602 // Install app1 with unlimited storage. | 2604 // Install app1 with unlimited storage. |
2603 const Extension* extension = | 2605 const Extension* extension = |
2604 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); | 2606 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); |
2605 ValidatePrefKeyCount(++pref_count); | 2607 ValidatePrefKeyCount(++pref_count); |
2606 ASSERT_EQ(1u, registry_->enabled_extensions().size()); | 2608 ASSERT_EQ(1u, registry_->enabled_extensions().size()); |
2607 const std::string id1 = extension->id(); | 2609 const std::string id1 = extension->id(); |
2608 EXPECT_TRUE(extension->HasAPIPermission( | 2610 EXPECT_TRUE(extension->permissions_data()->HasAPIPermission( |
2609 APIPermission::kUnlimitedStorage)); | 2611 APIPermission::kUnlimitedStorage)); |
2610 EXPECT_TRUE(extension->web_extent().MatchesURL( | 2612 EXPECT_TRUE(extension->web_extent().MatchesURL( |
2611 extensions::AppLaunchInfo::GetFullLaunchURL(extension))); | 2613 extensions::AppLaunchInfo::GetFullLaunchURL(extension))); |
2612 const GURL origin1( | 2614 const GURL origin1( |
2613 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); | 2615 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); |
2614 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> | 2616 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> |
2615 IsStorageUnlimited(origin1)); | 2617 IsStorageUnlimited(origin1)); |
2616 | 2618 |
2617 // Install app2 from the same origin with unlimited storage. | 2619 // Install app2 from the same origin with unlimited storage. |
2618 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); | 2620 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); |
2619 ValidatePrefKeyCount(++pref_count); | 2621 ValidatePrefKeyCount(++pref_count); |
2620 ASSERT_EQ(2u, registry_->enabled_extensions().size()); | 2622 ASSERT_EQ(2u, registry_->enabled_extensions().size()); |
2621 const std::string id2 = extension->id(); | 2623 const std::string id2 = extension->id(); |
2622 EXPECT_TRUE(extension->HasAPIPermission( | 2624 EXPECT_TRUE(extension->permissions_data()->HasAPIPermission( |
2623 APIPermission::kUnlimitedStorage)); | 2625 APIPermission::kUnlimitedStorage)); |
2624 EXPECT_TRUE(extension->web_extent().MatchesURL( | 2626 EXPECT_TRUE(extension->web_extent().MatchesURL( |
2625 extensions::AppLaunchInfo::GetFullLaunchURL(extension))); | 2627 extensions::AppLaunchInfo::GetFullLaunchURL(extension))); |
2626 const GURL origin2( | 2628 const GURL origin2( |
2627 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); | 2629 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); |
2628 EXPECT_EQ(origin1, origin2); | 2630 EXPECT_EQ(origin1, origin2); |
2629 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> | 2631 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> |
2630 IsStorageUnlimited(origin2)); | 2632 IsStorageUnlimited(origin2)); |
2631 | 2633 |
2632 // Uninstall one of them, unlimited storage should still be granted | 2634 // Uninstall one of them, unlimited storage should still be granted |
(...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4513 ExtensionCookieCallback callback; | 4515 ExtensionCookieCallback callback; |
4514 | 4516 |
4515 int pref_count = 0; | 4517 int pref_count = 0; |
4516 | 4518 |
4517 // Install app1 with unlimited storage. | 4519 // Install app1 with unlimited storage. |
4518 const Extension* extension = | 4520 const Extension* extension = |
4519 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); | 4521 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); |
4520 ValidatePrefKeyCount(++pref_count); | 4522 ValidatePrefKeyCount(++pref_count); |
4521 ASSERT_EQ(1u, registry_->enabled_extensions().size()); | 4523 ASSERT_EQ(1u, registry_->enabled_extensions().size()); |
4522 const std::string id1 = extension->id(); | 4524 const std::string id1 = extension->id(); |
4523 EXPECT_TRUE(extension->HasAPIPermission( | 4525 EXPECT_TRUE(extension->permissions_data()->HasAPIPermission( |
4524 APIPermission::kUnlimitedStorage)); | 4526 APIPermission::kUnlimitedStorage)); |
4525 const GURL origin1( | 4527 const GURL origin1( |
4526 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); | 4528 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); |
4527 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> | 4529 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> |
4528 IsStorageUnlimited(origin1)); | 4530 IsStorageUnlimited(origin1)); |
4529 std::string origin_id = webkit_database::GetIdentifierFromOrigin(origin1); | 4531 std::string origin_id = webkit_database::GetIdentifierFromOrigin(origin1); |
4530 | 4532 |
4531 // Install app2 from the same origin with unlimited storage. | 4533 // Install app2 from the same origin with unlimited storage. |
4532 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); | 4534 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); |
4533 ValidatePrefKeyCount(++pref_count); | 4535 ValidatePrefKeyCount(++pref_count); |
4534 ASSERT_EQ(2u, registry_->enabled_extensions().size()); | 4536 ASSERT_EQ(2u, registry_->enabled_extensions().size()); |
4535 const std::string id2 = extension->id(); | 4537 const std::string id2 = extension->id(); |
4536 EXPECT_TRUE(extension->HasAPIPermission( | 4538 EXPECT_TRUE(extension->permissions_data()->HasAPIPermission( |
4537 APIPermission::kUnlimitedStorage)); | 4539 APIPermission::kUnlimitedStorage)); |
4538 EXPECT_TRUE(extension->web_extent().MatchesURL( | 4540 EXPECT_TRUE(extension->web_extent().MatchesURL( |
4539 extensions::AppLaunchInfo::GetFullLaunchURL(extension))); | 4541 extensions::AppLaunchInfo::GetFullLaunchURL(extension))); |
4540 const GURL origin2( | 4542 const GURL origin2( |
4541 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); | 4543 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); |
4542 EXPECT_EQ(origin1, origin2); | 4544 EXPECT_EQ(origin1, origin2); |
4543 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> | 4545 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> |
4544 IsStorageUnlimited(origin2)); | 4546 IsStorageUnlimited(origin2)); |
4545 | 4547 |
4546 // Set a cookie for the extension. | 4548 // Set a cookie for the extension. |
(...skipping 2486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7033 | 7035 |
7034 service_->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, | 7036 service_->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, |
7035 content::Source<Profile>(profile_.get()), | 7037 content::Source<Profile>(profile_.get()), |
7036 content::NotificationService::NoDetails()); | 7038 content::NotificationService::NoDetails()); |
7037 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); | 7039 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); |
7038 EXPECT_EQ(0u, registry_->enabled_extensions().size()); | 7040 EXPECT_EQ(0u, registry_->enabled_extensions().size()); |
7039 EXPECT_EQ(0u, registry_->disabled_extensions().size()); | 7041 EXPECT_EQ(0u, registry_->disabled_extensions().size()); |
7040 EXPECT_EQ(0u, registry_->terminated_extensions().size()); | 7042 EXPECT_EQ(0u, registry_->terminated_extensions().size()); |
7041 EXPECT_EQ(0u, registry_->blacklisted_extensions().size()); | 7043 EXPECT_EQ(0u, registry_->blacklisted_extensions().size()); |
7042 } | 7044 } |
OLD | NEW |