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 "net/url_request/url_request_context.h" | 97 #include "net/url_request/url_request_context.h" |
98 #include "net/url_request/url_request_context_getter.h" | 98 #include "net/url_request/url_request_context_getter.h" |
99 #include "sync/api/string_ordinal.h" | 99 #include "sync/api/string_ordinal.h" |
100 #include "sync/api/sync_error_factory.h" | 100 #include "sync/api/sync_error_factory.h" |
101 #include "sync/api/sync_error_factory_mock.h" | 101 #include "sync/api/sync_error_factory_mock.h" |
102 #include "sync/protocol/app_specifics.pb.h" | 102 #include "sync/protocol/app_specifics.pb.h" |
103 #include "sync/protocol/extension_specifics.pb.h" | 103 #include "sync/protocol/extension_specifics.pb.h" |
104 #include "sync/protocol/sync.pb.h" | 104 #include "sync/protocol/sync.pb.h" |
105 #include "testing/gtest/include/gtest/gtest.h" | 105 #include "testing/gtest/include/gtest/gtest.h" |
106 #include "testing/platform_test.h" | 106 #include "testing/platform_test.h" |
107 #include "webkit/base/origin_url_conversions.h" | |
108 #include "webkit/browser/database/database_tracker.h" | 107 #include "webkit/browser/database/database_tracker.h" |
109 #include "webkit/browser/quota/quota_manager.h" | 108 #include "webkit/browser/quota/quota_manager.h" |
| 109 #include "webkit/common/database/database_identifier.h" |
110 #include "webkit/plugins/npapi/mock_plugin_list.h" | 110 #include "webkit/plugins/npapi/mock_plugin_list.h" |
111 | 111 |
112 #if defined(OS_CHROMEOS) | 112 #if defined(OS_CHROMEOS) |
113 #include "chrome/browser/chromeos/extensions/install_limiter.h" | 113 #include "chrome/browser/chromeos/extensions/install_limiter.h" |
114 #include "chrome/browser/chromeos/login/user_manager.h" | 114 #include "chrome/browser/chromeos/login/user_manager.h" |
115 #include "chrome/browser/chromeos/settings/cros_settings.h" | 115 #include "chrome/browser/chromeos/settings/cros_settings.h" |
116 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 116 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
117 #endif | 117 #endif |
118 | 118 |
119 using content::BrowserContext; | 119 using content::BrowserContext; |
(...skipping 3765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3885 TEST_F(ExtensionServiceTest, ClearExtensionData) { | 3885 TEST_F(ExtensionServiceTest, ClearExtensionData) { |
3886 InitializeEmptyExtensionService(); | 3886 InitializeEmptyExtensionService(); |
3887 ExtensionCookieCallback callback; | 3887 ExtensionCookieCallback callback; |
3888 | 3888 |
3889 // Load a test extension. | 3889 // Load a test extension. |
3890 base::FilePath path = data_dir_; | 3890 base::FilePath path = data_dir_; |
3891 path = path.AppendASCII("good.crx"); | 3891 path = path.AppendASCII("good.crx"); |
3892 const Extension* extension = InstallCRX(path, INSTALL_NEW); | 3892 const Extension* extension = InstallCRX(path, INSTALL_NEW); |
3893 ASSERT_TRUE(extension); | 3893 ASSERT_TRUE(extension); |
3894 GURL ext_url(extension->url()); | 3894 GURL ext_url(extension->url()); |
3895 std::string origin_id = webkit_base::GetOriginIdentifierFromURL(ext_url); | 3895 std::string origin_id = webkit_database::GetIdentifierFromOrigin(ext_url); |
3896 | 3896 |
3897 // Set a cookie for the extension. | 3897 // Set a cookie for the extension. |
3898 net::CookieMonster* cookie_monster = | 3898 net::CookieMonster* cookie_monster = |
3899 profile_->GetRequestContextForExtensions()->GetURLRequestContext()-> | 3899 profile_->GetRequestContextForExtensions()->GetURLRequestContext()-> |
3900 cookie_store()->GetCookieMonster(); | 3900 cookie_store()->GetCookieMonster(); |
3901 ASSERT_TRUE(cookie_monster); | 3901 ASSERT_TRUE(cookie_monster); |
3902 net::CookieOptions options; | 3902 net::CookieOptions options; |
3903 cookie_monster->SetCookieWithOptionsAsync( | 3903 cookie_monster->SetCookieWithOptionsAsync( |
3904 ext_url, "dummy=value", options, | 3904 ext_url, "dummy=value", options, |
3905 base::Bind(&ExtensionCookieCallback::SetCookieCallback, | 3905 base::Bind(&ExtensionCookieCallback::SetCookieCallback, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3985 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); | 3985 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); |
3986 ValidatePrefKeyCount(++pref_count); | 3986 ValidatePrefKeyCount(++pref_count); |
3987 ASSERT_EQ(1u, service_->extensions()->size()); | 3987 ASSERT_EQ(1u, service_->extensions()->size()); |
3988 const std::string id1 = extension->id(); | 3988 const std::string id1 = extension->id(); |
3989 EXPECT_TRUE(extension->HasAPIPermission( | 3989 EXPECT_TRUE(extension->HasAPIPermission( |
3990 APIPermission::kUnlimitedStorage)); | 3990 APIPermission::kUnlimitedStorage)); |
3991 const GURL origin1( | 3991 const GURL origin1( |
3992 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); | 3992 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); |
3993 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> | 3993 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> |
3994 IsStorageUnlimited(origin1)); | 3994 IsStorageUnlimited(origin1)); |
3995 std::string origin_id = webkit_base::GetOriginIdentifierFromURL(origin1); | 3995 std::string origin_id = webkit_database::GetIdentifierFromOrigin(origin1); |
3996 | 3996 |
3997 // Install app2 from the same origin with unlimited storage. | 3997 // Install app2 from the same origin with unlimited storage. |
3998 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); | 3998 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); |
3999 ValidatePrefKeyCount(++pref_count); | 3999 ValidatePrefKeyCount(++pref_count); |
4000 ASSERT_EQ(2u, service_->extensions()->size()); | 4000 ASSERT_EQ(2u, service_->extensions()->size()); |
4001 const std::string id2 = extension->id(); | 4001 const std::string id2 = extension->id(); |
4002 EXPECT_TRUE(extension->HasAPIPermission( | 4002 EXPECT_TRUE(extension->HasAPIPermission( |
4003 APIPermission::kUnlimitedStorage)); | 4003 APIPermission::kUnlimitedStorage)); |
4004 EXPECT_TRUE(extension->web_extent().MatchesURL( | 4004 EXPECT_TRUE(extension->web_extent().MatchesURL( |
4005 extensions::AppLaunchInfo::GetFullLaunchURL(extension))); | 4005 extensions::AppLaunchInfo::GetFullLaunchURL(extension))); |
(...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6027 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF); | 6027 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF); |
6028 AddMockExternalProvider(provider); | 6028 AddMockExternalProvider(provider); |
6029 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path); | 6029 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path); |
6030 | 6030 |
6031 service_->CheckForExternalUpdates(); | 6031 service_->CheckForExternalUpdates(); |
6032 loop_.RunUntilIdle(); | 6032 loop_.RunUntilIdle(); |
6033 EXPECT_TRUE(extensions::HasExternalInstallError(service_)); | 6033 EXPECT_TRUE(extensions::HasExternalInstallError(service_)); |
6034 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_)); | 6034 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_)); |
6035 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore)); | 6035 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore)); |
6036 } | 6036 } |
OLD | NEW |