OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/values.h" | 6 #include "base/values.h" |
7 #include "chrome/browser/content_settings/cookie_settings.h" | 7 #include "chrome/browser/content_settings/cookie_settings.h" |
8 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 8 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
9 #include "chrome/common/content_settings.h" | 9 #include "chrome/common/content_settings.h" |
10 #include "chrome/common/content_settings_types.h" | 10 #include "chrome/common/content_settings_types.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 policy_->RevokeRightsForExtension(extension); | 226 policy_->RevokeRightsForExtension(extension); |
227 ExpectProtectedBy(empty_set, GURL("http://explicit/")); | 227 ExpectProtectedBy(empty_set, GURL("http://explicit/")); |
228 ExpectProtectedBy(empty_set, GURL("https://foo.wildcards/")); | 228 ExpectProtectedBy(empty_set, GURL("https://foo.wildcards/")); |
229 ExpectProtectedBy(empty_set, GURL("https://foo.wildcards/")); | 229 ExpectProtectedBy(empty_set, GURL("https://foo.wildcards/")); |
230 ExpectProtectedBy(empty_set, GURL("http://bar.wildcards/")); | 230 ExpectProtectedBy(empty_set, GURL("http://bar.wildcards/")); |
231 EXPECT_FALSE(policy_->IsStorageUnlimited(GURL("http://explicit/"))); | 231 EXPECT_FALSE(policy_->IsStorageUnlimited(GURL("http://explicit/"))); |
232 EXPECT_FALSE(policy_->IsStorageUnlimited(GURL("https://foo.wildcards/"))); | 232 EXPECT_FALSE(policy_->IsStorageUnlimited(GURL("https://foo.wildcards/"))); |
233 EXPECT_FALSE(policy_->IsStorageUnlimited(GURL("https://bar.wildcards/"))); | 233 EXPECT_FALSE(policy_->IsStorageUnlimited(GURL("https://bar.wildcards/"))); |
234 } | 234 } |
235 | 235 |
236 TEST_F(ExtensionSpecialStoragePolicyTest, IsInstalled) { | 236 TEST_F(ExtensionSpecialStoragePolicyTest, CanQueryDiskSize) { |
237 const GURL kHttpUrl("http://foo"); | 237 const GURL kHttpUrl("http://foo"); |
238 const GURL kExtensionUrl("chrome-extension://bar"); | 238 const GURL kExtensionUrl("chrome-extension://bar"); |
239 scoped_refptr<Extension> regular_app(CreateRegularApp()); | 239 scoped_refptr<Extension> regular_app(CreateRegularApp()); |
240 scoped_refptr<Extension> protected_app(CreateProtectedApp()); | 240 scoped_refptr<Extension> protected_app(CreateProtectedApp()); |
241 scoped_refptr<Extension> unlimited_app(CreateUnlimitedApp()); | 241 scoped_refptr<Extension> unlimited_app(CreateUnlimitedApp()); |
242 policy_->GrantRightsForExtension(regular_app); | 242 policy_->GrantRightsForExtension(regular_app); |
243 policy_->GrantRightsForExtension(protected_app); | 243 policy_->GrantRightsForExtension(protected_app); |
244 policy_->GrantRightsForExtension(unlimited_app); | 244 policy_->GrantRightsForExtension(unlimited_app); |
245 | 245 |
246 EXPECT_FALSE(policy_->IsInstalledApp(kHttpUrl)); | 246 EXPECT_FALSE(policy_->CanQueryDiskSize(kHttpUrl)); |
247 EXPECT_FALSE(policy_->IsInstalledApp(kExtensionUrl)); | 247 EXPECT_FALSE(policy_->CanQueryDiskSize(kExtensionUrl)); |
248 EXPECT_TRUE(policy_->IsInstalledApp(regular_app->url())); | 248 EXPECT_TRUE(policy_->CanQueryDiskSize(regular_app->url())); |
249 EXPECT_TRUE(policy_->IsInstalledApp(protected_app->url())); | 249 EXPECT_TRUE(policy_->CanQueryDiskSize(protected_app->url())); |
250 EXPECT_TRUE(policy_->IsInstalledApp(unlimited_app->url())); | 250 EXPECT_TRUE(policy_->CanQueryDiskSize(unlimited_app->url())); |
251 } | 251 } |
252 | 252 |
253 TEST_F(ExtensionSpecialStoragePolicyTest, OverlappingApps) { | 253 TEST_F(ExtensionSpecialStoragePolicyTest, OverlappingApps) { |
254 scoped_refptr<Extension> protected_app(CreateProtectedApp()); | 254 scoped_refptr<Extension> protected_app(CreateProtectedApp()); |
255 scoped_refptr<Extension> unlimited_app(CreateUnlimitedApp()); | 255 scoped_refptr<Extension> unlimited_app(CreateUnlimitedApp()); |
256 policy_->GrantRightsForExtension(protected_app); | 256 policy_->GrantRightsForExtension(protected_app); |
257 policy_->GrantRightsForExtension(unlimited_app); | 257 policy_->GrantRightsForExtension(unlimited_app); |
258 ExtensionSet protecting_extensions; | 258 ExtensionSet protecting_extensions; |
259 ExtensionSet empty_set; | 259 ExtensionSet empty_set; |
260 protecting_extensions.Insert(protected_app); | 260 protecting_extensions.Insert(protected_app); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 CONTENT_SETTING_SESSION_ONLY); | 314 CONTENT_SETTING_SESSION_ONLY); |
315 | 315 |
316 EXPECT_TRUE(policy_->HasSessionOnlyOrigins()); | 316 EXPECT_TRUE(policy_->HasSessionOnlyOrigins()); |
317 | 317 |
318 // Clearing an origin-specific rule. | 318 // Clearing an origin-specific rule. |
319 cookie_settings->ResetCookieSetting(pattern, | 319 cookie_settings->ResetCookieSetting(pattern, |
320 ContentSettingsPattern::Wildcard()); | 320 ContentSettingsPattern::Wildcard()); |
321 | 321 |
322 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); | 322 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); |
323 } | 323 } |
OLD | NEW |