summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-08 21:53:13 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-08 21:53:13 +0000
commitcadaec593e7979bfe86521f5300664ff396ca37f (patch)
treeb2d5720e08ac2b19fe1f1c34c8df4fdfe44a329c /content
parent5bbc87042e45aee1152f79f97e55dd42dee07cb2 (diff)
downloadchromium_src-cadaec593e7979bfe86521f5300664ff396ca37f.zip
chromium_src-cadaec593e7979bfe86521f5300664ff396ca37f.tar.gz
chromium_src-cadaec593e7979bfe86521f5300664ff396ca37f.tar.bz2
Add an API around InterstitialPage that's used by chrome.
BUG=98716 Review URL: https://chromiumcodereview.appspot.com/9348064 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121059 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/tab_contents/interstitial_page_impl.cc (renamed from content/browser/tab_contents/interstitial_page.cc)203
-rw-r--r--content/browser/tab_contents/interstitial_page_impl.h (renamed from content/browser/tab_contents/interstitial_page.h)116
-rw-r--r--content/browser/tab_contents/navigation_controller_impl.cc11
-rw-r--r--content/browser/tab_contents/render_view_host_manager.h8
-rw-r--r--content/browser/tab_contents/tab_contents.cc3
-rw-r--r--content/browser/tab_contents/tab_contents.h9
-rw-r--r--content/browser/tab_contents/tab_contents_unittest.cc18
-rw-r--r--content/browser/tab_contents/tab_contents_view_gtk.cc2
-rw-r--r--content/browser/tab_contents/tab_contents_view_win.cc2
-rw-r--r--content/content_browser.gypi5
-rw-r--r--content/public/browser/interstitial_page.h88
-rw-r--r--content/public/browser/utility_process_host.h2
-rw-r--r--content/public/browser/web_contents.h2
13 files changed, 254 insertions, 215 deletions
diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page_impl.cc
index 9ce0be1..264995b 100644
--- a/content/browser/tab_contents/interstitial_page.cc
+++ b/content/browser/tab_contents/interstitial_page_impl.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/tab_contents/interstitial_page.h"
+#include "content/browser/tab_contents/interstitial_page_impl.h"
#include <vector>
@@ -74,10 +74,10 @@ void ResourceRequestHelper(ResourceDispatcherHost* resource_dispatcher_host,
} // namespace
-class InterstitialPage::InterstitialPageRVHViewDelegate
+class InterstitialPageImpl::InterstitialPageRVHViewDelegate
: public RenderViewHostDelegate::View {
public:
- explicit InterstitialPageRVHViewDelegate(InterstitialPage* page);
+ explicit InterstitialPageRVHViewDelegate(InterstitialPageImpl* page);
// RenderViewHostDelegate::View implementation:
virtual void CreateNewWindow(
@@ -114,26 +114,50 @@ class InterstitialPage::InterstitialPageRVHViewDelegate
bool final_update);
private:
- InterstitialPage* interstitial_page_;
+ InterstitialPageImpl* interstitial_page_;
DISALLOW_COPY_AND_ASSIGN(InterstitialPageRVHViewDelegate);
};
+
+// We keep a map of the various blocking pages shown as the UI tests need to
+// be able to retrieve them.
+typedef std::map<WebContents*, InterstitialPageImpl*> InterstitialPageMap;
+static InterstitialPageMap* g_tab_to_interstitial_page;
+
+// Initializes g_tab_to_interstitial_page in a thread-safe manner.
+// Should be called before accessing g_tab_to_interstitial_page.
+static void InitInterstitialPageMap() {
+ if (!g_tab_to_interstitial_page)
+ g_tab_to_interstitial_page = new InterstitialPageMap;
+}
+
+namespace content {
+
InterstitialPage* InterstitialPage::Create(WebContents* tab,
bool new_navigation,
const GURL& url,
InterstitialPageDelegate* delegate) {
- return new InterstitialPage(tab, new_navigation, url, delegate);
+ return new InterstitialPageImpl(tab, new_navigation, url, delegate);
}
-// static
-InterstitialPage::InterstitialPageMap*
- InterstitialPage::tab_to_interstitial_page_ = NULL;
+InterstitialPage* InterstitialPage::GetInterstitialPage(
+ WebContents* web_contents) {
+ InitInterstitialPageMap();
+ InterstitialPageMap::const_iterator iter =
+ g_tab_to_interstitial_page->find(web_contents);
+ if (iter == g_tab_to_interstitial_page->end())
+ return NULL;
-InterstitialPage::InterstitialPage(WebContents* tab,
- bool new_navigation,
- const GURL& url,
- InterstitialPageDelegate* delegate)
+ return iter->second;
+}
+
+} // namespace content
+
+InterstitialPageImpl::InterstitialPageImpl(WebContents* tab,
+ bool new_navigation,
+ const GURL& url,
+ InterstitialPageDelegate* delegate)
: tab_(static_cast<TabContents*>(tab)),
url_(url),
new_navigation_(new_navigation),
@@ -159,17 +183,17 @@ InterstitialPage::InterstitialPage(WebContents* tab,
DCHECK(new_navigation || !tab->GetController().GetPendingEntry());
}
-InterstitialPage::~InterstitialPage() {
+InterstitialPageImpl::~InterstitialPageImpl() {
}
-void InterstitialPage::Show() {
+void InterstitialPageImpl::Show() {
// If an interstitial is already showing or about to be shown, close it before
// showing the new one.
// Be careful not to take an action on the old interstitial more than once.
InterstitialPageMap::const_iterator iter =
- tab_to_interstitial_page_->find(tab_);
- if (iter != tab_to_interstitial_page_->end()) {
- InterstitialPage* interstitial = iter->second;
+ g_tab_to_interstitial_page->find(tab_);
+ if (iter != g_tab_to_interstitial_page->end()) {
+ InterstitialPageImpl* interstitial = iter->second;
if (interstitial->action_taken_ != NO_ACTION) {
interstitial->Hide();
delete interstitial;
@@ -196,10 +220,10 @@ void InterstitialPage::Show() {
this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
content::Source<RenderWidgetHost>(tab_->GetRenderViewHost()));
- // Update the tab_to_interstitial_page_ map.
- iter = tab_to_interstitial_page_->find(tab_);
- DCHECK(iter == tab_to_interstitial_page_->end());
- (*tab_to_interstitial_page_)[tab_] = this;
+ // Update the g_tab_to_interstitial_page map.
+ iter = g_tab_to_interstitial_page->find(tab_);
+ DCHECK(iter == g_tab_to_interstitial_page->end());
+ (*g_tab_to_interstitial_page)[tab_] = this;
if (new_navigation_) {
NavigationEntryImpl* entry = new NavigationEntryImpl;
@@ -233,7 +257,7 @@ void InterstitialPage::Show() {
content::Source<RenderViewHost>(render_view_host_));
}
-void InterstitialPage::Hide() {
+void InterstitialPageImpl::Hide() {
RenderWidgetHostView* old_view = tab_->GetRenderViewHost()->view();
if (tab_->GetInterstitialPage() == this &&
old_view && !old_view->IsShowing()) {
@@ -268,15 +292,16 @@ void InterstitialPage::Hide() {
content::Source<WebContents>(tab_),
content::NotificationService::NoDetails());
- InterstitialPageMap::iterator iter = tab_to_interstitial_page_->find(tab_);
- DCHECK(iter != tab_to_interstitial_page_->end());
- if (iter != tab_to_interstitial_page_->end())
- tab_to_interstitial_page_->erase(iter);
+ InterstitialPageMap::iterator iter = g_tab_to_interstitial_page->find(tab_);
+ DCHECK(iter != g_tab_to_interstitial_page->end());
+ if (iter != g_tab_to_interstitial_page->end())
+ g_tab_to_interstitial_page->erase(iter);
}
-void InterstitialPage::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
+void InterstitialPageImpl::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
switch (type) {
case content::NOTIFICATION_NAV_ENTRY_PENDING:
// We are navigating away from the interstitial (the user has typed a URL
@@ -329,23 +354,23 @@ void InterstitialPage::Observe(int type,
}
}
-RenderViewHostDelegate::View* InterstitialPage::GetViewDelegate() {
+RenderViewHostDelegate::View* InterstitialPageImpl::GetViewDelegate() {
return rvh_view_delegate_.get();
}
-const GURL& InterstitialPage::GetURL() const {
+const GURL& InterstitialPageImpl::GetURL() const {
return url_;
}
-void InterstitialPage::RenderViewGone(RenderViewHost* render_view_host,
- base::TerminationStatus status,
- int error_code) {
+void InterstitialPageImpl::RenderViewGone(RenderViewHost* render_view_host,
+ base::TerminationStatus status,
+ int error_code) {
// Our renderer died. This should not happen in normal cases.
// Just dismiss the interstitial.
DontProceed();
}
-void InterstitialPage::DidNavigate(
+void InterstitialPageImpl::DidNavigate(
RenderViewHost* render_view_host,
const ViewHostMsg_FrameNavigate_Params& params) {
// A fast user could have navigated away from the page that triggered the
@@ -394,10 +419,11 @@ void InterstitialPage::DidNavigate(
tab_->SetIsLoading(false, NULL);
}
-void InterstitialPage::UpdateTitle(RenderViewHost* render_view_host,
- int32 page_id,
- const string16& title,
- base::i18n::TextDirection title_direction) {
+void InterstitialPageImpl::UpdateTitle(
+ RenderViewHost* render_view_host,
+ int32 page_id,
+ const string16& title,
+ base::i18n::TextDirection title_direction) {
DCHECK(render_view_host == render_view_host_);
NavigationEntry* entry = tab_->GetController().GetActiveEntry();
if (!entry) {
@@ -425,39 +451,39 @@ void InterstitialPage::UpdateTitle(RenderViewHost* render_view_host,
tab_->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE);
}
-content::RendererPreferences InterstitialPage::GetRendererPrefs(
+content::RendererPreferences InterstitialPageImpl::GetRendererPrefs(
content::BrowserContext* browser_context) const {
delegate_->OverrideRendererPrefs(&renderer_preferences_);
return renderer_preferences_;
}
-WebPreferences InterstitialPage::GetWebkitPrefs() {
- return tab_->GetWebkitPrefs(render_view_host(), url_);
+WebPreferences InterstitialPageImpl::GetWebkitPrefs() {
+ return tab_->GetWebkitPrefs(render_view_host_, url_);
}
-bool InterstitialPage::PreHandleKeyboardEvent(
+bool InterstitialPageImpl::PreHandleKeyboardEvent(
const NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) {
return tab_->PreHandleKeyboardEvent(event, is_keyboard_shortcut);
}
-void InterstitialPage::HandleKeyboardEvent(
+void InterstitialPageImpl::HandleKeyboardEvent(
const NativeWebKeyboardEvent& event) {
return tab_->HandleKeyboardEvent(event);
}
-WebContents* InterstitialPage::tab() const {
+WebContents* InterstitialPageImpl::tab() const {
return tab_;
}
-RenderViewHost* InterstitialPage::CreateRenderViewHost() {
+RenderViewHost* InterstitialPageImpl::CreateRenderViewHost() {
RenderViewHost* render_view_host = new RenderViewHost(
SiteInstance::Create(tab()->GetBrowserContext()),
this, MSG_ROUTING_NONE, kInvalidSessionStorageNamespaceId);
return render_view_host;
}
-WebContentsView* InterstitialPage::CreateWebContentsView() {
+WebContentsView* InterstitialPageImpl::CreateWebContentsView() {
if (!create_view_)
return NULL;
WebContentsView* web_contents_view = tab()->GetView();
@@ -475,7 +501,7 @@ WebContentsView* InterstitialPage::CreateWebContentsView() {
return web_contents_view;
}
-void InterstitialPage::Proceed() {
+void InterstitialPageImpl::Proceed() {
if (action_taken_ != NO_ACTION) {
NOTREACHED();
return;
@@ -508,7 +534,7 @@ void InterstitialPage::Proceed() {
delegate_->OnProceed();
}
-void InterstitialPage::DontProceed() {
+void InterstitialPageImpl::DontProceed() {
DCHECK(action_taken_ != DONT_PROCEED_ACTION);
Disable();
@@ -540,7 +566,7 @@ void InterstitialPage::DontProceed() {
delete this;
}
-void InterstitialPage::CancelForNavigation() {
+void InterstitialPageImpl::CancelForNavigation() {
// The user is trying to navigate away. We should unblock the renderer and
// disable the interstitial, but keep it visible until the navigation
// completes.
@@ -554,7 +580,7 @@ void InterstitialPage::CancelForNavigation() {
TakeActionOnResourceDispatcher(CANCEL);
}
-void InterstitialPage::SetSize(const gfx::Size& size) {
+void InterstitialPageImpl::SetSize(const gfx::Size& size) {
#if !defined(OS_MACOSX)
// When a tab is closed, we might be resized after our view was NULLed
// (typically if there was an info-bar).
@@ -566,36 +592,40 @@ void InterstitialPage::SetSize(const gfx::Size& size) {
#endif
}
-void InterstitialPage::Focus() {
+void InterstitialPageImpl::Focus() {
// Focus the native window.
render_view_host_->view()->Focus();
}
-void InterstitialPage::FocusThroughTabTraversal(bool reverse) {
+void InterstitialPageImpl::FocusThroughTabTraversal(bool reverse) {
render_view_host_->SetInitialFocus(reverse);
}
-content::InterstitialPageDelegate* InterstitialPage::GetDelegateForTesting() {
+RenderViewHost* InterstitialPageImpl::GetRenderViewHostForTesting() const {
+ return render_view_host_;
+}
+
+InterstitialPageDelegate* InterstitialPageImpl::GetDelegateForTesting() {
return delegate_.get();
}
-void InterstitialPage::DontCreateViewForTesting() {
+void InterstitialPageImpl::DontCreateViewForTesting() {
create_view_ = false;
}
-content::ViewType InterstitialPage::GetRenderViewType() const {
+content::ViewType InterstitialPageImpl::GetRenderViewType() const {
return content::VIEW_TYPE_INTERSTITIAL_PAGE;
}
-gfx::Rect InterstitialPage::GetRootWindowResizerRect() const {
+gfx::Rect InterstitialPageImpl::GetRootWindowResizerRect() const {
return gfx::Rect();
}
-void InterstitialPage::Disable() {
+void InterstitialPageImpl::Disable() {
enabled_ = false;
}
-void InterstitialPage::TakeActionOnResourceDispatcher(
+void InterstitialPageImpl::TakeActionOnResourceDispatcher(
ResourceRequestAction action) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)) <<
"TakeActionOnResourceDispatcher should be called on the main thread.";
@@ -627,71 +657,50 @@ void InterstitialPage::TakeActionOnResourceDispatcher(
action));
}
-// static
-void InterstitialPage::InitInterstitialPageMap() {
- if (!tab_to_interstitial_page_)
- tab_to_interstitial_page_ = new InterstitialPageMap;
-}
-
-// static
-InterstitialPage* InterstitialPage::GetInterstitialPage(
- WebContents* web_contents) {
- InitInterstitialPageMap();
- TabContents* tab_contents = static_cast<TabContents*>(web_contents);
- InterstitialPageMap::const_iterator iter =
- tab_to_interstitial_page_->find(tab_contents);
- if (iter == tab_to_interstitial_page_->end())
- return NULL;
-
- return iter->second;
-}
-
-InterstitialPage::InterstitialPageRVHViewDelegate::
- InterstitialPageRVHViewDelegate(InterstitialPage* page)
+InterstitialPageImpl::InterstitialPageRVHViewDelegate::
+ InterstitialPageRVHViewDelegate(InterstitialPageImpl* page)
: interstitial_page_(page) {
}
-void InterstitialPage::InterstitialPageRVHViewDelegate::CreateNewWindow(
+void InterstitialPageImpl::InterstitialPageRVHViewDelegate::CreateNewWindow(
int route_id,
const ViewHostMsg_CreateWindow_Params& params) {
NOTREACHED() << "InterstitialPage does not support showing popups yet.";
}
-void InterstitialPage::InterstitialPageRVHViewDelegate::CreateNewWidget(
+void InterstitialPageImpl::InterstitialPageRVHViewDelegate::CreateNewWidget(
int route_id, WebKit::WebPopupType popup_type) {
NOTREACHED() << "InterstitialPage does not support showing drop-downs yet.";
}
-void
-InterstitialPage::InterstitialPageRVHViewDelegate::CreateNewFullscreenWidget(
- int route_id) {
+void InterstitialPageImpl::InterstitialPageRVHViewDelegate::
+ CreateNewFullscreenWidget(int route_id) {
NOTREACHED()
<< "InterstitialPage does not support showing full screen popups.";
}
-void InterstitialPage::InterstitialPageRVHViewDelegate::ShowCreatedWindow(
+void InterstitialPageImpl::InterstitialPageRVHViewDelegate::ShowCreatedWindow(
int route_id, WindowOpenDisposition disposition,
const gfx::Rect& initial_pos, bool user_gesture) {
NOTREACHED() << "InterstitialPage does not support showing popups yet.";
}
-void InterstitialPage::InterstitialPageRVHViewDelegate::ShowCreatedWidget(
+void InterstitialPageImpl::InterstitialPageRVHViewDelegate::ShowCreatedWidget(
int route_id, const gfx::Rect& initial_pos) {
NOTREACHED() << "InterstitialPage does not support showing drop-downs yet.";
}
-void
-InterstitialPage::InterstitialPageRVHViewDelegate::ShowCreatedFullscreenWidget(
- int route_id) {
+void InterstitialPageImpl::InterstitialPageRVHViewDelegate::
+ ShowCreatedFullscreenWidget(int route_id) {
NOTREACHED()
<< "InterstitialPage does not support showing full screen popups.";
}
-void InterstitialPage::InterstitialPageRVHViewDelegate::ShowContextMenu(
+void InterstitialPageImpl::InterstitialPageRVHViewDelegate::ShowContextMenu(
const ContextMenuParams& params) {
}
-void InterstitialPage::InterstitialPageRVHViewDelegate::ShowPopupMenu(
+void InterstitialPageImpl::InterstitialPageRVHViewDelegate::ShowPopupMenu(
const gfx::Rect& bounds,
int item_height,
double item_font_size,
@@ -700,7 +709,7 @@ void InterstitialPage::InterstitialPageRVHViewDelegate::ShowPopupMenu(
bool right_aligned) {
}
-void InterstitialPage::InterstitialPageRVHViewDelegate::StartDragging(
+void InterstitialPageImpl::InterstitialPageRVHViewDelegate::StartDragging(
const WebDropData& drop_data,
WebDragOperationsMask allowed_operations,
const SkBitmap& image,
@@ -708,15 +717,15 @@ void InterstitialPage::InterstitialPageRVHViewDelegate::StartDragging(
NOTREACHED() << "InterstitialPage does not support dragging yet.";
}
-void InterstitialPage::InterstitialPageRVHViewDelegate::UpdateDragCursor(
+void InterstitialPageImpl::InterstitialPageRVHViewDelegate::UpdateDragCursor(
WebDragOperation) {
NOTREACHED() << "InterstitialPage does not support dragging yet.";
}
-void InterstitialPage::InterstitialPageRVHViewDelegate::GotFocus() {
+void InterstitialPageImpl::InterstitialPageRVHViewDelegate::GotFocus() {
}
-void InterstitialPage::InterstitialPageRVHViewDelegate::TakeFocus(
+void InterstitialPageImpl::InterstitialPageRVHViewDelegate::TakeFocus(
bool reverse) {
if (!interstitial_page_->tab())
return;
@@ -727,7 +736,7 @@ void InterstitialPage::InterstitialPageRVHViewDelegate::TakeFocus(
tab->GetViewDelegate()->TakeFocus(reverse);
}
-void InterstitialPage::InterstitialPageRVHViewDelegate::OnFindReply(
+void InterstitialPageImpl::InterstitialPageRVHViewDelegate::OnFindReply(
int request_id, int number_of_matches, const gfx::Rect& selection_rect,
int active_match_ordinal, bool final_update) {
}
diff --git a/content/browser/tab_contents/interstitial_page.h b/content/browser/tab_contents/interstitial_page_impl.h
index 0b29713..ab4ad92 100644
--- a/content/browser/tab_contents/interstitial_page.h
+++ b/content/browser/tab_contents/interstitial_page_impl.h
@@ -2,52 +2,36 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_H_
-#define CONTENT_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_H_
+#ifndef CONTENT_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_IMPL_H_
+#define CONTENT_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_IMPL_H_
#pragma once
-#include <map>
-#include <string>
-
#include "base/memory/scoped_ptr.h"
#include "base/process_util.h"
-#include "content/common/content_export.h"
+#include "content/public/browser/interstitial_page.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/render_view_host_delegate.h"
#include "content/public/common/renderer_preferences.h"
#include "googleurl/src/gurl.h"
-#include "ui/gfx/size.h"
class TabContents;
namespace content {
-class InterstitialPageDelegate;
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
-// page. (Navigating to a page served over bad HTTPS or a page containing
-// malware are typical cases where an interstitial is required.)
-//
-// If specified in its constructor, this class creates a navigation entry so
-// that when the interstitial shows, the current entry is the target URL.
-//
-// InterstitialPage instances take care of deleting themselves when closed
-// through a navigation, the TabContents closing them or the tab containing them
-// being closed.
-
enum ResourceRequestAction {
BLOCK,
RESUME,
CANCEL
};
-class CONTENT_EXPORT InterstitialPage : public content::NotificationObserver,
- public content::RenderViewHostDelegate {
+class CONTENT_EXPORT InterstitialPageImpl
+ : public content::InterstitialPage,
+ public content::NotificationObserver,
+ public content::RenderViewHostDelegate {
public:
// The different state of actions the user can take in an interstitial.
enum ActionState {
@@ -56,60 +40,28 @@ class CONTENT_EXPORT InterstitialPage : public content::NotificationObserver,
DONT_PROCEED_ACTION // "Don't proceed" was selected.
};
- // Creates an interstitial page to show in |tab|. |new_navigation| should be
- // set to true when the interstitial is caused by loading a new page, in which
- // case a temporary navigation entry is created with the URL |url| and
- // added to the navigation controller (so the interstitial page appears as a
- // new navigation entry). |new_navigation| should be false when the
- // interstitial was triggered by a loading a sub-resource in a page.
- // Takes ownership of |delegate|.
- static InterstitialPage* Create(content::WebContents* tab,
- bool new_navigation,
- const GURL& url,
- content::InterstitialPageDelegate* delegate);
-
- InterstitialPage(content::WebContents* tab,
- bool new_navigation,
- const GURL& url,
- content::InterstitialPageDelegate* delegate);
- virtual ~InterstitialPage();
-
- // Shows the interstitial page in the tab.
- void Show();
-
- // Hides the interstitial page.
- void Hide();
-
- // Retrieves the InterstitialPage if any associated with the specified
- // |web_contents| (used by ui tests).
- static InterstitialPage* GetInterstitialPage(
- content::WebContents* web_contents);
-
- // Reverts to the page showing before the interstitial.
- // Sub-classes should call this method when the user has chosen NOT to proceed
- // to the target URL.
- // Warning: if |new_navigation| was set to true in the constructor, 'this'
- // will be deleted when this method returns.
- virtual void DontProceed();
-
- // Sub-classes should call this method when the user has chosen to proceed to
- // the target URL.
- // Warning: 'this' has been deleted when this method returns.
- virtual void Proceed();
+ InterstitialPageImpl(content::WebContents* tab,
+ bool new_navigation,
+ const GURL& url,
+ content::InterstitialPageDelegate* delegate);
+ virtual ~InterstitialPageImpl();
+
+ // InterstitialPage implementation:
+ virtual void Show() OVERRIDE;
+ virtual void Hide() OVERRIDE;
+ virtual void DontProceed() OVERRIDE;
+ virtual void Proceed() OVERRIDE;
+ virtual RenderViewHost* GetRenderViewHostForTesting() const OVERRIDE;
+ virtual content::InterstitialPageDelegate* GetDelegateForTesting() OVERRIDE;
+ virtual void DontCreateViewForTesting() OVERRIDE;
+ virtual void SetSize(const gfx::Size& size) OVERRIDE;
+ virtual void Focus() OVERRIDE;
// Allows the user to navigate away by disabling the interstitial, canceling
// the pending request, and unblocking the hidden renderer. The interstitial
// will stay visible until the navigation completes.
void CancelForNavigation();
- // Sizes the RenderViewHost showing the actual interstitial page contents.
- void SetSize(const gfx::Size& size);
-
- ActionState action_taken() const { return action_taken_; }
-
- // Sets the focus to the interstitial.
- void Focus();
-
// Focus the first (last if reverse is true) element in the interstitial page.
// Called when tab traversing.
void FocusThroughTabTraversal(bool reverse);
@@ -120,11 +72,6 @@ class CONTENT_EXPORT InterstitialPage : public content::NotificationObserver,
}
bool reload_on_dont_proceed() const { return reload_on_dont_proceed_; }
- RenderViewHost* render_view_host() const { return render_view_host_; }
-
- content::InterstitialPageDelegate* GetDelegateForTesting();
- void DontCreateViewForTesting();
-
protected:
// content::NotificationObserver method:
virtual void Observe(int type,
@@ -170,16 +117,8 @@ class CONTENT_EXPORT InterstitialPage : public content::NotificationObserver,
content::NotificationRegistrar notification_registrar_;
private:
- // AutomationProvider needs access to Proceed and DontProceed to simulate
- // user actions.
- friend class AutomationProvider;
-
class InterstitialPageRVHViewDelegate;
- // Initializes tab_to_interstitial_page_ in a thread-safe manner.
- // Should be called before accessing tab_to_interstitial_page_.
- static void InitInterstitialPageMap();
-
// Disable the interstitial:
// - if it is not yet showing, then it won't be shown.
// - any command sent by the RenderViewHost will be ignored.
@@ -244,11 +183,6 @@ class CONTENT_EXPORT InterstitialPage : public content::NotificationObserver,
// Our RenderViewHostViewDelegate, necessary for accelerators to work.
scoped_ptr<InterstitialPageRVHViewDelegate> rvh_view_delegate_;
- // We keep a map of the various blocking pages shown as the UI tests need to
- // be able to retrieve them.
- typedef std::map<TabContents*, InterstitialPage*> InterstitialPageMap;
- static InterstitialPageMap* tab_to_interstitial_page_;
-
// Settings passed to the renderer.
mutable content::RendererPreferences renderer_preferences_;
@@ -256,7 +190,7 @@ class CONTENT_EXPORT InterstitialPage : public content::NotificationObserver,
scoped_ptr<content::InterstitialPageDelegate> delegate_;
- DISALLOW_COPY_AND_ASSIGN(InterstitialPage);
+ DISALLOW_COPY_AND_ASSIGN(InterstitialPageImpl);
};
-#endif // CONTENT_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_H_
+#endif // CONTENT_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_IMPL_H_
diff --git a/content/browser/tab_contents/navigation_controller_impl.cc b/content/browser/tab_contents/navigation_controller_impl.cc
index eba3157..ac97791 100644
--- a/content/browser/tab_contents/navigation_controller_impl.cc
+++ b/content/browser/tab_contents/navigation_controller_impl.cc
@@ -16,7 +16,7 @@
#include "content/browser/renderer_host/render_view_host.h" // Temporary
#include "content/browser/site_instance_impl.h"
#include "content/browser/tab_contents/debug_urls.h"
-#include "content/browser/tab_contents/interstitial_page.h"
+#include "content/browser/tab_contents/interstitial_page_impl.h"
#include "content/browser/tab_contents/navigation_entry_impl.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/common/view_messages.h"
@@ -1142,7 +1142,8 @@ void NavigationControllerImpl::PruneAllButActive() {
// Normally the interstitial page hides itself if the user doesn't proceeed.
// This would result in showing a NavigationEntry we just removed. Set this
// so the interstitial triggers a reload if the user doesn't proceed.
- tab_contents_->GetInterstitialPage()->set_reload_on_dont_proceed(true);
+ static_cast<InterstitialPageImpl*>(tab_contents_->GetInterstitialPage())->
+ set_reload_on_dont_proceed(true);
}
}
@@ -1275,8 +1276,10 @@ void NavigationControllerImpl::NavigateToPendingEntry(ReloadType reload_type) {
// cannot make new requests. Unblock (and disable) it to allow this
// navigation to succeed. The interstitial will stay visible until the
// resulting DidNavigate.
- if (tab_contents_->GetInterstitialPage())
- tab_contents_->GetInterstitialPage()->CancelForNavigation();
+ if (tab_contents_->GetInterstitialPage()) {
+ static_cast<InterstitialPageImpl*>(tab_contents_->GetInterstitialPage())->
+ CancelForNavigation();
+ }
// For session history navigations only the pending_entry_index_ is set.
if (!pending_entry_) {
diff --git a/content/browser/tab_contents/render_view_host_manager.h b/content/browser/tab_contents/render_view_host_manager.h
index 027e2ce..b32fe7f 100644
--- a/content/browser/tab_contents/render_view_host_manager.h
+++ b/content/browser/tab_contents/render_view_host_manager.h
@@ -15,7 +15,7 @@
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/render_view_host_delegate.h"
-class InterstitialPage;
+class InterstitialPageImpl;
class NavigationControllerImpl;
class RenderViewHost;
class RenderWidgetHostView;
@@ -163,7 +163,7 @@ class CONTENT_EXPORT RenderViewHostManager
// |interstitial_page| should be non NULL (use the remove_interstitial_page
// method to unset the interstitial) and no interstitial page should be set
// when there is already a non NULL interstitial page set.
- void set_interstitial_page(InterstitialPage* interstitial_page) {
+ void set_interstitial_page(InterstitialPageImpl* interstitial_page) {
DCHECK(!interstitial_page_ && interstitial_page);
interstitial_page_ = interstitial_page;
}
@@ -176,7 +176,7 @@ class CONTENT_EXPORT RenderViewHostManager
// Returns the currently showing interstitial, NULL if no interstitial is
// showing.
- InterstitialPage* interstitial_page() const {
+ InterstitialPageImpl* interstitial_page() const {
return interstitial_page_;
}
@@ -285,7 +285,7 @@ class CONTENT_EXPORT RenderViewHostManager
// The intersitial page currently shown if any, not own by this class
// (the InterstitialPage is self-owned, it deletes itself when hidden).
- InterstitialPage* interstitial_page_;
+ InterstitialPageImpl* interstitial_page_;
content::NotificationRegistrar registrar_;
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 0df3703..f4cccc8 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -30,7 +30,7 @@
#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/browser/renderer_host/resource_request_details.h"
#include "content/browser/site_instance_impl.h"
-#include "content/browser/tab_contents/interstitial_page.h"
+#include "content/browser/tab_contents/interstitial_page_impl.h"
#include "content/browser/tab_contents/navigation_entry_impl.h"
#include "content/browser/tab_contents/provisional_load_details.h"
#include "content/browser/tab_contents/title_updated_details.h"
@@ -115,6 +115,7 @@ using content::DevToolsManagerImpl;
using content::DownloadItem;
using content::DownloadManager;
using content::GlobalRequestID;
+using content::InterstitialPage;
using content::NavigationController;
using content::NavigationEntry;
using content::NavigationEntryImpl;
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index aef97ef..baeb781 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -30,6 +30,7 @@
#include "base/win/scoped_handle.h"
#endif
+class InterstitialPageImpl;
class LoadNotificationDetails;
class RenderViewHost;
class SavePackage;
@@ -99,7 +100,7 @@ class CONTENT_EXPORT TabContents
// |interstitial_page| should be non NULL (use the remove_interstitial_page
// method to unset the interstitial) and no interstitial page should be set
// when there is already a non NULL interstitial page set.
- void set_interstitial_page(InterstitialPage* interstitial_page) {
+ void set_interstitial_page(InterstitialPageImpl* interstitial_page) {
render_manager_.set_interstitial_page(interstitial_page);
}
@@ -181,7 +182,7 @@ class CONTENT_EXPORT TabContents
virtual void Focus() OVERRIDE;
virtual void FocusThroughTabTraversal(bool reverse) OVERRIDE;
virtual bool ShowingInterstitialPage() const OVERRIDE;
- virtual InterstitialPage* GetInterstitialPage() const OVERRIDE;
+ virtual content::InterstitialPage* GetInterstitialPage() const OVERRIDE;
virtual bool IsSavable() OVERRIDE;
virtual void OnSavePage() OVERRIDE;
virtual bool SavePage(const FilePath& main_file,
@@ -367,8 +368,8 @@ class CONTENT_EXPORT TabContents
friend class TabContentsViewGtk;
#endif
- // So InterstitialPage can access SetIsLoading.
- friend class InterstitialPage;
+ // So InterstitialPageImpl can access SetIsLoading.
+ friend class InterstitialPageImpl;
// TODO(brettw) TestTabContents shouldn't exist!
friend class TestTabContents;
diff --git a/content/browser/tab_contents/tab_contents_unittest.cc b/content/browser/tab_contents/tab_contents_unittest.cc
index f5c5b59..2b465b2 100644
--- a/content/browser/tab_contents/tab_contents_unittest.cc
+++ b/content/browser/tab_contents/tab_contents_unittest.cc
@@ -9,7 +9,7 @@
#include "content/browser/renderer_host/render_widget_host_view.h"
#include "content/browser/renderer_host/test_render_view_host.h"
#include "content/browser/site_instance_impl.h"
-#include "content/browser/tab_contents/interstitial_page.h"
+#include "content/browser/tab_contents/interstitial_page_impl.h"
#include "content/browser/tab_contents/navigation_entry_impl.h"
#include "content/browser/tab_contents/test_tab_contents.h"
#include "content/common/view_messages.h"
@@ -29,6 +29,7 @@
using content::BrowserContext;
using content::BrowserThread;
+using content::InterstitialPage;
using content::NavigationEntry;
using content::NavigationEntryImpl;
using content::SiteInstance;
@@ -103,7 +104,7 @@ class TestInterstitialPageDelegate : public content::InterstitialPageDelegate {
TestInterstitialPage* interstitial_page_;
};
-class TestInterstitialPage : public InterstitialPage {
+class TestInterstitialPage : public InterstitialPageImpl {
public:
enum InterstitialState {
UNDECIDED = 0, // No decision taken yet.
@@ -134,7 +135,7 @@ class TestInterstitialPage : public InterstitialPage {
const GURL& url,
InterstitialState* state,
bool* deleted)
- : InterstitialPage(
+ : InterstitialPageImpl(
tab, new_navigation, url,
new TestInterstitialPageDelegate(this)),
state_(state),
@@ -173,16 +174,16 @@ class TestInterstitialPage : public InterstitialPage {
void TestDidNavigate(int page_id, const GURL& url) {
ViewHostMsg_FrameNavigate_Params params;
InitNavigateParams(&params, page_id, url, content::PAGE_TRANSITION_TYPED);
- DidNavigate(render_view_host(), params);
+ DidNavigate(GetRenderViewHostForTesting(), params);
}
void TestRenderViewGone(base::TerminationStatus status, int error_code) {
- RenderViewGone(render_view_host(), status, error_code);
+ RenderViewGone(GetRenderViewHostForTesting(), status, error_code);
}
bool is_showing() const {
- return static_cast<TestRenderWidgetHostView*>(render_view_host()->view())->
- is_showing();
+ return static_cast<TestRenderWidgetHostView*>(
+ GetRenderViewHostForTesting()->view())->is_showing();
}
void ClearStates() {
@@ -1891,5 +1892,6 @@ TEST_F(TabContentsTest, CopyStateFromAndPruneTargetInterstitial) {
EXPECT_TRUE(other_contents->ShowingInterstitialPage());
// And the interstitial should do a reload on don't proceed.
- EXPECT_TRUE(other_contents->GetInterstitialPage()->reload_on_dont_proceed());
+ EXPECT_TRUE(static_cast<InterstitialPageImpl*>(
+ other_contents->GetInterstitialPage())->reload_on_dont_proceed());
}
diff --git a/content/browser/tab_contents/tab_contents_view_gtk.cc b/content/browser/tab_contents/tab_contents_view_gtk.cc
index 49f3f76..1c0480b 100644
--- a/content/browser/tab_contents/tab_contents_view_gtk.cc
+++ b/content/browser/tab_contents/tab_contents_view_gtk.cc
@@ -16,7 +16,7 @@
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_view_host_factory.h"
#include "content/browser/renderer_host/render_widget_host_view_gtk.h"
-#include "content/browser/tab_contents/interstitial_page.h"
+#include "content/browser/tab_contents/interstitial_page_impl.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_view_wrapper_gtk.h"
#include "content/browser/tab_contents/web_drag_dest_gtk.h"
diff --git a/content/browser/tab_contents/tab_contents_view_win.cc b/content/browser/tab_contents/tab_contents_view_win.cc
index 38829ac..9ea043e 100644
--- a/content/browser/tab_contents/tab_contents_view_win.cc
+++ b/content/browser/tab_contents/tab_contents_view_win.cc
@@ -7,7 +7,7 @@
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_view_host_factory.h"
#include "content/browser/renderer_host/render_widget_host_view_win.h"
-#include "content/browser/tab_contents/interstitial_page.h"
+#include "content/browser/tab_contents/interstitial_page_impl.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/web_contents_delegate.h"
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 3d0ea4a..3e191b4 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -60,6 +60,7 @@
'public/browser/geolocation_permission_context.h',
'public/browser/global_request_id.h',
'public/browser/host_zoom_map.h',
+ 'public/browser/interstitial_page.h',
'public/browser/invalidate_type.h',
'public/browser/javascript_dialogs.h',
'public/browser/native_web_keyboard_event.h',
@@ -623,8 +624,8 @@
'browser/tab_contents/drag_utils_gtk.h',
'browser/tab_contents/debug_urls.cc',
'browser/tab_contents/debug_urls.h',
- 'browser/tab_contents/interstitial_page.cc',
- 'browser/tab_contents/interstitial_page.h',
+ 'browser/tab_contents/interstitial_page_impl.cc',
+ 'browser/tab_contents/interstitial_page_impl.h',
'browser/tab_contents/navigation_controller_impl.cc',
'browser/tab_contents/navigation_controller_impl.h',
'browser/tab_contents/navigation_entry_impl.cc',
diff --git a/content/public/browser/interstitial_page.h b/content/public/browser/interstitial_page.h
new file mode 100644
index 0000000..0e9a101
--- /dev/null
+++ b/content/public/browser/interstitial_page.h
@@ -0,0 +1,88 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_PUBLIC_BROWSER_INTERSTITIAL_PAGE_H_
+#define CONTENT_PUBLIC_BROWSER_INTERSTITIAL_PAGE_H_
+#pragma once
+
+#include "content/common/content_export.h"
+
+class GURL;
+class RenderViewHost;
+
+namespace gfx {
+class Size;
+}
+
+namespace content {
+
+class InterstitialPageDelegate;
+class WebContents;
+
+// This class is used for showing interstitial pages, pages that show some
+// informative message asking for user validation before reaching the target
+// page. (Navigating to a page served over bad HTTPS or a page containing
+// malware are typical cases where an interstitial is required.)
+//
+// If specified in the Create function, this class creates a navigation entry so
+// that when the interstitial shows, the current entry is the target URL.
+//
+// InterstitialPage instances take care of deleting themselves when closed
+// through a navigation, the WebContents closing them or the tab containing them
+// being closed.
+
+class InterstitialPage {
+ public:
+ // Creates an interstitial page to show in |tab|. |new_navigation| should be
+ // set to true when the interstitial is caused by loading a new page, in which
+ // case a temporary navigation entry is created with the URL |url| and added
+ // to the navigation controller (so the interstitial page appears as a new
+ // navigation entry). |new_navigation| should be false when the interstitial
+ // was triggered by a loading a sub-resource in a page. Takes ownership of
+ // |delegate|.
+ CONTENT_EXPORT static InterstitialPage* Create(
+ WebContents* tab,
+ bool new_navigation,
+ const GURL& url,
+ InterstitialPageDelegate* delegate);
+
+ // Retrieves the InterstitialPage if any associated with the specified
+ // |web_contents| (used by ui tests).
+ CONTENT_EXPORT static InterstitialPage* GetInterstitialPage(
+ WebContents* web_contents);
+
+ virtual ~InterstitialPage() {}
+
+ // Shows the interstitial page in the tab.
+ virtual void Show() = 0;
+
+ // Hides the interstitial page.
+ virtual void Hide() = 0;
+
+ // Reverts to the page showing before the interstitial.
+ // Delegates should call this method when the user has chosen NOT to proceed
+ // to the target URL.
+ // Warning: if |new_navigation| was set to true in the constructor, 'this'
+ // will be deleted when this method returns.
+ virtual void DontProceed() = 0;
+
+ // Delegates should call this method when the user has chosen to proceed to
+ // the target URL.
+ // Warning: 'this' has been deleted when this method returns.
+ virtual void Proceed() = 0;
+
+ // Sizes the RenderViewHost showing the actual interstitial page contents.
+ virtual void SetSize(const gfx::Size& size) = 0;
+
+ // Sets the focus to the interstitial.
+ virtual void Focus() = 0;
+
+ virtual RenderViewHost* GetRenderViewHostForTesting() const = 0;
+ virtual InterstitialPageDelegate* GetDelegateForTesting() = 0;
+ virtual void DontCreateViewForTesting() = 0;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_H_
diff --git a/content/public/browser/utility_process_host.h b/content/public/browser/utility_process_host.h
index a965b96..5320818 100644
--- a/content/public/browser/utility_process_host.h
+++ b/content/public/browser/utility_process_host.h
@@ -32,7 +32,7 @@ class UtilityProcessHost : public IPC::Message::Sender,
public base::SupportsWeakPtr<UtilityProcessHost> {
public:
// Used to create a utility process.
- static CONTENT_EXPORT UtilityProcessHost* Create(
+ CONTENT_EXPORT static UtilityProcessHost* Create(
UtilityProcessHostClient* client,
BrowserThread::ID client_thread_id);
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
index 2811e1df..898b436 100644
--- a/content/public/browser/web_contents.h
+++ b/content/public/browser/web_contents.h
@@ -17,7 +17,6 @@
#include "ui/gfx/native_widget_types.h"
#include "webkit/glue/window_open_disposition.h"
-class InterstitialPage;
class RenderViewHost;
class RenderWidgetHostView;
class SessionStorageNamespace;
@@ -39,6 +38,7 @@ struct LoadStateWithParam;
namespace content {
class BrowserContext;
+class InterstitialPage;
class NavigationController;
class RenderProcessHost;
class WebContentsDelegate;