| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 5 |
| 6 #include "chrome/browser/prefs/pref_service.h" | 6 #include "chrome/browser/prefs/pref_service.h" |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/safe_browsing/malware_details.h" | 8 #include "chrome/browser/safe_browsing/malware_details.h" |
| 9 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 9 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 else | 98 else |
| 99 user_response_ = CANCEL; | 99 user_response_ = CANCEL; |
| 100 } | 100 } |
| 101 | 101 |
| 102 void Navigate(const char* url, int page_id) { | 102 void Navigate(const char* url, int page_id) { |
| 103 ViewHostMsg_FrameNavigate_Params params; | 103 ViewHostMsg_FrameNavigate_Params params; |
| 104 InitNavigateParams(¶ms, page_id, GURL(url), PageTransition::TYPED); | 104 InitNavigateParams(¶ms, page_id, GURL(url), PageTransition::TYPED); |
| 105 contents()->TestDidNavigate(contents_->render_view_host(), params); | 105 contents()->TestDidNavigate(contents_->render_view_host(), params); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void GoBack() { | 108 void GoBackCrossSite() { |
| 109 NavigationEntry* entry = contents()->controller().GetEntryAtOffset(-1); | 109 NavigationEntry* entry = contents()->controller().GetEntryAtOffset(-1); |
| 110 ASSERT_TRUE(entry); | 110 ASSERT_TRUE(entry); |
| 111 contents()->controller().GoBack(); | 111 contents()->controller().GoBack(); |
| 112 Navigate(entry->url().spec().c_str(), entry->page_id()); | 112 |
| 113 // The navigation should commit in the pending RVH. |
| 114 ViewHostMsg_FrameNavigate_Params params; |
| 115 InitNavigateParams(¶ms, entry->page_id(), GURL(entry->url()), |
| 116 PageTransition::TYPED); |
| 117 contents()->TestDidNavigate(contents_->pending_rvh(), params); |
| 113 } | 118 } |
| 114 | 119 |
| 115 void ShowInterstitial(ResourceType::Type resource_type, | 120 void ShowInterstitial(ResourceType::Type resource_type, |
| 116 const char* url) { | 121 const char* url) { |
| 117 SafeBrowsingService::UnsafeResource resource; | 122 SafeBrowsingService::UnsafeResource resource; |
| 118 InitResource(&resource, resource_type, GURL(url)); | 123 InitResource(&resource, resource_type, GURL(url)); |
| 119 SafeBrowsingBlockingPage::ShowBlockingPage(service_, resource); | 124 SafeBrowsingBlockingPage::ShowBlockingPage(service_, resource); |
| 120 } | 125 } |
| 121 | 126 |
| 122 // Returns the SafeBrowsingBlockingPage currently showing or NULL if none is | 127 // Returns the SafeBrowsingBlockingPage currently showing or NULL if none is |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 455 |
| 451 // Now navigate to a bad page triggerring an interstitial. | 456 // Now navigate to a bad page triggerring an interstitial. |
| 452 controller().LoadURL(GURL(kBadURL), GURL(), PageTransition::TYPED); | 457 controller().LoadURL(GURL(kBadURL), GURL(), PageTransition::TYPED); |
| 453 ShowInterstitial(ResourceType::MAIN_FRAME, kBadURL); | 458 ShowInterstitial(ResourceType::MAIN_FRAME, kBadURL); |
| 454 SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage(); | 459 SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage(); |
| 455 ASSERT_TRUE(sb_interstitial); | 460 ASSERT_TRUE(sb_interstitial); |
| 456 | 461 |
| 457 // Proceed, then navigate back. | 462 // Proceed, then navigate back. |
| 458 ProceedThroughInterstitial(sb_interstitial); | 463 ProceedThroughInterstitial(sb_interstitial); |
| 459 Navigate(kBadURL, 2); // Commit the navigation. | 464 Navigate(kBadURL, 2); // Commit the navigation. |
| 460 GoBack(); | 465 GoBackCrossSite(); |
| 461 | 466 |
| 462 // We are back on the good page. | 467 // We are back on the good page. |
| 463 sb_interstitial = GetSafeBrowsingBlockingPage(); | 468 sb_interstitial = GetSafeBrowsingBlockingPage(); |
| 464 ASSERT_FALSE(sb_interstitial); | 469 ASSERT_FALSE(sb_interstitial); |
| 465 ASSERT_EQ(2, controller().entry_count()); | 470 ASSERT_EQ(2, controller().entry_count()); |
| 466 EXPECT_EQ(kGoodURL, controller().GetActiveEntry()->url().spec()); | 471 EXPECT_EQ(kGoodURL, controller().GetActiveEntry()->url().spec()); |
| 467 | 472 |
| 468 // Navigate forward to the malware URL. | 473 // Navigate forward to the malware URL. |
| 469 contents()->controller().GoForward(); | 474 contents()->controller().GoForward(); |
| 470 ShowInterstitial(ResourceType::MAIN_FRAME, kBadURL); | 475 ShowInterstitial(ResourceType::MAIN_FRAME, kBadURL); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 | 578 |
| 574 EXPECT_TRUE(contents()->profile()->GetPrefs()->GetBoolean( | 579 EXPECT_TRUE(contents()->profile()->GetPrefs()->GetBoolean( |
| 575 prefs::kSafeBrowsingReportingEnabled)); | 580 prefs::kSafeBrowsingReportingEnabled)); |
| 576 | 581 |
| 577 // Simulate the user uncheck the report agreement checkbox. | 582 // Simulate the user uncheck the report agreement checkbox. |
| 578 sb_interstitial->SetReportingPreference(false); | 583 sb_interstitial->SetReportingPreference(false); |
| 579 | 584 |
| 580 EXPECT_FALSE(contents()->profile()->GetPrefs()->GetBoolean( | 585 EXPECT_FALSE(contents()->profile()->GetPrefs()->GetBoolean( |
| 581 prefs::kSafeBrowsingReportingEnabled)); | 586 prefs::kSafeBrowsingReportingEnabled)); |
| 582 } | 587 } |
| OLD | NEW |