| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 10 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); | 324 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); |
| 325 | 325 |
| 326 // The default setting can be session-only. | 326 // The default setting can be session-only. |
| 327 cookie_settings->SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY); | 327 cookie_settings->SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY); |
| 328 EXPECT_TRUE(policy_->HasSessionOnlyOrigins()); | 328 EXPECT_TRUE(policy_->HasSessionOnlyOrigins()); |
| 329 | 329 |
| 330 cookie_settings->SetDefaultCookieSetting(CONTENT_SETTING_ALLOW); | 330 cookie_settings->SetDefaultCookieSetting(CONTENT_SETTING_ALLOW); |
| 331 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); | 331 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); |
| 332 | 332 |
| 333 // Or the session-onlyness can affect individual origins. | 333 // Or the session-onlyness can affect individual origins. |
| 334 ContentSettingsPattern pattern = | 334 GURL url("http://pattern.com"); |
| 335 ContentSettingsPattern::FromString("pattern.com"); | 335 cookie_settings->SetCookieSetting(url, CONTENT_SETTING_SESSION_ONLY); |
| 336 | |
| 337 cookie_settings->SetCookieSetting(pattern, | |
| 338 ContentSettingsPattern::Wildcard(), | |
| 339 CONTENT_SETTING_SESSION_ONLY); | |
| 340 | 336 |
| 341 EXPECT_TRUE(policy_->HasSessionOnlyOrigins()); | 337 EXPECT_TRUE(policy_->HasSessionOnlyOrigins()); |
| 342 | 338 |
| 343 // Clearing an origin-specific rule. | 339 // Clearing an origin-specific rule. |
| 344 cookie_settings->ResetCookieSetting(GURL("http://pattern.com")); | 340 cookie_settings->ResetCookieSetting(url); |
| 345 | 341 |
| 346 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); | 342 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); |
| 347 } | 343 } |
| 348 | 344 |
| 349 TEST_F(ExtensionSpecialStoragePolicyTest, IsStorageDurableTest) { | 345 TEST_F(ExtensionSpecialStoragePolicyTest, IsStorageDurableTest) { |
| 350 TestingProfile profile; | 346 TestingProfile profile; |
| 351 content_settings::CookieSettings* cookie_settings = | 347 content_settings::CookieSettings* cookie_settings = |
| 352 CookieSettingsFactory::GetForProfile(&profile).get(); | 348 CookieSettingsFactory::GetForProfile(&profile).get(); |
| 353 policy_ = new ExtensionSpecialStoragePolicy(cookie_settings); | 349 policy_ = new ExtensionSpecialStoragePolicy(cookie_settings); |
| 354 const GURL kHttpUrl("http://foo.com"); | 350 const GURL kHttpUrl("http://foo.com"); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 EXPECT_TRUE(observer.IsCompleted()); | 407 EXPECT_TRUE(observer.IsCompleted()); |
| 412 } | 408 } |
| 413 | 409 |
| 414 observer.ExpectClear(); | 410 observer.ExpectClear(); |
| 415 policy_->RevokeRightsForAllExtensions(); | 411 policy_->RevokeRightsForAllExtensions(); |
| 416 base::MessageLoop::current()->RunUntilIdle(); | 412 base::MessageLoop::current()->RunUntilIdle(); |
| 417 EXPECT_TRUE(observer.IsCompleted()); | 413 EXPECT_TRUE(observer.IsCompleted()); |
| 418 | 414 |
| 419 policy_->RemoveObserver(&observer); | 415 policy_->RemoveObserver(&observer); |
| 420 } | 416 } |
| OLD | NEW |