| 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/prefs/pref_service.h" | 5 #include "chrome/browser/prefs/pref_service.h" |
| 6 #include "chrome/browser/profiles/profile.h" | 6 #include "chrome/browser/profiles/profile.h" |
| 7 #include "chrome/browser/safe_browsing/malware_details.h" | 7 #include "chrome/browser/safe_browsing/malware_details.h" |
| 8 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 8 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
| 9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
| 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 public: | 75 public: |
| 76 // The decision the user made. | 76 // The decision the user made. |
| 77 enum UserResponse { | 77 enum UserResponse { |
| 78 PENDING, | 78 PENDING, |
| 79 OK, | 79 OK, |
| 80 CANCEL | 80 CANCEL |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 SafeBrowsingBlockingPageTest() | 83 SafeBrowsingBlockingPageTest() |
| 84 : ui_thread_(BrowserThread::UI, MessageLoop::current()), | 84 : ui_thread_(BrowserThread::UI, MessageLoop::current()), |
| 85 file_user_blocking_thread_( |
| 86 BrowserThread::FILE_USER_BLOCKING, MessageLoop::current()), |
| 85 io_thread_(BrowserThread::IO, MessageLoop::current()) { | 87 io_thread_(BrowserThread::IO, MessageLoop::current()) { |
| 86 ResetUserResponse(); | 88 ResetUserResponse(); |
| 87 service_ = new TestSafeBrowsingService(); | 89 service_ = new TestSafeBrowsingService(); |
| 88 } | 90 } |
| 89 | 91 |
| 90 virtual void SetUp() { | 92 virtual void SetUp() { |
| 91 ChromeRenderViewHostTestHarness::SetUp(); | 93 ChromeRenderViewHostTestHarness::SetUp(); |
| 92 SafeBrowsingBlockingPage::RegisterFactory(&factory_); | 94 SafeBrowsingBlockingPage::RegisterFactory(&factory_); |
| 93 MalwareDetails::RegisterFactory(NULL); // Create it fresh each time. | 95 MalwareDetails::RegisterFactory(NULL); // Create it fresh each time. |
| 94 ResetUserResponse(); | 96 ResetUserResponse(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 resource->is_subresource = is_subresource; | 184 resource->is_subresource = is_subresource; |
| 183 resource->threat_type = SafeBrowsingService::URL_MALWARE; | 185 resource->threat_type = SafeBrowsingService::URL_MALWARE; |
| 184 resource->render_process_host_id = contents()->GetRenderProcessHost()-> | 186 resource->render_process_host_id = contents()->GetRenderProcessHost()-> |
| 185 GetID(); | 187 GetID(); |
| 186 resource->render_view_id = contents()->GetRenderViewHost()->routing_id(); | 188 resource->render_view_id = contents()->GetRenderViewHost()->routing_id(); |
| 187 } | 189 } |
| 188 | 190 |
| 189 UserResponse user_response_; | 191 UserResponse user_response_; |
| 190 TestSafeBrowsingBlockingPageFactory factory_; | 192 TestSafeBrowsingBlockingPageFactory factory_; |
| 191 content::TestBrowserThread ui_thread_; | 193 content::TestBrowserThread ui_thread_; |
| 194 content::TestBrowserThread file_user_blocking_thread_; |
| 192 content::TestBrowserThread io_thread_; | 195 content::TestBrowserThread io_thread_; |
| 193 }; | 196 }; |
| 194 | 197 |
| 195 // Tests showing a blocking page for a malware page and not proceeding. | 198 // Tests showing a blocking page for a malware page and not proceeding. |
| 196 TEST_F(SafeBrowsingBlockingPageTest, MalwarePageDontProceed) { | 199 TEST_F(SafeBrowsingBlockingPageTest, MalwarePageDontProceed) { |
| 197 // Enable malware details. | 200 // Enable malware details. |
| 198 Profile* profile = Profile::FromBrowserContext( | 201 Profile* profile = Profile::FromBrowserContext( |
| 199 contents()->GetBrowserContext()); | 202 contents()->GetBrowserContext()); |
| 200 profile->GetPrefs()->SetBoolean(prefs::kSafeBrowsingReportingEnabled, true); | 203 profile->GetPrefs()->SetBoolean(prefs::kSafeBrowsingReportingEnabled, true); |
| 201 | 204 |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 | 619 |
| 617 EXPECT_TRUE(profile->GetPrefs()->GetBoolean( | 620 EXPECT_TRUE(profile->GetPrefs()->GetBoolean( |
| 618 prefs::kSafeBrowsingReportingEnabled)); | 621 prefs::kSafeBrowsingReportingEnabled)); |
| 619 | 622 |
| 620 // Simulate the user uncheck the report agreement checkbox. | 623 // Simulate the user uncheck the report agreement checkbox. |
| 621 sb_interstitial->SetReportingPreference(false); | 624 sb_interstitial->SetReportingPreference(false); |
| 622 | 625 |
| 623 EXPECT_FALSE(profile->GetPrefs()->GetBoolean( | 626 EXPECT_FALSE(profile->GetPrefs()->GetBoolean( |
| 624 prefs::kSafeBrowsingReportingEnabled)); | 627 prefs::kSafeBrowsingReportingEnabled)); |
| 625 } | 628 } |
| OLD | NEW |