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