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 | 9 |
9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
14 #include "base/prefs/pref_member.h" | 15 #include "base/prefs/pref_member.h" |
15 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
16 #include "base/test/histogram_tester.h" | 17 #include "base/test/histogram_tester.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, nullptr, -2, -2, -2, | 89 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, nullptr, -2, -2, -2, |
89 true, false, true, true, false); | 90 true, false, true, true, false); |
90 } else { | 91 } else { |
91 request->SetUserData( | 92 request->SetUserData( |
92 data_use_measurement::DataUseUserData::kUserDataKey, | 93 data_use_measurement::DataUseUserData::kUserDataKey, |
93 new data_use_measurement::DataUseUserData( | 94 new data_use_measurement::DataUseUserData( |
94 data_use_measurement::DataUseUserData::SUGGESTIONS)); | 95 data_use_measurement::DataUseUserData::SUGGESTIONS)); |
95 } | 96 } |
96 request->Start(); | 97 request->Start(); |
97 base::RunLoop().RunUntilIdle(); | 98 base::RunLoop().RunUntilIdle(); |
98 return request.Pass(); | 99 return request; |
99 } | 100 } |
100 | 101 |
101 // A fake DataUseAggregator for testing that only counts how many times its | 102 // A fake DataUseAggregator for testing that only counts how many times its |
102 // respective methods have been called. | 103 // respective methods have been called. |
103 class FakeDataUseAggregator : public data_usage::DataUseAggregator { | 104 class FakeDataUseAggregator : public data_usage::DataUseAggregator { |
104 public: | 105 public: |
105 FakeDataUseAggregator() | 106 FakeDataUseAggregator() |
106 : data_usage::DataUseAggregator( | 107 : data_usage::DataUseAggregator( |
107 scoped_ptr<data_usage::DataUseAnnotator>(), | 108 scoped_ptr<data_usage::DataUseAnnotator>(), |
108 scoped_ptr<data_usage::DataUseAmortizer>()), | 109 scoped_ptr<data_usage::DataUseAmortizer>()), |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 profile_.GetTestingPrefService()); | 351 profile_.GetTestingPrefService()); |
351 } | 352 } |
352 | 353 |
353 protected: | 354 protected: |
354 scoped_ptr<net::NetworkDelegate> CreateNetworkDelegate() { | 355 scoped_ptr<net::NetworkDelegate> CreateNetworkDelegate() { |
355 scoped_ptr<ChromeNetworkDelegate> network_delegate( | 356 scoped_ptr<ChromeNetworkDelegate> network_delegate( |
356 new ChromeNetworkDelegate(forwarder(), &enable_referrers_)); | 357 new ChromeNetworkDelegate(forwarder(), &enable_referrers_)); |
357 network_delegate->set_force_google_safe_search(&force_google_safe_search_); | 358 network_delegate->set_force_google_safe_search(&force_google_safe_search_); |
358 network_delegate->set_force_youtube_safety_mode( | 359 network_delegate->set_force_youtube_safety_mode( |
359 &force_youtube_safety_mode_); | 360 &force_youtube_safety_mode_); |
360 return network_delegate.Pass(); | 361 return std::move(network_delegate); |
361 } | 362 } |
362 | 363 |
363 void SetSafeSearch(bool google_safe_search, | 364 void SetSafeSearch(bool google_safe_search, |
364 bool youtube_safety_mode) { | 365 bool youtube_safety_mode) { |
365 force_google_safe_search_.SetValue(google_safe_search); | 366 force_google_safe_search_.SetValue(google_safe_search); |
366 force_youtube_safety_mode_.SetValue(youtube_safety_mode); | 367 force_youtube_safety_mode_.SetValue(youtube_safety_mode); |
367 } | 368 } |
368 | 369 |
369 void SetDelegate(net::NetworkDelegate* delegate) { | 370 void SetDelegate(net::NetworkDelegate* delegate) { |
370 network_delegate_ = delegate; | 371 network_delegate_ = delegate; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 447 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
447 &enable_referrers_, NULL, NULL, NULL, | 448 &enable_referrers_, NULL, NULL, NULL, |
448 profile_.GetTestingPrefService()); | 449 profile_.GetTestingPrefService()); |
449 } | 450 } |
450 | 451 |
451 protected: | 452 protected: |
452 scoped_ptr<ChromeNetworkDelegate> CreateNetworkDelegate() { | 453 scoped_ptr<ChromeNetworkDelegate> CreateNetworkDelegate() { |
453 scoped_ptr<ChromeNetworkDelegate> network_delegate( | 454 scoped_ptr<ChromeNetworkDelegate> network_delegate( |
454 new ChromeNetworkDelegate(forwarder(), &enable_referrers_)); | 455 new ChromeNetworkDelegate(forwarder(), &enable_referrers_)); |
455 network_delegate->set_cookie_settings(cookie_settings_); | 456 network_delegate->set_cookie_settings(cookie_settings_); |
456 return network_delegate.Pass(); | 457 return network_delegate; |
457 } | 458 } |
458 | 459 |
459 void SetDelegate(net::NetworkDelegate* delegate) { | 460 void SetDelegate(net::NetworkDelegate* delegate) { |
460 network_delegate_ = delegate; | 461 network_delegate_ = delegate; |
461 context_.set_network_delegate(network_delegate_); | 462 context_.set_network_delegate(network_delegate_); |
462 } | 463 } |
463 | 464 |
464 protected: | 465 protected: |
465 extensions::EventRouterForwarder* forwarder() { | 466 extensions::EventRouterForwarder* forwarder() { |
466 #if defined(ENABLE_EXTENSIONS) | 467 #if defined(ENABLE_EXTENSIONS) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 kBlockedFirstPartySite)); | 537 kBlockedFirstPartySite)); |
537 | 538 |
538 cookie_settings_->SetCookieSetting( | 539 cookie_settings_->SetCookieSetting( |
539 ContentSettingsPattern::FromURL(kBlockedFirstPartySite), | 540 ContentSettingsPattern::FromURL(kBlockedFirstPartySite), |
540 ContentSettingsPattern::Wildcard(), | 541 ContentSettingsPattern::Wildcard(), |
541 CONTENT_SETTING_BLOCK); | 542 CONTENT_SETTING_BLOCK); |
542 // Privacy mode is disabled as kAllowedSite is still getting cookies | 543 // Privacy mode is disabled as kAllowedSite is still getting cookies |
543 EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite, | 544 EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite, |
544 kBlockedFirstPartySite)); | 545 kBlockedFirstPartySite)); |
545 } | 546 } |
OLD | NEW |