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 <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 150 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
151 &enable_referrers_, nullptr, nullptr, nullptr, | 151 &enable_referrers_, nullptr, nullptr, nullptr, |
152 profile_.GetTestingPrefService()); | 152 profile_.GetTestingPrefService()); |
153 profile_manager_.reset( | 153 profile_manager_.reset( |
154 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 154 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
155 ASSERT_TRUE(profile_manager_->SetUp()); | 155 ASSERT_TRUE(profile_manager_->SetUp()); |
156 } | 156 } |
157 | 157 |
158 void Initialize() { | 158 void Initialize() { |
159 network_delegate_.reset( | 159 network_delegate_.reset( |
160 new ChromeNetworkDelegate(forwarder(), &enable_referrers_)); | 160 new ChromeNetworkDelegate(forwarder(), &enable_referrers_, |
| 161 metrics::UpdateUsagePrefCallbackType())); |
161 context_->set_client_socket_factory(&socket_factory_); | 162 context_->set_client_socket_factory(&socket_factory_); |
162 context_->set_network_delegate(network_delegate_.get()); | 163 context_->set_network_delegate(network_delegate_.get()); |
163 context_->Init(); | 164 context_->Init(); |
164 } | 165 } |
165 | 166 |
166 net::TestURLRequestContext* context() { return context_.get(); } | 167 net::TestURLRequestContext* context() { return context_.get(); } |
167 net::NetworkDelegate* network_delegate() { return network_delegate_.get(); } | 168 net::NetworkDelegate* network_delegate() { return network_delegate_.get(); } |
168 net::MockClientSocketFactory* socket_factory() { return &socket_factory_; } | 169 net::MockClientSocketFactory* socket_factory() { return &socket_factory_; } |
169 | 170 |
170 ChromeNetworkDelegate* chrome_network_delegate() { | 171 ChromeNetworkDelegate* chrome_network_delegate() { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 &enable_referrers_, | 342 &enable_referrers_, |
342 NULL, | 343 NULL, |
343 &force_google_safe_search_, | 344 &force_google_safe_search_, |
344 &force_youtube_safety_mode_, | 345 &force_youtube_safety_mode_, |
345 profile_.GetTestingPrefService()); | 346 profile_.GetTestingPrefService()); |
346 } | 347 } |
347 | 348 |
348 protected: | 349 protected: |
349 scoped_ptr<net::NetworkDelegate> CreateNetworkDelegate() { | 350 scoped_ptr<net::NetworkDelegate> CreateNetworkDelegate() { |
350 scoped_ptr<ChromeNetworkDelegate> network_delegate( | 351 scoped_ptr<ChromeNetworkDelegate> network_delegate( |
351 new ChromeNetworkDelegate(forwarder(), &enable_referrers_)); | 352 new ChromeNetworkDelegate(forwarder(), &enable_referrers_, |
| 353 metrics::UpdateUsagePrefCallbackType())); |
352 network_delegate->set_force_google_safe_search(&force_google_safe_search_); | 354 network_delegate->set_force_google_safe_search(&force_google_safe_search_); |
353 network_delegate->set_force_youtube_safety_mode( | 355 network_delegate->set_force_youtube_safety_mode( |
354 &force_youtube_safety_mode_); | 356 &force_youtube_safety_mode_); |
355 return std::move(network_delegate); | 357 return std::move(network_delegate); |
356 } | 358 } |
357 | 359 |
358 void SetSafeSearch(bool google_safe_search, | 360 void SetSafeSearch(bool google_safe_search, |
359 bool youtube_safety_mode) { | 361 bool youtube_safety_mode) { |
360 force_google_safe_search_.SetValue(google_safe_search); | 362 force_google_safe_search_.SetValue(google_safe_search); |
361 force_youtube_safety_mode_.SetValue(youtube_safety_mode); | 363 force_youtube_safety_mode_.SetValue(youtube_safety_mode); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 441 |
440 void SetUp() override { | 442 void SetUp() override { |
441 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 443 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
442 &enable_referrers_, NULL, NULL, NULL, | 444 &enable_referrers_, NULL, NULL, NULL, |
443 profile_.GetTestingPrefService()); | 445 profile_.GetTestingPrefService()); |
444 } | 446 } |
445 | 447 |
446 protected: | 448 protected: |
447 scoped_ptr<ChromeNetworkDelegate> CreateNetworkDelegate() { | 449 scoped_ptr<ChromeNetworkDelegate> CreateNetworkDelegate() { |
448 scoped_ptr<ChromeNetworkDelegate> network_delegate( | 450 scoped_ptr<ChromeNetworkDelegate> network_delegate( |
449 new ChromeNetworkDelegate(forwarder(), &enable_referrers_)); | 451 new ChromeNetworkDelegate(forwarder(), &enable_referrers_, |
| 452 metrics::UpdateUsagePrefCallbackType())); |
450 network_delegate->set_cookie_settings(cookie_settings_); | 453 network_delegate->set_cookie_settings(cookie_settings_); |
451 return network_delegate; | 454 return network_delegate; |
452 } | 455 } |
453 | 456 |
454 void SetDelegate(net::NetworkDelegate* delegate) { | 457 void SetDelegate(net::NetworkDelegate* delegate) { |
455 network_delegate_ = delegate; | 458 network_delegate_ = delegate; |
456 context_.set_network_delegate(network_delegate_); | 459 context_.set_network_delegate(network_delegate_); |
457 } | 460 } |
458 | 461 |
459 protected: | 462 protected: |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 | 529 |
527 EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite, | 530 EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite, |
528 kBlockedFirstPartySite)); | 531 kBlockedFirstPartySite)); |
529 | 532 |
530 cookie_settings_->SetCookieSetting(kBlockedFirstPartySite, | 533 cookie_settings_->SetCookieSetting(kBlockedFirstPartySite, |
531 CONTENT_SETTING_BLOCK); | 534 CONTENT_SETTING_BLOCK); |
532 // Privacy mode is disabled as kAllowedSite is still getting cookies | 535 // Privacy mode is disabled as kAllowedSite is still getting cookies |
533 EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite, | 536 EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite, |
534 kBlockedFirstPartySite)); | 537 kBlockedFirstPartySite)); |
535 } | 538 } |
OLD | NEW |