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

Unified Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc

Issue 9323071: Use InterstitialPage through a delegate interface instead of deriving from it. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix tests Created 8 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
===================================================================
--- chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc (revision 120576)
+++ chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc (working copy)
@@ -21,6 +21,7 @@
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/tab_contents/interstitial_page.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
@@ -264,21 +265,22 @@
service->AddURLResult(url, checkresult);
}
- void SendCommand(const std::string& command) {
- WebContents* contents =
- browser()->GetSelectedTabContentsWrapper()->web_contents();
+ TestSafeBrowsingBlockingPage* GetSafeBrowsingBlockingPage() {
// We use InterstitialPage::GetInterstitialPage(tab) instead of
// tab->GetInterstitialPage() because the tab doesn't have a pointer
// to its interstital page until it gets a command from the renderer
// that it has indeed displayed it -- and this sometimes happens after
// NavigateToURL returns.
- SafeBrowsingBlockingPage* interstitial_page =
- static_cast<SafeBrowsingBlockingPage*>(
- InterstitialPage::GetInterstitialPage(contents));
- ASSERT_TRUE(interstitial_page);
- interstitial_page->CommandReceived(command);
+ WebContents* contents =
+ browser()->GetSelectedTabContentsWrapper()->web_contents();
+ return static_cast<TestSafeBrowsingBlockingPage*>(
+ contents->GetInterstitialPage()->GetDelegateForTesting());
}
+ void SendCommand(const std::string& command) {
+ GetSafeBrowsingBlockingPage()->CommandReceived(command);
+ }
+
void DontProceedThroughInterstitial() {
WebContents* contents =
browser()->GetSelectedTabContentsWrapper()->web_contents();
@@ -303,8 +305,7 @@
if (contents->ShowingInterstitialPage() && wait_for_delete) {
// We'll get notified when the interstitial is deleted.
- static_cast<TestSafeBrowsingBlockingPage*>(
- contents->GetInterstitialPage())->set_wait_for_delete();
+ GetSafeBrowsingBlockingPage()->set_wait_for_delete();
ui_test_utils::RunMessageLoop();
}

Powered by Google App Engine
This is Rietveld 408576698