Commit 948481d2 authored by nasko@chromium.org's avatar nasko@chromium.org

Ensure show/hide are properly called on interstitial pages if present.

In my CL for sending Show/Hide to all frames on a page (https://codereview.chromium.org/298283003), I used the RWH for each RenderFrameHost in the tree. This missed the fact that an interstitial page will be overlayed and not part of the frame tree in WebContents.

BUG=381439

Review URL: https://codereview.chromium.org/321253003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276463 0039d316-1c4b-4281-b951-d872f2087c98
parent 64dde5dc
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "content/public/browser/navigation_entry.h" #include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "content/public/common/security_style.h" #include "content/public/common/security_style.h"
...@@ -1750,6 +1751,31 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, InterstitialNotAffectedByContentSettings) { ...@@ -1750,6 +1751,31 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, InterstitialNotAffectedByContentSettings) {
ASSERT_TRUE(result); ASSERT_TRUE(result);
} }
// Verifies that switching tabs, while showing interstitial page, will not
// affect the visibility of the interestitial.
// https://crbug.com/381439
IN_PROC_BROWSER_TEST_F(SSLUITest, InterstitialNotAffectedByHideShow) {
ASSERT_TRUE(https_server_expired_.Start());
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing());
ui_test_utils::NavigateToURL(
browser(), https_server_expired_.GetURL("files/ssl/google.html"));
CheckAuthenticationBrokenState(
tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL);
EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing());
AddTabAtIndex(0,
https_server_.GetURL("files/ssl/google.html"),
content::PAGE_TRANSITION_TYPED);
EXPECT_EQ(2, browser()->tab_strip_model()->count());
EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
EXPECT_EQ(tab, browser()->tab_strip_model()->GetWebContentsAt(1));
EXPECT_FALSE(tab->GetRenderWidgetHostView()->IsShowing());
browser()->tab_strip_model()->ActivateTabAt(1, true);
EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing());
}
// TODO(jcampan): more tests to do below. // TODO(jcampan): more tests to do below.
// Visit a page over https that contains a frame with a redirect. // Visit a page over https that contains a frame with a redirect.
......
...@@ -219,10 +219,10 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { ...@@ -219,10 +219,10 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) {
{ {
// There should be only one RenderWidgetHost when there are no // There should be only one RenderWidgetHost when there are no
// cross-process iframes. // cross-process iframes.
std::set<RenderWidgetHostImpl*> widgets_set = std::set<RenderWidgetHostView*> views_set =
static_cast<WebContentsImpl*>(shell()->web_contents()) static_cast<WebContentsImpl*>(shell()->web_contents())
->GetRenderWidgetHostsInTree(); ->GetRenderWidgetHostViewsInTree();
EXPECT_EQ(1U, widgets_set.size()); EXPECT_EQ(1U, views_set.size());
} }
// These must stay in scope with replace_host. // These must stay in scope with replace_host.
...@@ -249,10 +249,10 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { ...@@ -249,10 +249,10 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) {
{ {
// There should be now two RenderWidgetHosts, one for each process // There should be now two RenderWidgetHosts, one for each process
// rendering a frame. // rendering a frame.
std::set<RenderWidgetHostImpl*> widgets_set = std::set<RenderWidgetHostView*> views_set =
static_cast<WebContentsImpl*>(shell()->web_contents()) static_cast<WebContentsImpl*>(shell()->web_contents())
->GetRenderWidgetHostsInTree(); ->GetRenderWidgetHostViewsInTree();
EXPECT_EQ(2U, widgets_set.size()); EXPECT_EQ(2U, views_set.size());
} }
// Load another cross-site page into the same iframe. // Load another cross-site page into the same iframe.
...@@ -279,10 +279,10 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { ...@@ -279,10 +279,10 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) {
child->current_frame_host()->GetProcess()); child->current_frame_host()->GetProcess());
EXPECT_NE(rph, child->current_frame_host()->GetProcess()); EXPECT_NE(rph, child->current_frame_host()->GetProcess());
{ {
std::set<RenderWidgetHostImpl*> widgets_set = std::set<RenderWidgetHostView*> views_set =
static_cast<WebContentsImpl*>(shell()->web_contents()) static_cast<WebContentsImpl*>(shell()->web_contents())
->GetRenderWidgetHostsInTree(); ->GetRenderWidgetHostViewsInTree();
EXPECT_EQ(2U, widgets_set.size()); EXPECT_EQ(2U, views_set.size());
} }
} }
......
...@@ -216,9 +216,13 @@ void SendToAllFramesInternal(IPC::Message* message, RenderFrameHost* rfh) { ...@@ -216,9 +216,13 @@ void SendToAllFramesInternal(IPC::Message* message, RenderFrameHost* rfh) {
rfh->Send(message_copy); rfh->Send(message_copy);
} }
void AddRenderWidgetHostToSet(std::set<RenderWidgetHostImpl*>* set, void AddRenderWidgetHostViewToSet(std::set<RenderWidgetHostView*>* set,
RenderFrameHost* rfh) { RenderFrameHost* rfh) {
set->insert(static_cast<RenderFrameHostImpl*>(rfh)->GetRenderWidgetHost()); RenderWidgetHostView* rwhv = static_cast<RenderFrameHostImpl*>(rfh)
->frame_tree_node()
->render_manager()
->GetRenderWidgetHostView();
set->insert(rwhv);
} }
} // namespace } // namespace
...@@ -941,15 +945,14 @@ base::TimeTicks WebContentsImpl::GetLastActiveTime() const { ...@@ -941,15 +945,14 @@ base::TimeTicks WebContentsImpl::GetLastActiveTime() const {
void WebContentsImpl::WasShown() { void WebContentsImpl::WasShown() {
controller_.SetActive(true); controller_.SetActive(true);
std::set<RenderWidgetHostImpl*> widgets = GetRenderWidgetHostsInTree(); std::set<RenderWidgetHostView*> widgets = GetRenderWidgetHostViewsInTree();
for (std::set<RenderWidgetHostImpl*>::iterator iter = widgets.begin(); for (std::set<RenderWidgetHostView*>::iterator iter = widgets.begin();
iter != widgets.end(); iter != widgets.end();
iter++) { iter++) {
RenderWidgetHostView* rwhv = (*iter)->GetView(); if (*iter) {
if (rwhv) { (*iter)->Show();
rwhv->Show();
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
rwhv->SetActive(true); (*iter)->SetActive(true);
#endif #endif
} }
} }
...@@ -979,13 +982,12 @@ void WebContentsImpl::WasHidden() { ...@@ -979,13 +982,12 @@ void WebContentsImpl::WasHidden() {
// removes the |GetRenderViewHost()|; then when we actually destroy the // removes the |GetRenderViewHost()|; then when we actually destroy the
// window, OnWindowPosChanged() notices and calls WasHidden() (which // window, OnWindowPosChanged() notices and calls WasHidden() (which
// calls us). // calls us).
std::set<RenderWidgetHostImpl*> widgets = GetRenderWidgetHostsInTree(); std::set<RenderWidgetHostView*> widgets = GetRenderWidgetHostViewsInTree();
for (std::set<RenderWidgetHostImpl*>::iterator iter = widgets.begin(); for (std::set<RenderWidgetHostView*>::iterator iter = widgets.begin();
iter != widgets.end(); iter != widgets.end();
iter++) { iter++) {
RenderWidgetHostView* rwhv = (*iter)->GetView(); if (*iter)
if (rwhv) (*iter)->Hide();
rwhv->Hide();
} }
} }
...@@ -1142,9 +1144,15 @@ void WebContentsImpl::RemoveObserver(WebContentsObserver* observer) { ...@@ -1142,9 +1144,15 @@ void WebContentsImpl::RemoveObserver(WebContentsObserver* observer) {
observers_.RemoveObserver(observer); observers_.RemoveObserver(observer);
} }
std::set<RenderWidgetHostImpl*> WebContentsImpl::GetRenderWidgetHostsInTree() { std::set<RenderWidgetHostView*>
std::set<RenderWidgetHostImpl*> set; WebContentsImpl::GetRenderWidgetHostViewsInTree() {
ForEachFrame(base::Bind(&AddRenderWidgetHostToSet, base::Unretained(&set))); std::set<RenderWidgetHostView*> set;
if (ShowingInterstitialPage()) {
set.insert(GetRenderWidgetHostView());
} else {
ForEachFrame(
base::Bind(&AddRenderWidgetHostViewToSet, base::Unretained(&set)));
}
return set; return set;
} }
......
...@@ -673,8 +673,8 @@ class CONTENT_EXPORT WebContentsImpl ...@@ -673,8 +673,8 @@ class CONTENT_EXPORT WebContentsImpl
void RemoveDestructionObserver(WebContentsImpl* web_contents); void RemoveDestructionObserver(WebContentsImpl* web_contents);
// Traverses all the RenderFrameHosts in the FrameTree and creates a set // Traverses all the RenderFrameHosts in the FrameTree and creates a set
// all the unique RenderWidgetHosts. // all the unique RenderWidgetHostViews.
std::set<RenderWidgetHostImpl*> GetRenderWidgetHostsInTree(); std::set<RenderWidgetHostView*> GetRenderWidgetHostViewsInTree();
// Callback function when showing JavaScript dialogs. Takes in a routing ID // Callback function when showing JavaScript dialogs. Takes in a routing ID
// pair to identify the RenderFrameHost that opened the dialog, because it's // pair to identify the RenderFrameHost that opened the dialog, because it's
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment