| 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/message_loop.h" | 5 #include "base/message_loop/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/chrome_content_settings_client.h" |
| 9 #include "chrome/common/content_settings.h" | 10 #include "chrome/common/content_settings.h" |
| 10 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
| 11 #include "components/content_settings/core/common/content_settings_types.h" | 12 #include "components/content_settings/core/common/content_settings_types.h" |
| 12 #include "content/public/test/test_browser_thread.h" | 13 #include "content/public/test/test_browser_thread.h" |
| 13 #include "extensions/common/extension.h" | 14 #include "extensions/common/extension.h" |
| 14 #include "extensions/common/extension_set.h" | 15 #include "extensions/common/extension_set.h" |
| 15 #include "extensions/common/manifest.h" | 16 #include "extensions/common/manifest.h" |
| 16 #include "extensions/common/manifest_constants.h" | 17 #include "extensions/common/manifest_constants.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); | 325 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); |
| 325 | 326 |
| 326 // The default setting can be session-only. | 327 // The default setting can be session-only. |
| 327 cookie_settings->SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY); | 328 cookie_settings->SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY); |
| 328 EXPECT_TRUE(policy_->HasSessionOnlyOrigins()); | 329 EXPECT_TRUE(policy_->HasSessionOnlyOrigins()); |
| 329 | 330 |
| 330 cookie_settings->SetDefaultCookieSetting(CONTENT_SETTING_ALLOW); | 331 cookie_settings->SetDefaultCookieSetting(CONTENT_SETTING_ALLOW); |
| 331 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); | 332 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); |
| 332 | 333 |
| 333 // Or the session-onlyness can affect individual origins. | 334 // Or the session-onlyness can affect individual origins. |
| 335 content_settings::ChromeContentSettingsClient client; |
| 334 ContentSettingsPattern pattern = | 336 ContentSettingsPattern pattern = |
| 335 ContentSettingsPattern::FromString("pattern.com"); | 337 ContentSettingsPattern::FromString(&client, "pattern.com"); |
| 336 | 338 |
| 337 cookie_settings->SetCookieSetting(pattern, | 339 cookie_settings->SetCookieSetting(pattern, |
| 338 ContentSettingsPattern::Wildcard(), | 340 ContentSettingsPattern::Wildcard(), |
| 339 CONTENT_SETTING_SESSION_ONLY); | 341 CONTENT_SETTING_SESSION_ONLY); |
| 340 | 342 |
| 341 EXPECT_TRUE(policy_->HasSessionOnlyOrigins()); | 343 EXPECT_TRUE(policy_->HasSessionOnlyOrigins()); |
| 342 | 344 |
| 343 // Clearing an origin-specific rule. | 345 // Clearing an origin-specific rule. |
| 344 cookie_settings->ResetCookieSetting(pattern, | 346 cookie_settings->ResetCookieSetting(pattern, |
| 345 ContentSettingsPattern::Wildcard()); | 347 ContentSettingsPattern::Wildcard()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 EXPECT_TRUE(observer.IsCompleted()); | 400 EXPECT_TRUE(observer.IsCompleted()); |
| 399 } | 401 } |
| 400 | 402 |
| 401 observer.ExpectClear(); | 403 observer.ExpectClear(); |
| 402 policy_->RevokeRightsForAllExtensions(); | 404 policy_->RevokeRightsForAllExtensions(); |
| 403 message_loop.RunUntilIdle(); | 405 message_loop.RunUntilIdle(); |
| 404 EXPECT_TRUE(observer.IsCompleted()); | 406 EXPECT_TRUE(observer.IsCompleted()); |
| 405 | 407 |
| 406 policy_->RemoveObserver(&observer); | 408 policy_->RemoveObserver(&observer); |
| 407 } | 409 } |
| OLD | NEW |