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/values.h" | 5 #include "base/values.h" |
6 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 6 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
7 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 7 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
8 #include "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
9 #include "components/content_settings/core/browser/cookie_settings.h" | 9 #include "components/content_settings/core/browser/cookie_settings.h" |
10 #include "components/content_settings/core/common/content_settings.h" | 10 #include "components/content_settings/core/common/content_settings.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 335 |
336 EXPECT_TRUE(policy_->HasSessionOnlyOrigins()); | 336 EXPECT_TRUE(policy_->HasSessionOnlyOrigins()); |
337 | 337 |
338 // Clearing an origin-specific rule. | 338 // Clearing an origin-specific rule. |
339 cookie_settings->ResetCookieSetting(pattern, | 339 cookie_settings->ResetCookieSetting(pattern, |
340 ContentSettingsPattern::Wildcard()); | 340 ContentSettingsPattern::Wildcard()); |
341 | 341 |
342 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); | 342 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); |
343 } | 343 } |
344 | 344 |
| 345 TEST_F(ExtensionSpecialStoragePolicyTest, IsStorageDurableTest) { |
| 346 TestingProfile profile; |
| 347 content_settings::CookieSettings* cookie_settings = |
| 348 CookieSettingsFactory::GetForProfile(&profile).get(); |
| 349 policy_ = new ExtensionSpecialStoragePolicy(cookie_settings); |
| 350 const GURL kHttpUrl("http://foo.com"); |
| 351 |
| 352 EXPECT_FALSE(policy_->IsStorageDurable(kHttpUrl)); |
| 353 |
| 354 HostContentSettingsMap* content_settings_map = |
| 355 profile.GetHostContentSettingsMap(); |
| 356 content_settings_map->SetContentSetting( |
| 357 ContentSettingsPattern::FromString("foo.com"), |
| 358 ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, |
| 359 std::string(), CONTENT_SETTING_ALLOW); |
| 360 |
| 361 EXPECT_TRUE(policy_->IsStorageDurable(kHttpUrl)); |
| 362 } |
| 363 |
345 TEST_F(ExtensionSpecialStoragePolicyTest, NotificationTest) { | 364 TEST_F(ExtensionSpecialStoragePolicyTest, NotificationTest) { |
346 PolicyChangeObserver observer; | 365 PolicyChangeObserver observer; |
347 policy_->AddObserver(&observer); | 366 policy_->AddObserver(&observer); |
348 | 367 |
349 scoped_refptr<Extension> apps[] = { | 368 scoped_refptr<Extension> apps[] = { |
350 CreateProtectedApp(), | 369 CreateProtectedApp(), |
351 CreateUnlimitedApp(), | 370 CreateUnlimitedApp(), |
352 }; | 371 }; |
353 | 372 |
354 int change_flags[] = { | 373 int change_flags[] = { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 EXPECT_TRUE(observer.IsCompleted()); | 408 EXPECT_TRUE(observer.IsCompleted()); |
390 } | 409 } |
391 | 410 |
392 observer.ExpectClear(); | 411 observer.ExpectClear(); |
393 policy_->RevokeRightsForAllExtensions(); | 412 policy_->RevokeRightsForAllExtensions(); |
394 base::MessageLoop::current()->RunUntilIdle(); | 413 base::MessageLoop::current()->RunUntilIdle(); |
395 EXPECT_TRUE(observer.IsCompleted()); | 414 EXPECT_TRUE(observer.IsCompleted()); |
396 | 415 |
397 policy_->RemoveObserver(&observer); | 416 policy_->RemoveObserver(&observer); |
398 } | 417 } |
OLD | NEW |