| 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 "chrome/browser/net/chrome_network_delegate.h" | 5 #include "chrome/browser/net/chrome_network_delegate.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/prefs/pref_member.h" | 10 #include "base/prefs/pref_member.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 class ChromeNetworkDelegateSafeSearchTest : public testing::Test { | 92 class ChromeNetworkDelegateSafeSearchTest : public testing::Test { |
| 93 public: | 93 public: |
| 94 ChromeNetworkDelegateSafeSearchTest() | 94 ChromeNetworkDelegateSafeSearchTest() |
| 95 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 95 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
| 96 forwarder_(new extensions::EventRouterForwarder()) { | 96 forwarder_(new extensions::EventRouterForwarder()) { |
| 97 } | 97 } |
| 98 | 98 |
| 99 virtual void SetUp() OVERRIDE { | 99 virtual void SetUp() OVERRIDE { |
| 100 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 100 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
| 101 &enable_referrers_, NULL, &force_google_safe_search_, | 101 &enable_referrers_, NULL, &force_google_safe_search_, NULL, |
| 102 profile_.GetTestingPrefService()); | 102 profile_.GetTestingPrefService()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 protected: | 105 protected: |
| 106 scoped_ptr<net::NetworkDelegate> CreateNetworkDelegate() { | 106 scoped_ptr<net::NetworkDelegate> CreateNetworkDelegate() { |
| 107 scoped_ptr<ChromeNetworkDelegate> network_delegate( | 107 scoped_ptr<ChromeNetworkDelegate> network_delegate( |
| 108 new ChromeNetworkDelegate(forwarder_.get(), &enable_referrers_)); | 108 new ChromeNetworkDelegate(forwarder_.get(), &enable_referrers_)); |
| 109 network_delegate->set_force_google_safe_search(&force_google_safe_search_); | 109 network_delegate->set_force_google_safe_search(&force_google_safe_search_); |
| 110 return network_delegate.PassAs<net::NetworkDelegate>(); | 110 return network_delegate.PassAs<net::NetworkDelegate>(); |
| 111 } | 111 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 forwarder_(new extensions::EventRouterForwarder()), | 288 forwarder_(new extensions::EventRouterForwarder()), |
| 289 cookie_settings_(CookieSettings::Factory::GetForProfile(&profile_) | 289 cookie_settings_(CookieSettings::Factory::GetForProfile(&profile_) |
| 290 .get()), | 290 .get()), |
| 291 kBlockedSite("http://ads.thirdparty.com"), | 291 kBlockedSite("http://ads.thirdparty.com"), |
| 292 kAllowedSite("http://good.allays.com"), | 292 kAllowedSite("http://good.allays.com"), |
| 293 kFirstPartySite("http://cool.things.com"), | 293 kFirstPartySite("http://cool.things.com"), |
| 294 kBlockedFirstPartySite("http://no.thirdparties.com") {} | 294 kBlockedFirstPartySite("http://no.thirdparties.com") {} |
| 295 | 295 |
| 296 virtual void SetUp() OVERRIDE { | 296 virtual void SetUp() OVERRIDE { |
| 297 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 297 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
| 298 &enable_referrers_, NULL, NULL, | 298 &enable_referrers_, NULL, NULL, NULL, |
| 299 profile_.GetTestingPrefService()); | 299 profile_.GetTestingPrefService()); |
| 300 } | 300 } |
| 301 | 301 |
| 302 protected: | 302 protected: |
| 303 scoped_ptr<ChromeNetworkDelegate> CreateNetworkDelegate() { | 303 scoped_ptr<ChromeNetworkDelegate> CreateNetworkDelegate() { |
| 304 scoped_ptr<ChromeNetworkDelegate> network_delegate( | 304 scoped_ptr<ChromeNetworkDelegate> network_delegate( |
| 305 new ChromeNetworkDelegate(forwarder_.get(), &enable_referrers_)); | 305 new ChromeNetworkDelegate(forwarder_.get(), &enable_referrers_)); |
| 306 network_delegate->set_cookie_settings(cookie_settings_); | 306 network_delegate->set_cookie_settings(cookie_settings_); |
| 307 return network_delegate.Pass(); | 307 return network_delegate.Pass(); |
| 308 } | 308 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 | 378 |
| 379 cookie_settings_->SetCookieSetting( | 379 cookie_settings_->SetCookieSetting( |
| 380 ContentSettingsPattern::FromURL(kBlockedFirstPartySite), | 380 ContentSettingsPattern::FromURL(kBlockedFirstPartySite), |
| 381 ContentSettingsPattern::Wildcard(), | 381 ContentSettingsPattern::Wildcard(), |
| 382 CONTENT_SETTING_BLOCK); | 382 CONTENT_SETTING_BLOCK); |
| 383 // Privacy mode is disabled as kAllowedSite is still getting cookies | 383 // Privacy mode is disabled as kAllowedSite is still getting cookies |
| 384 EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite, | 384 EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite, |
| 385 kBlockedFirstPartySite)); | 385 kBlockedFirstPartySite)); |
| 386 } | 386 } |
| 387 | 387 |
| OLD | NEW |