| 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 <list> | 5 #include <list> |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/safe_browsing/malware_details.h" | 10 #include "chrome/browser/safe_browsing/malware_details.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 return NULL; | 158 return NULL; |
| 159 return static_cast<SafeBrowsingBlockingPage*>( | 159 return static_cast<SafeBrowsingBlockingPage*>( |
| 160 interstitial->GetDelegateForTesting()); | 160 interstitial->GetDelegateForTesting()); |
| 161 } | 161 } |
| 162 | 162 |
| 163 UserResponse user_response() const { return user_response_; } | 163 UserResponse user_response() const { return user_response_; } |
| 164 void ResetUserResponse() { user_response_ = PENDING; } | 164 void ResetUserResponse() { user_response_ = PENDING; } |
| 165 | 165 |
| 166 static void ProceedThroughInterstitial( | 166 static void ProceedThroughInterstitial( |
| 167 SafeBrowsingBlockingPage* sb_interstitial) { | 167 SafeBrowsingBlockingPage* sb_interstitial) { |
| 168 sb_interstitial->interstitial_page_->Proceed(); | 168 sb_interstitial->interstitial_page()->Proceed(); |
| 169 // Proceed() posts a task to update the SafeBrowsingService::Client. | 169 // Proceed() posts a task to update the SafeBrowsingService::Client. |
| 170 base::RunLoop().RunUntilIdle(); | 170 base::RunLoop().RunUntilIdle(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 static void DontProceedThroughInterstitial( | 173 static void DontProceedThroughInterstitial( |
| 174 SafeBrowsingBlockingPage* sb_interstitial) { | 174 SafeBrowsingBlockingPage* sb_interstitial) { |
| 175 sb_interstitial->interstitial_page_->DontProceed(); | 175 sb_interstitial->interstitial_page()->DontProceed(); |
| 176 // DontProceed() posts a task to update the SafeBrowsingService::Client. | 176 // DontProceed() posts a task to update the SafeBrowsingService::Client. |
| 177 base::RunLoop().RunUntilIdle(); | 177 base::RunLoop().RunUntilIdle(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void DontProceedThroughSubresourceInterstitial( | 180 void DontProceedThroughSubresourceInterstitial( |
| 181 SafeBrowsingBlockingPage* sb_interstitial) { | 181 SafeBrowsingBlockingPage* sb_interstitial) { |
| 182 // CommandReceived(kTakeMeBackCommand) does a back navigation for | 182 // CommandReceived(kTakeMeBackCommand) does a back navigation for |
| 183 // subresource interstitials. | 183 // subresource interstitials. |
| 184 GoBack(false); | 184 GoBack(false); |
| 185 // DontProceed() posts a task to update the SafeBrowsingService::Client. | 185 // DontProceed() posts a task to update the SafeBrowsingService::Client. |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 // Simulate the load causing a safe browsing interstitial to be shown. | 571 // Simulate the load causing a safe browsing interstitial to be shown. |
| 572 ShowInterstitial(false, kBadURL); | 572 ShowInterstitial(false, kBadURL); |
| 573 SafeBrowsingBlockingPage* sb_interstitial = | 573 SafeBrowsingBlockingPage* sb_interstitial = |
| 574 GetSafeBrowsingBlockingPage(); | 574 GetSafeBrowsingBlockingPage(); |
| 575 ASSERT_TRUE(sb_interstitial); | 575 ASSERT_TRUE(sb_interstitial); |
| 576 | 576 |
| 577 base::RunLoop().RunUntilIdle(); | 577 base::RunLoop().RunUntilIdle(); |
| 578 | 578 |
| 579 // Simulate the user clicking "proceed" then "don't proceed" (before the | 579 // Simulate the user clicking "proceed" then "don't proceed" (before the |
| 580 // interstitial is shown). | 580 // interstitial is shown). |
| 581 sb_interstitial->interstitial_page_->Proceed(); | 581 sb_interstitial->interstitial_page()->Proceed(); |
| 582 sb_interstitial->interstitial_page_->DontProceed(); | 582 sb_interstitial->interstitial_page()->DontProceed(); |
| 583 // Proceed() and DontProceed() post a task to update the | 583 // Proceed() and DontProceed() post a task to update the |
| 584 // SafeBrowsingService::Client. | 584 // SafeBrowsingService::Client. |
| 585 base::RunLoop().RunUntilIdle(); | 585 base::RunLoop().RunUntilIdle(); |
| 586 | 586 |
| 587 // The interstitial should be gone. | 587 // The interstitial should be gone. |
| 588 EXPECT_EQ(OK, user_response()); | 588 EXPECT_EQ(OK, user_response()); |
| 589 EXPECT_FALSE(GetSafeBrowsingBlockingPage()); | 589 EXPECT_FALSE(GetSafeBrowsingBlockingPage()); |
| 590 | 590 |
| 591 // Only one report should have been sent. | 591 // Only one report should have been sent. |
| 592 EXPECT_EQ(1u, ui_manager_->GetDetails()->size()); | 592 EXPECT_EQ(1u, ui_manager_->GetDetails()->size()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 | 656 |
| 657 EXPECT_TRUE(profile->GetPrefs()->GetBoolean( | 657 EXPECT_TRUE(profile->GetPrefs()->GetBoolean( |
| 658 prefs::kSafeBrowsingExtendedReportingEnabled)); | 658 prefs::kSafeBrowsingExtendedReportingEnabled)); |
| 659 | 659 |
| 660 // Simulate the user uncheck the report agreement checkbox. | 660 // Simulate the user uncheck the report agreement checkbox. |
| 661 sb_interstitial->SetReportingPreference(false); | 661 sb_interstitial->SetReportingPreference(false); |
| 662 | 662 |
| 663 EXPECT_FALSE(profile->GetPrefs()->GetBoolean( | 663 EXPECT_FALSE(profile->GetPrefs()->GetBoolean( |
| 664 prefs::kSafeBrowsingExtendedReportingEnabled)); | 664 prefs::kSafeBrowsingExtendedReportingEnabled)); |
| 665 } | 665 } |
| OLD | NEW |