Index: chrome/browser/download/download_request_limiter_unittest.cc |
diff --git a/chrome/browser/download/download_request_limiter_unittest.cc b/chrome/browser/download/download_request_limiter_unittest.cc |
index 14d15026609ad3aeacccf0acd276e31848ee1a05..6353ced7c886202925c0e1477836a0825f285a6a 100644 |
--- a/chrome/browser/download/download_request_limiter_unittest.cc |
+++ b/chrome/browser/download/download_request_limiter_unittest.cc |
@@ -11,7 +11,6 @@ |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/test/base/chrome_render_view_host_test_harness.h" |
-#include "chrome/test/base/testing_profile.h" |
#include "components/content_settings/core/browser/host_content_settings_map.h" |
#include "content/public/browser/navigation_controller.h" |
#include "content/public/browser/navigation_details.h" |
@@ -143,29 +142,16 @@ class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness { |
public: |
void SetUp() override { |
ChromeRenderViewHostTestHarness::SetUp(); |
- profile_.reset(new TestingProfile()); |
testing_delegate_.SetUp(web_contents()); |
UpdateExpectations(ACCEPT); |
cancel_count_ = continue_count_ = 0; |
download_request_limiter_ = new DownloadRequestLimiter(); |
- |
- content_settings_ = new HostContentSettingsMap( |
- profile_->GetPrefs(), false /* incognito_profile */, |
- false /* guest_profile */); |
- DownloadRequestLimiter::SetContentSettingsForTesting( |
- content_settings_.get()); |
} |
void TearDown() override { |
alshabalin
2017/03/01 12:18:23
DownloadRequestLimiter::TabDownloadState now depen
|
- content_settings_->ShutdownOnUIThread(); |
- content_settings_ = nullptr; |
testing_delegate_.TearDown(); |
- // |profile_| must be teared down before |
- // |RenderViewHostTestHarness::thread_bundle_|. |
- profile_.reset(); |
- |
ChromeRenderViewHostTestHarness::TearDown(); |
} |
@@ -212,13 +198,6 @@ class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness { |
// Ensure a download state exists. |
download_request_limiter_->GetDownloadState(web_contents, nullptr, true); |
SetHostContentSetting(web_contents, setting); |
- |
- // Manually send the update notification. In the browser, this is sent from |
- // ContentSettingRPHBubbleModel. |
- content::NotificationService::current()->Notify( |
- chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
- content::Source<WebContents>(web_contents), |
- content::NotificationService::NoDetails()); |
} |
protected: |
@@ -231,9 +210,10 @@ class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness { |
} |
void SetHostContentSetting(WebContents* contents, ContentSetting setting) { |
- content_settings_->SetContentSettingDefaultScope( |
- contents->GetURL(), GURL(), CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, |
- std::string(), setting); |
+ DownloadRequestLimiter::GetContentSettings(contents) |
dominickn
2017/03/02 03:32:52
Instead of exposing GetContentSettings, can you no
alshabalin
2017/03/02 09:54:01
Done. DownloadRequestLimiter::GetContentSettings i
|
+ ->SetContentSettingDefaultScope( |
+ contents->GetURL(), GURL(), |
+ CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, std::string(), setting); |
} |
void LoadCompleted() { testing_delegate_.LoadCompleted(web_contents()); } |
@@ -252,11 +232,7 @@ class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness { |
// Number of times CancelDownload was invoked. |
int cancel_count_; |
- scoped_refptr<HostContentSettingsMap> content_settings_; |
TestingDelegate testing_delegate_; |
- |
- private: |
- std::unique_ptr<TestingProfile> profile_; |
}; |
TEST_F(DownloadRequestLimiterTest, DownloadRequestLimiter_Allow) { |
@@ -650,19 +626,19 @@ TEST_F(DownloadRequestLimiterTest, |
CanDownload(); |
ExpectAndResetCounts(1, 0, 0, __LINE__); |
- ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
+ ASSERT_EQ(DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS, |
download_request_limiter_->GetDownloadStatus(web_contents())); |
SetHostContentSetting(web_contents(), CONTENT_SETTING_BLOCK); |
CanDownload(); |
ExpectAndResetCounts(0, 1, 0, __LINE__); |
- ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
+ ASSERT_EQ(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED, |
download_request_limiter_->GetDownloadStatus(web_contents())); |
CanDownload(); |
ExpectAndResetCounts(0, 1, 0, __LINE__); |
- ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
+ ASSERT_EQ(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED, |
download_request_limiter_->GetDownloadStatus(web_contents())); |
} |