| 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/download/download_request_limiter.h" | 5 #include "chrome/browser/download/download_request_limiter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 profile_->GetPrefs(), false /* incognito_profile */, | 154 profile_->GetPrefs(), false /* incognito_profile */, |
| 155 false /* guest_profile */); | 155 false /* guest_profile */); |
| 156 DownloadRequestLimiter::SetContentSettingsForTesting( | 156 DownloadRequestLimiter::SetContentSettingsForTesting( |
| 157 content_settings_.get()); | 157 content_settings_.get()); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void TearDown() override { | 160 void TearDown() override { |
| 161 content_settings_->ShutdownOnUIThread(); | 161 content_settings_->ShutdownOnUIThread(); |
| 162 content_settings_ = nullptr; | 162 content_settings_ = nullptr; |
| 163 testing_delegate_.TearDown(); | 163 testing_delegate_.TearDown(); |
| 164 |
| 165 // |profile_| must be teared down before |
| 166 // |RenderViewHostTestHarness::thread_bundle_|. |
| 167 profile_.reset(); |
| 168 |
| 164 ChromeRenderViewHostTestHarness::TearDown(); | 169 ChromeRenderViewHostTestHarness::TearDown(); |
| 165 } | 170 } |
| 166 | 171 |
| 167 void CanDownload() { | 172 void CanDownload() { |
| 168 CanDownloadFor(web_contents()); | 173 CanDownloadFor(web_contents()); |
| 169 } | 174 } |
| 170 | 175 |
| 171 void CanDownloadFor(WebContents* web_contents) { | 176 void CanDownloadFor(WebContents* web_contents) { |
| 172 download_request_limiter_->CanDownloadImpl( | 177 download_request_limiter_->CanDownloadImpl( |
| 173 web_contents, | 178 web_contents, |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 // changing the content setting). | 714 // changing the content setting). |
| 710 UpdateContentSettings(web_contents(), CONTENT_SETTING_ASK); | 715 UpdateContentSettings(web_contents(), CONTENT_SETTING_ASK); |
| 711 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, | 716 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
| 712 download_request_limiter_->GetDownloadStatus(web_contents())); | 717 download_request_limiter_->GetDownloadStatus(web_contents())); |
| 713 UpdateExpectations(WAIT); | 718 UpdateExpectations(WAIT); |
| 714 CanDownload(); | 719 CanDownload(); |
| 715 ExpectAndResetCounts(0, 0, 1, __LINE__); | 720 ExpectAndResetCounts(0, 0, 1, __LINE__); |
| 716 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, | 721 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
| 717 download_request_limiter_->GetDownloadStatus(web_contents())); | 722 download_request_limiter_->GetDownloadStatus(web_contents())); |
| 718 } | 723 } |
| OLD | NEW |