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