| 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 ExpectProtectedBy(protecting_extensions, GURL("http://foo.wildcards/")); | 296 ExpectProtectedBy(protecting_extensions, GURL("http://foo.wildcards/")); |
| 297 ExpectProtectedBy(protecting_extensions, GURL("https://bar.wildcards/")); | 297 ExpectProtectedBy(protecting_extensions, GURL("https://bar.wildcards/")); |
| 298 | 298 |
| 299 policy_->RevokeRightsForExtension(protected_app); | 299 policy_->RevokeRightsForExtension(protected_app); |
| 300 ExpectProtectedBy(empty_set, GURL("http://explicit/")); | 300 ExpectProtectedBy(empty_set, GURL("http://explicit/")); |
| 301 ExpectProtectedBy(empty_set, GURL("http://foo.wildcards/")); | 301 ExpectProtectedBy(empty_set, GURL("http://foo.wildcards/")); |
| 302 ExpectProtectedBy(empty_set, GURL("https://bar.wildcards/")); | 302 ExpectProtectedBy(empty_set, GURL("https://bar.wildcards/")); |
| 303 } | 303 } |
| 304 | 304 |
| 305 TEST_F(ExtensionSpecialStoragePolicyTest, HasSessionOnlyOrigins) { | 305 TEST_F(ExtensionSpecialStoragePolicyTest, HasSessionOnlyOrigins) { |
| 306 MessageLoop message_loop; | 306 base::MessageLoop message_loop; |
| 307 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | 307 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
| 308 | 308 |
| 309 TestingProfile profile; | 309 TestingProfile profile; |
| 310 CookieSettings* cookie_settings = | 310 CookieSettings* cookie_settings = |
| 311 CookieSettings::Factory::GetForProfile(&profile); | 311 CookieSettings::Factory::GetForProfile(&profile); |
| 312 policy_ = new ExtensionSpecialStoragePolicy(cookie_settings); | 312 policy_ = new ExtensionSpecialStoragePolicy(cookie_settings); |
| 313 | 313 |
| 314 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); | 314 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); |
| 315 | 315 |
| 316 // The default setting can be session-only. | 316 // The default setting can be session-only. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 331 EXPECT_TRUE(policy_->HasSessionOnlyOrigins()); | 331 EXPECT_TRUE(policy_->HasSessionOnlyOrigins()); |
| 332 | 332 |
| 333 // Clearing an origin-specific rule. | 333 // Clearing an origin-specific rule. |
| 334 cookie_settings->ResetCookieSetting(pattern, | 334 cookie_settings->ResetCookieSetting(pattern, |
| 335 ContentSettingsPattern::Wildcard()); | 335 ContentSettingsPattern::Wildcard()); |
| 336 | 336 |
| 337 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); | 337 EXPECT_FALSE(policy_->HasSessionOnlyOrigins()); |
| 338 } | 338 } |
| 339 | 339 |
| 340 TEST_F(ExtensionSpecialStoragePolicyTest, NotificationTest) { | 340 TEST_F(ExtensionSpecialStoragePolicyTest, NotificationTest) { |
| 341 MessageLoop message_loop; | 341 base::MessageLoop message_loop; |
| 342 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | 342 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
| 343 content::TestBrowserThread io_thread(BrowserThread::IO, &message_loop); | 343 content::TestBrowserThread io_thread(BrowserThread::IO, &message_loop); |
| 344 | 344 |
| 345 PolicyChangeObserver observer; | 345 PolicyChangeObserver observer; |
| 346 policy_->AddObserver(&observer); | 346 policy_->AddObserver(&observer); |
| 347 | 347 |
| 348 scoped_refptr<Extension> apps[] = { | 348 scoped_refptr<Extension> apps[] = { |
| 349 CreateProtectedApp(), | 349 CreateProtectedApp(), |
| 350 CreateUnlimitedApp(), | 350 CreateUnlimitedApp(), |
| 351 }; | 351 }; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 EXPECT_TRUE(observer.IsCompleted()); | 388 EXPECT_TRUE(observer.IsCompleted()); |
| 389 } | 389 } |
| 390 | 390 |
| 391 observer.ExpectClear(); | 391 observer.ExpectClear(); |
| 392 policy_->RevokeRightsForAllExtensions(); | 392 policy_->RevokeRightsForAllExtensions(); |
| 393 message_loop.RunUntilIdle(); | 393 message_loop.RunUntilIdle(); |
| 394 EXPECT_TRUE(observer.IsCompleted()); | 394 EXPECT_TRUE(observer.IsCompleted()); |
| 395 | 395 |
| 396 policy_->RemoveObserver(&observer); | 396 policy_->RemoveObserver(&observer); |
| 397 } | 397 } |
| OLD | NEW |