Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc

Issue 2540563002: Move SafeBrowsingUIManager::UnsafeResource to security_interstitials namespace (Closed)
Patch Set: rebase update Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/run_loop.h" 7 #include "base/run_loop.h"
8 #include "chrome/browser/interstitials/chrome_controller_client.h" 8 #include "chrome/browser/interstitials/chrome_controller_client.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 10 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 web_contents()->GetMainFrame(); 152 web_contents()->GetMainFrame();
153 WebContentsTester::For(web_contents())->TestDidNavigate( 153 WebContentsTester::For(web_contents())->TestDidNavigate(
154 rfh, 154 rfh,
155 entry->GetUniqueID(), 155 entry->GetUniqueID(),
156 false, 156 false,
157 entry->GetURL(), 157 entry->GetURL(),
158 ui::PAGE_TRANSITION_TYPED); 158 ui::PAGE_TRANSITION_TYPED);
159 } 159 }
160 160
161 void ShowInterstitial(bool is_subresource, const char* url) { 161 void ShowInterstitial(bool is_subresource, const char* url) {
162 SafeBrowsingUIManager::UnsafeResource resource; 162 security_interstitials::UnsafeResource resource;
163 InitResource(&resource, is_subresource, GURL(url)); 163 InitResource(&resource, is_subresource, GURL(url));
164 SafeBrowsingBlockingPage::ShowBlockingPage(ui_manager_.get(), resource); 164 SafeBrowsingBlockingPage::ShowBlockingPage(ui_manager_.get(), resource);
165 } 165 }
166 166
167 // Returns the SafeBrowsingBlockingPage currently showing or NULL if none is 167 // Returns the SafeBrowsingBlockingPage currently showing or NULL if none is
168 // showing. 168 // showing.
169 SafeBrowsingBlockingPage* GetSafeBrowsingBlockingPage() { 169 SafeBrowsingBlockingPage* GetSafeBrowsingBlockingPage() {
170 InterstitialPage* interstitial = 170 InterstitialPage* interstitial =
171 InterstitialPage::GetInterstitialPage(web_contents()); 171 InterstitialPage::GetInterstitialPage(web_contents());
172 if (!interstitial) 172 if (!interstitial)
(...skipping 24 matching lines...) Expand all
197 // CommandReceived(kTakeMeBackCommand) does a back navigation for 197 // CommandReceived(kTakeMeBackCommand) does a back navigation for
198 // subresource interstitials. 198 // subresource interstitials.
199 GoBack(false); 199 GoBack(false);
200 // DontProceed() posts a task to update the SafeBrowsingService::Client. 200 // DontProceed() posts a task to update the SafeBrowsingService::Client.
201 base::RunLoop().RunUntilIdle(); 201 base::RunLoop().RunUntilIdle();
202 } 202 }
203 203
204 scoped_refptr<TestSafeBrowsingUIManager> ui_manager_; 204 scoped_refptr<TestSafeBrowsingUIManager> ui_manager_;
205 205
206 private: 206 private:
207 void InitResource(SafeBrowsingUIManager::UnsafeResource* resource, 207 void InitResource(security_interstitials::UnsafeResource* resource,
208 bool is_subresource, 208 bool is_subresource,
209 const GURL& url) { 209 const GURL& url) {
210 resource->callback = 210 resource->callback =
211 base::Bind(&SafeBrowsingBlockingPageTest::OnBlockingPageComplete, 211 base::Bind(&SafeBrowsingBlockingPageTest::OnBlockingPageComplete,
212 base::Unretained(this)); 212 base::Unretained(this));
213 resource->callback_thread = content::BrowserThread::GetTaskRunnerForThread( 213 resource->callback_thread = content::BrowserThread::GetTaskRunnerForThread(
214 content::BrowserThread::IO); 214 content::BrowserThread::IO);
215 resource->url = url; 215 resource->url = url;
216 resource->is_subresource = is_subresource; 216 resource->is_subresource = is_subresource;
217 resource->threat_type = SB_THREAT_TYPE_URL_MALWARE; 217 resource->threat_type = SB_THREAT_TYPE_URL_MALWARE;
218 resource->web_contents_getter = 218 resource->web_contents_getter =
219 SafeBrowsingUIManager::UnsafeResource::GetWebContentsGetter( 219 security_interstitials::UnsafeResource::GetWebContentsGetter(
220 web_contents()->GetRenderProcessHost()->GetID(), 220 web_contents()->GetRenderProcessHost()->GetID(),
221 web_contents()->GetMainFrame()->GetRoutingID()); 221 web_contents()->GetMainFrame()->GetRoutingID());
222 resource->threat_source = safe_browsing::ThreatSource::LOCAL_PVER3; 222 resource->threat_source = safe_browsing::ThreatSource::LOCAL_PVER3;
223 } 223 }
224 224
225 UserResponse user_response_; 225 UserResponse user_response_;
226 TestSafeBrowsingBlockingPageFactory factory_; 226 TestSafeBrowsingBlockingPageFactory factory_;
227 }; 227 };
228 228
229 229
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 835
836 // No report should have been sent. 836 // No report should have been sent.
837 EXPECT_EQ(0u, ui_manager_->GetThreatDetails()->size()); 837 EXPECT_EQ(0u, ui_manager_->GetThreatDetails()->size());
838 ui_manager_->GetThreatDetails()->clear(); 838 ui_manager_->GetThreatDetails()->clear();
839 } 839 }
840 840
841 // TODO(mattm): Add test for extended reporting not shown or sent in incognito 841 // TODO(mattm): Add test for extended reporting not shown or sent in incognito
842 // window. 842 // window.
843 843
844 } // namespace safe_browsing 844 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698