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