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

Unified Diff: content/browser/tab_contents/tab_contents_unittest.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 cros 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: content/browser/tab_contents/tab_contents_unittest.cc
===================================================================
--- content/browser/tab_contents/tab_contents_unittest.cc (revision 120733)
+++ content/browser/tab_contents/tab_contents_unittest.cc (working copy)
@@ -13,6 +13,7 @@
#include "content/browser/tab_contents/navigation_entry_impl.h"
#include "content/browser/tab_contents/test_tab_contents.h"
#include "content/common/view_messages.h"
+#include "content/public/browser/interstitial_page_delegate.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
@@ -88,6 +89,20 @@
TabContentsTestWebUIControllerFactory factory_;
};
+class TestInterstitialPage;
+
+class TestInterstitialPageDelegate : public content::InterstitialPageDelegate {
+ public:
+ TestInterstitialPageDelegate(TestInterstitialPage* interstitial_page)
+ : interstitial_page_(interstitial_page) {}
+ virtual void CommandReceived(const std::string& command) OVERRIDE;
+ virtual std::string GetHTMLContents() OVERRIDE { return std::string(); }
+ virtual void OnDontProceed() OVERRIDE;
+ virtual void OnProceed() OVERRIDE;
+ private:
+ TestInterstitialPage* interstitial_page_;
+};
+
class TestInterstitialPage : public InterstitialPage {
public:
enum InterstitialState {
@@ -119,7 +134,9 @@
const GURL& url,
InterstitialState* state,
bool* deleted)
- : InterstitialPage(tab, new_navigation, url),
+ : InterstitialPage(
+ tab, new_navigation, url,
+ new TestInterstitialPageDelegate(this)),
state_(state),
deleted_(deleted),
command_received_count_(0),
@@ -135,15 +152,13 @@
delegate_->TestInterstitialPageDeleted(this);
}
- virtual void DontProceed() {
+ void OnDontProceed() {
if (state_)
*state_ = CANCELED;
- InterstitialPage::DontProceed();
}
- virtual void Proceed() {
+ void OnProceed() {
if (state_)
*state_ = OKED;
- InterstitialPage::Proceed();
}
int command_received_count() const {
@@ -152,7 +167,7 @@
void TestDomOperationResponse(const std::string& json_string) {
if (enabled())
- CommandReceived(json_string);
+ CommandReceived();
}
void TestDidNavigate(int page_id, const GURL& url) {
@@ -176,22 +191,23 @@
delegate_ = NULL;
}
+ void CommandReceived() {
+ command_received_count_++;
+ }
+
void set_delegate(Delegate* delegate) {
delegate_ = delegate;
}
protected:
- virtual RenderViewHost* CreateRenderViewHost() {
+ virtual RenderViewHost* CreateRenderViewHost() OVERRIDE {
return new TestRenderViewHost(
SiteInstance::Create(tab()->GetBrowserContext()),
this, MSG_ROUTING_NONE);
}
- virtual content::WebContentsView* CreateWebContentsView() { return NULL; }
-
-
- virtual void CommandReceived(const std::string& command) {
- command_received_count_++;
+ virtual content::WebContentsView* CreateWebContentsView() OVERRIDE {
+ return NULL;
}
private:
@@ -201,6 +217,18 @@
Delegate* delegate_;
};
+void TestInterstitialPageDelegate::CommandReceived(const std::string& command) {
+ interstitial_page_->CommandReceived();
+}
+
+void TestInterstitialPageDelegate::OnDontProceed() {
+ interstitial_page_->OnDontProceed();
+}
+
+void TestInterstitialPageDelegate::OnProceed() {
+ interstitial_page_->OnProceed();
+}
+
class TestInterstitialPageStateGuard : public TestInterstitialPage::Delegate {
public:
explicit TestInterstitialPageStateGuard(
« no previous file with comments | « content/browser/tab_contents/interstitial_page.cc ('k') | content/public/browser/interstitial_page_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698