| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
| 11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 12 #include "content/browser/tab_contents/navigation_entry.h" | 12 #include "content/browser/tab_contents/navigation_entry.h" |
| 13 #include "content/browser/tab_contents/test_tab_contents.h" | 13 #include "content/browser/tab_contents/test_tab_contents.h" |
| 14 #include "content/common/view_messages.h" | |
| 15 #include "content/test/test_browser_thread.h" | 14 #include "content/test/test_browser_thread.h" |
| 16 | 15 |
| 17 using content::BrowserThread; | 16 using content::BrowserThread; |
| 18 | 17 |
| 19 static const char* kGoogleURL = "http://www.google.com/"; | 18 static const char* kGoogleURL = "http://www.google.com/"; |
| 20 static const char* kGoodURL = "http://www.goodguys.com/"; | 19 static const char* kGoodURL = "http://www.goodguys.com/"; |
| 21 static const char* kBadURL = "http://www.badguys.com/"; | 20 static const char* kBadURL = "http://www.badguys.com/"; |
| 22 static const char* kBadURL2 = "http://www.badguys2.com/"; | 21 static const char* kBadURL2 = "http://www.badguys2.com/"; |
| 23 static const char* kBadURL3 = "http://www.badguys3.com/"; | 22 static const char* kBadURL3 = "http://www.badguys3.com/"; |
| 24 | 23 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 SafeBrowsingService::UrlCheckResult result) { | 102 SafeBrowsingService::UrlCheckResult result) { |
| 104 } | 103 } |
| 105 virtual void OnBlockingPageComplete(bool proceed) { | 104 virtual void OnBlockingPageComplete(bool proceed) { |
| 106 if (proceed) | 105 if (proceed) |
| 107 user_response_ = OK; | 106 user_response_ = OK; |
| 108 else | 107 else |
| 109 user_response_ = CANCEL; | 108 user_response_ = CANCEL; |
| 110 } | 109 } |
| 111 | 110 |
| 112 void Navigate(const char* url, int page_id) { | 111 void Navigate(const char* url, int page_id) { |
| 113 ViewHostMsg_FrameNavigate_Params params; | 112 contents()->TestDidNavigate( |
| 114 InitNavigateParams( | 113 contents()->render_view_host(), page_id, GURL(url), |
| 115 ¶ms, page_id, GURL(url), content::PAGE_TRANSITION_TYPED); | 114 content::PAGE_TRANSITION_TYPED); |
| 116 contents()->TestDidNavigate(contents()->render_view_host(), params); | |
| 117 } | 115 } |
| 118 | 116 |
| 119 void GoBackCrossSite() { | 117 void GoBackCrossSite() { |
| 120 NavigationEntry* entry = contents()->controller().GetEntryAtOffset(-1); | 118 NavigationEntry* entry = contents()->controller().GetEntryAtOffset(-1); |
| 121 ASSERT_TRUE(entry); | 119 ASSERT_TRUE(entry); |
| 122 contents()->controller().GoBack(); | 120 contents()->controller().GoBack(); |
| 123 | 121 |
| 124 // The navigation should commit in the pending RVH. | 122 // The navigation should commit in the pending RVH. |
| 125 ViewHostMsg_FrameNavigate_Params params; | 123 contents()->TestDidNavigate( |
| 126 InitNavigateParams(¶ms, entry->page_id(), GURL(entry->url()), | 124 contents()->pending_rvh(), entry->page_id(), GURL(entry->url()), |
| 127 content::PAGE_TRANSITION_TYPED); | 125 content::PAGE_TRANSITION_TYPED); |
| 128 contents()->TestDidNavigate(contents()->pending_rvh(), params); | |
| 129 } | 126 } |
| 130 | 127 |
| 131 void ShowInterstitial(bool is_subresource, const char* url) { | 128 void ShowInterstitial(bool is_subresource, const char* url) { |
| 132 SafeBrowsingService::UnsafeResource resource; | 129 SafeBrowsingService::UnsafeResource resource; |
| 133 InitResource(&resource, is_subresource, GURL(url)); | 130 InitResource(&resource, is_subresource, GURL(url)); |
| 134 SafeBrowsingBlockingPage::ShowBlockingPage(service_, resource); | 131 SafeBrowsingBlockingPage::ShowBlockingPage(service_, resource); |
| 135 } | 132 } |
| 136 | 133 |
| 137 // Returns the SafeBrowsingBlockingPage currently showing or NULL if none is | 134 // Returns the SafeBrowsingBlockingPage currently showing or NULL if none is |
| 138 // showing. | 135 // showing. |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 | 592 |
| 596 EXPECT_TRUE(profile->GetPrefs()->GetBoolean( | 593 EXPECT_TRUE(profile->GetPrefs()->GetBoolean( |
| 597 prefs::kSafeBrowsingReportingEnabled)); | 594 prefs::kSafeBrowsingReportingEnabled)); |
| 598 | 595 |
| 599 // Simulate the user uncheck the report agreement checkbox. | 596 // Simulate the user uncheck the report agreement checkbox. |
| 600 sb_interstitial->SetReportingPreference(false); | 597 sb_interstitial->SetReportingPreference(false); |
| 601 | 598 |
| 602 EXPECT_FALSE(profile->GetPrefs()->GetBoolean( | 599 EXPECT_FALSE(profile->GetPrefs()->GetBoolean( |
| 603 prefs::kSafeBrowsingReportingEnabled)); | 600 prefs::kSafeBrowsingReportingEnabled)); |
| 604 } | 601 } |
| OLD | NEW |