| 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 // This test creates a fake safebrowsing service, where we can inject | 5 // This test creates a fake safebrowsing service, where we can inject |
| 6 // malware and phishing urls. It then uses a real browser to go to | 6 // malware and phishing urls. It then uses a real browser to go to |
| 7 // these urls, and sends "goback" or "proceed" commands and verifies | 7 // these urls, and sends "goback" or "proceed" commands and verifies |
| 8 // they work. | 8 // they work. |
| 9 | 9 |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // A MalwareDetails class lets us intercept calls from the renderer. | 96 // A MalwareDetails class lets us intercept calls from the renderer. |
| 97 class FakeMalwareDetails : public MalwareDetails { | 97 class FakeMalwareDetails : public MalwareDetails { |
| 98 public: | 98 public: |
| 99 FakeMalwareDetails(TabContents* tab_contents, | 99 FakeMalwareDetails(TabContents* tab_contents, |
| 100 const SafeBrowsingService::UnsafeResource& unsafe_resource) | 100 const SafeBrowsingService::UnsafeResource& unsafe_resource) |
| 101 : MalwareDetails(tab_contents, unsafe_resource) { } | 101 : MalwareDetails(tab_contents, unsafe_resource) { } |
| 102 | 102 |
| 103 virtual ~FakeMalwareDetails() {} | 103 virtual ~FakeMalwareDetails() {} |
| 104 | 104 |
| 105 virtual void AddDOMDetails( | 105 virtual void AddDOMDetails( |
| 106 const ViewHostMsg_MalwareDOMDetails_Params& params) { | 106 const std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node>& params) { |
| 107 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 107 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 108 MalwareDetails::AddDOMDetails(params); | 108 MalwareDetails::AddDOMDetails(params); |
| 109 | 109 |
| 110 // Notify the UI thread that we got the dom details. | 110 // Notify the UI thread that we got the dom details. |
| 111 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 111 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 112 NewRunnableMethod(this, | 112 NewRunnableMethod(this, |
| 113 &FakeMalwareDetails::OnDOMDetailsDone)); | 113 &FakeMalwareDetails::OnDOMDetailsDone)); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void OnDOMDetailsDone() { | 116 void OnDOMDetailsDone() { |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 prefs::kSafeBrowsingReportingEnabled)); | 407 prefs::kSafeBrowsingReportingEnabled)); |
| 408 | 408 |
| 409 SendCommand("\"proceed\""); // Simulate the user clicking "back" | 409 SendCommand("\"proceed\""); // Simulate the user clicking "back" |
| 410 AssertNoInterstitial(); // Assert the interstitial is gone | 410 AssertNoInterstitial(); // Assert the interstitial is gone |
| 411 | 411 |
| 412 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL()); | 412 EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL()); |
| 413 AssertReportSent(); | 413 AssertReportSent(); |
| 414 } | 414 } |
| 415 | 415 |
| 416 } // namespace | 416 } // namespace |
| OLD | NEW |