Commit 5e196a51 authored by Charles Harrison's avatar Charles Harrison Committed by Commit Bot

[tab_under] Hook into the new desktop UI

This doesn't properly plumb through the click closure, which might need
some rethinking since we share the UI with framebusting.

Bug: 661629
Change-Id: I8a38140eee2f314e98183fc0874af94dda15a626
Reviewed-on: https://chromium-review.googlesource.com/763909
Commit-Queue: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarPatrick Monette <pmonette@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521442}
parent 72308c8f
......@@ -18,6 +18,7 @@
#include "base/test/simple_test_tick_clock.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/ui/blocked_content/popup_tracker.h"
#include "chrome/browser/ui/blocked_content/tab_under_navigation_throttle.h"
......@@ -37,7 +38,9 @@
#if defined(OS_ANDROID)
#include "chrome/browser/ui/android/infobars/infobar_android.h"
#endif // defined(OS_ANDROID)
#else
#include "chrome/browser/ui/blocked_content/framebust_block_tab_helper.h"
#endif
class InfoBarAndroid;
......@@ -58,6 +61,10 @@ class PopupOpenerTabHelperTest : public ChromeRenderViewHostTestHarness {
PopupOpenerTabHelper::CreateForWebContents(web_contents(),
std::move(tick_clock));
InfoBarService::CreateForWebContents(web_contents());
TabSpecificContentSettings::CreateForWebContents(web_contents());
#if !defined(OS_ANDROID)
FramebustBlockTabHelper::CreateForWebContents(web_contents());
#endif
// The tick clock needs to be advanced manually so it isn't set to null,
// which the code uses to determine if it is set yet.
......@@ -344,7 +351,10 @@ class BlockTabUnderTest : public PopupOpenerTabHelperTest {
void ExpectUIShown(bool shown) {
#if defined(OS_ANDROID)
EXPECT_EQ(shown, !!GetInfoBar());
#endif // defined(OS_ANDROID)
#else
EXPECT_EQ(shown, FramebustBlockTabHelper::FromWebContents(web_contents())
->HasBlockedUrls());
#endif
}
// content::WebContentsDelegate:
......@@ -489,7 +499,13 @@ TEST_F(BlockTabUnderTest, TabUnderWithSubsequentGesture_IsNotBlocked) {
// A subsequent navigation should be allowed, even if it is classified as a
// suspicious redirect.
EXPECT_TRUE(NavigateAndCommitWithoutGesture(GURL("https://example.test2/")));
#if defined(OS_ANDROID)
ExpectUIShown(false);
#else
EXPECT_EQ(1u, FramebustBlockTabHelper::FromWebContents(web_contents())
->blocked_urls()
.size());
#endif
}
TEST_F(BlockTabUnderTest, MultipleRedirectAttempts_AreBlocked) {
......
......@@ -15,6 +15,7 @@
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/ui/blocked_content/popup_opener_tab_helper.h"
#include "components/rappor/public/rappor_parameters.h"
#include "components/rappor/public/rappor_utils.h"
......@@ -22,6 +23,7 @@
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/console_message_level.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
......@@ -87,8 +89,13 @@ void ShowUI(content::WebContents* web_contents, const GURL& url) {
web_contents, base::MakeUnique<FramebustBlockMessageDelegate>(
web_contents, url, base::BindOnce(&LogOutcome)));
#else
NOTIMPLEMENTED() << "The BlockTabUnders experiment does not currently have a "
"UI implemented on desktop platforms.";
// TODO(csharrison): Instrument click-through metrics. This may be a bit
// difficult and requires attribution since this UI surface is shared with
// framebusting.
TabSpecificContentSettings* content_settings =
TabSpecificContentSettings::FromWebContents(web_contents);
DCHECK(content_settings);
content_settings->OnFramebustBlocked(url);
#endif
}
......
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