Commit ab68fc91 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

views: only hide page info bubble on user navigations

Otherwise, the page info bubble hides when an iframe on the page navigates,
which happens dozens of times on some JS-heavy pages, or when the page navigates
itself using a meta-refresh or similar.

Bug: 788301
Change-Id: I10e4676bc3e0b4c688e5e435d243799a831c5bc3
Reviewed-on: https://chromium-review.googlesource.com/793230Reviewed-by: default avatarRaymes Khoury <raymes@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524383}
parent d702c900
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/page_info/page_info_dialog.h" #include "chrome/browser/ui/page_info/page_info_dialog.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "ui/base/ui_features.h" #include "ui/base/ui_features.h"
#include "ui/views/view.h" #include "ui/views/view.h"
...@@ -87,5 +88,6 @@ void PageInfoBubbleViewBase::WasHidden() { ...@@ -87,5 +88,6 @@ void PageInfoBubbleViewBase::WasHidden() {
void PageInfoBubbleViewBase::DidStartNavigation( void PageInfoBubbleViewBase::DidStartNavigation(
content::NavigationHandle* handle) { content::NavigationHandle* handle) {
GetWidget()->Close(); if (handle->IsInMainFrame())
GetWidget()->Close();
} }
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "components/content_settings/core/browser/content_settings_registry.h" #include "components/content_settings/core/browser/content_settings_registry.h"
#include "components/content_settings/core/common/content_settings_types.h" #include "components/content_settings/core/common/content_settings_types.h"
#include "components/safe_browsing/features.h" #include "components/safe_browsing/features.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
...@@ -228,6 +229,19 @@ class PageInfoBubbleViewBrowserTest : public DialogBrowserTest { ...@@ -228,6 +229,19 @@ class PageInfoBubbleViewBrowserTest : public DialogBrowserTest {
} }
} }
protected:
GURL GetSimplePageUrl() const {
return ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath(FILE_PATH_LITERAL("simple.html")));
}
GURL GetIframePageUrl() const {
return ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath(FILE_PATH_LITERAL("iframe_blank.html")));
}
private: private:
base::test::ScopedFeatureList softer_warning_feature_; base::test::ScopedFeatureList softer_warning_feature_;
...@@ -467,3 +481,46 @@ IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, ...@@ -467,3 +481,46 @@ IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
InvokeDialog_BlockAllPermissions) { InvokeDialog_BlockAllPermissions) {
RunDialog(); RunDialog();
} }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
ClosesOnUserNavigateToSamePage) {
ui_test_utils::NavigateToURL(browser(), GetSimplePageUrl());
EXPECT_EQ(PageInfoBubbleView::BUBBLE_NONE,
PageInfoBubbleView::GetShownBubbleType());
OpenPageInfoBubble(browser());
EXPECT_EQ(PageInfoBubbleView::BUBBLE_PAGE_INFO,
PageInfoBubbleView::GetShownBubbleType());
ui_test_utils::NavigateToURL(browser(), GetSimplePageUrl());
EXPECT_EQ(PageInfoBubbleView::BUBBLE_NONE,
PageInfoBubbleView::GetShownBubbleType());
}
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
ClosesOnUserNavigateToDifferentPage) {
ui_test_utils::NavigateToURL(browser(), GetSimplePageUrl());
EXPECT_EQ(PageInfoBubbleView::BUBBLE_NONE,
PageInfoBubbleView::GetShownBubbleType());
OpenPageInfoBubble(browser());
EXPECT_EQ(PageInfoBubbleView::BUBBLE_PAGE_INFO,
PageInfoBubbleView::GetShownBubbleType());
ui_test_utils::NavigateToURL(browser(), GetIframePageUrl());
EXPECT_EQ(PageInfoBubbleView::BUBBLE_NONE,
PageInfoBubbleView::GetShownBubbleType());
}
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
DoesntCloseOnSubframeNavigate) {
ui_test_utils::NavigateToURL(browser(), GetIframePageUrl());
EXPECT_EQ(PageInfoBubbleView::BUBBLE_NONE,
PageInfoBubbleView::GetShownBubbleType());
OpenPageInfoBubble(browser());
EXPECT_EQ(PageInfoBubbleView::BUBBLE_PAGE_INFO,
PageInfoBubbleView::GetShownBubbleType());
content::NavigateIframeToURL(
browser()->tab_strip_model()->GetActiveWebContents(), "test",
GetSimplePageUrl());
// Expect that the bubble is still open even after a subframe navigation has
// happened.
EXPECT_EQ(PageInfoBubbleView::BUBBLE_PAGE_INFO,
PageInfoBubbleView::GetShownBubbleType());
}
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