summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-03 17:18:04 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-03 17:18:04 +0000
commitbc0caef9b0af84365b6dd546cd21673c9790ca58 (patch)
tree54881e9c8bc957f65901a53978d18865135392dd /chrome/browser/tab_contents
parent4e9f6be54df1f1f6f9cfe243624ef976f15d452f (diff)
downloadchromium_src-bc0caef9b0af84365b6dd546cd21673c9790ca58.zip
chromium_src-bc0caef9b0af84365b6dd546cd21673c9790ca58.tar.gz
chromium_src-bc0caef9b0af84365b6dd546cd21673c9790ca58.tar.bz2
This CL adds unit-tests for the SafeBrowsingBlockingPage class.
This required: - creating a factory to create SafeBrowsingBlockingPage instances (so unit-tests can provide their own sub-classes). - making the code posts tasks on the current message loop when there is no IO thread. This should only happen in tests scenarios where we only have 1 thread. BUG=6731 TEST=Run the unit-tests. In Chrome, navigate to pages flagged as malware (ex: ianfette.org) and make sure the safe browsing feature still works as expected. Review URL: http://codereview.chromium.org/56135 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13088 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/interstitial_page.cc15
-rw-r--r--chrome/browser/tab_contents/interstitial_page.h7
-rw-r--r--chrome/browser/tab_contents/web_contents_unittest.cc3
3 files changed, 19 insertions, 6 deletions
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc
index aa37c94..d1701b3 100644
--- a/chrome/browser/tab_contents/interstitial_page.cc
+++ b/chrome/browser/tab_contents/interstitial_page.cc
@@ -174,6 +174,7 @@ void InterstitialPage::Show() {
DCHECK(!render_view_host_);
render_view_host_ = CreateRenderViewHost();
+ CreateWebContentsView();
std::string data_url = "data:text/html;charset=utf-8," +
EscapePath(GetHTMLContents());
@@ -253,16 +254,20 @@ RenderViewHost* InterstitialPage::CreateRenderViewHost() {
RenderViewHost* render_view_host = new RenderViewHost(
SiteInstance::CreateSiteInstance(tab()->profile()),
this, MSG_ROUTING_NONE, NULL);
+ return render_view_host;
+}
+
+WebContentsView* InterstitialPage::CreateWebContentsView() {
WebContentsView* web_contents_view = tab()->view();
RenderWidgetHostView* view =
- web_contents_view->CreateViewForWidget(render_view_host);
- render_view_host->set_view(view);
- render_view_host->AllowDomAutomationBindings();
- render_view_host->CreateRenderView();
+ web_contents_view->CreateViewForWidget(render_view_host_);
+ render_view_host_->set_view(view);
+ render_view_host_->AllowDomAutomationBindings();
+ render_view_host_->CreateRenderView();
view->SetSize(web_contents_view->GetContainerSize());
// Don't show the interstitial until we have navigated to it.
view->Hide();
- return render_view_host;
+ return web_contents_view;
}
void InterstitialPage::Proceed() {
diff --git a/chrome/browser/tab_contents/interstitial_page.h b/chrome/browser/tab_contents/interstitial_page.h
index 3f5ceca..3d66193 100644
--- a/chrome/browser/tab_contents/interstitial_page.h
+++ b/chrome/browser/tab_contents/interstitial_page.h
@@ -16,6 +16,7 @@
class MessageLoop;
class NavigationEntry;
class WebContents;
+class WebContentsView;
// This class is a base class for interstitial pages, pages that show some
// informative message asking for user validation before reaching the target
@@ -111,10 +112,14 @@ class InterstitialPage : public NotificationObserver,
const GURL& url() const { return url_; }
RenderViewHost* render_view_host() const { return render_view_host_; }
- // Creates and shows the RenderViewHost containing the interstitial content.
+ // Creates the RenderViewHost containing the interstitial content.
// Overriden in unit tests.
virtual RenderViewHost* CreateRenderViewHost();
+ // Creates the WebContentsView that shows the interstitial RVH.
+ // Overriden in unit tests.
+ virtual WebContentsView* CreateWebContentsView();
+
private:
// AutomationProvider needs access to Proceed and DontProceed to simulate
// user actions.
diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc
index 8dab8c6..2f069e9 100644
--- a/chrome/browser/tab_contents/web_contents_unittest.cc
+++ b/chrome/browser/tab_contents/web_contents_unittest.cc
@@ -150,6 +150,9 @@ class TestInterstitialPage : public InterstitialPage {
this, MSG_ROUTING_NONE, NULL);
}
+ virtual WebContentsView* CreateWebContentsView() { return NULL; }
+
+
virtual void CommandReceived(const std::string& command) {
command_received_count_++;
}