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

Unified Diff: content/browser/tab_contents/interstitial_page.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: sync 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/interstitial_page.cc
===================================================================
--- content/browser/tab_contents/interstitial_page.cc (revision 120576)
+++ content/browser/tab_contents/interstitial_page.cc (working copy)
@@ -24,6 +24,7 @@
#include "content/common/view_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/dom_operation_notification_details.h"
+#include "content/public/browser/interstitial_page_delegate.h"
#include "content/public/browser/invalidate_type.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
@@ -36,6 +37,7 @@
using content::BrowserThread;
using content::DomOperationNotificationDetails;
+using content::InterstitialPageDelegate;
using content::NavigationController;
using content::NavigationEntry;
using content::NavigationEntryImpl;
@@ -117,13 +119,21 @@
DISALLOW_COPY_AND_ASSIGN(InterstitialPageRVHViewDelegate);
};
+InterstitialPage* InterstitialPage::Create(WebContents* tab,
+ bool new_navigation,
+ const GURL& url,
+ InterstitialPageDelegate* delegate) {
+ return new InterstitialPage(tab, new_navigation, url, delegate);
+}
+
// static
InterstitialPage::InterstitialPageMap*
InterstitialPage::tab_to_interstitial_page_ = NULL;
InterstitialPage::InterstitialPage(WebContents* tab,
bool new_navigation,
- const GURL& url)
+ const GURL& url,
+ InterstitialPageDelegate* delegate)
: tab_(static_cast<TabContents*>(tab)),
url_(url),
new_navigation_(new_navigation),
@@ -138,7 +148,8 @@
tab_was_loading_(false),
resource_dispatcher_host_notified_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(rvh_view_delegate_(
- new InterstitialPageRVHViewDelegate(this))) {
+ new InterstitialPageRVHViewDelegate(this))),
+ delegate_(delegate) {
InitInterstitialPageMap();
// It would be inconsistent to create an interstitial with no new navigation
// (which is the case when the interstitial was triggered by a sub-resource on
@@ -199,8 +210,8 @@
entry->SetVirtualURL(url_);
entry->set_page_type(content::PAGE_TYPE_INTERSTITIAL);
- // Give sub-classes a chance to set some states on the navigation entry.
- UpdateEntry(entry);
+ // Give delegates a chance to set some states on the navigation entry.
+ delegate_->OverrideEntry(entry);
tab_->GetControllerImpl().AddTransientEntry(entry);
}
@@ -210,7 +221,7 @@
CreateWebContentsView();
std::string data_url = "data:text/html;charset=utf-8," +
- net::EscapePath(GetHTMLContents());
+ net::EscapePath(delegate_->GetHTMLContents());
render_view_host_->NavigateToURL(GURL(data_url));
notification_registrar_.Add(this,
@@ -310,7 +321,7 @@
if (enabled()) {
content::Details<DomOperationNotificationDetails> dom_op_details(
details);
- CommandReceived(dom_op_details->json);
+ delegate_->CommandReceived(dom_op_details->json);
}
break;
default:
@@ -416,6 +427,7 @@
content::RendererPreferences InterstitialPage::GetRendererPrefs(
content::BrowserContext* browser_context) const {
+ delegate_->OverrideRendererPrefs(&renderer_preferences_);
return renderer_preferences_;
}
@@ -490,10 +502,6 @@
}
}
-std::string InterstitialPage::GetHTMLContents() {
- return std::string();
-}
-
void InterstitialPage::DontProceed() {
DCHECK(action_taken_ != DONT_PROCEED_ACTION);
@@ -560,6 +568,10 @@
render_view_host_->SetInitialFocus(reverse);
}
+content::InterstitialPageDelegate* InterstitialPage::GetDelegateForTesting() {
+ return delegate_.get();
+}
+
content::ViewType InterstitialPage::GetRenderViewType() const {
return content::VIEW_TYPE_INTERSTITIAL_PAGE;
}

Powered by Google App Engine
This is Rietveld 408576698