Commit cd283b08 authored by meacer's avatar meacer Committed by Commit Bot

[SB Delayed Warnings] Ignore Chrome Custom Tabs

SafeBrowsing Delayed Warnings experiment is implemented to measure how
URL display changes in the omnibox affect phishing rate. The URL display
changes hide parts of the URL in the omnibox. Since Chrome Custom Tabs
already shows only the hostname, we don't need to delay warnings that
happen in CCT.

Bug: 1113383
Change-Id: Id71f185812dbd4c8106d7c6bbc578505d0bdf2ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2372777
Commit-Queue: Mustafa Emre Acer <meacer@chromium.org>
Reviewed-by: default avatarElla Ge <eirage@chromium.org>
Reviewed-by: default avatarVarun Khaneja <vakh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801197}
parent 9666ea61
...@@ -38,7 +38,6 @@ import org.chromium.chrome.browser.flags.ChromeFeatureList; ...@@ -38,7 +38,6 @@ import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.Features.DisableFeatures; import org.chromium.chrome.test.util.browser.Features.DisableFeatures;
import org.chromium.chrome.test.util.browser.Features.EnableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
import org.chromium.components.embedder_support.util.Origin; import org.chromium.components.embedder_support.util.Origin;
...@@ -61,6 +60,7 @@ import java.util.concurrent.TimeoutException; ...@@ -61,6 +60,7 @@ import java.util.concurrent.TimeoutException;
/** Tests for detached resource requests. */ /** Tests for detached resource requests. */
@RunWith(ChromeJUnit4ClassRunner.class) @RunWith(ChromeJUnit4ClassRunner.class)
@EnableFeatures(ChromeFeatureList.SAFE_BROWSING_DELAYED_WARNINGS)
public class DetachedResourceRequestTest { public class DetachedResourceRequestTest {
@Rule @Rule
public CustomTabActivityTestRule mCustomTabActivityTestRule = new CustomTabActivityTestRule(); public CustomTabActivityTestRule mCustomTabActivityTestRule = new CustomTabActivityTestRule();
...@@ -315,11 +315,9 @@ public class DetachedResourceRequestTest { ...@@ -315,11 +315,9 @@ public class DetachedResourceRequestTest {
*/ */
@Test @Test
@SmallTest @SmallTest
@DisableFeatures({ChromeFeatureList.SPLIT_CACHE_BY_NETWORK_ISOLATION_KEY, @DisableFeatures(ChromeFeatureList.SPLIT_CACHE_BY_NETWORK_ISOLATION_KEY)
ChromeFeatureList.SAFE_BROWSING_DELAYED_WARNINGS})
public void public void testSafeBrowsingMainResource() throws Exception {
testSafeBrowsingMainResource() throws Exception {
testSafeBrowsingMainResource(true /* afterNative */, false /* splitCacheEnabled */); testSafeBrowsingMainResource(true /* afterNative */, false /* splitCacheEnabled */);
} }
...@@ -330,7 +328,6 @@ public class DetachedResourceRequestTest { ...@@ -330,7 +328,6 @@ public class DetachedResourceRequestTest {
@Test @Test
@SmallTest @SmallTest
@EnableFeatures(ChromeFeatureList.SPLIT_CACHE_BY_NETWORK_ISOLATION_KEY) @EnableFeatures(ChromeFeatureList.SPLIT_CACHE_BY_NETWORK_ISOLATION_KEY)
@DisableFeatures(ChromeFeatureList.SAFE_BROWSING_DELAYED_WARNINGS)
public void testSafeBrowsingMainResourceWithSplitCache() throws Exception { public void testSafeBrowsingMainResourceWithSplitCache() throws Exception {
testSafeBrowsingMainResource(true /* afterNative */, true /* splitCacheEnabled */); testSafeBrowsingMainResource(true /* afterNative */, true /* splitCacheEnabled */);
} }
...@@ -341,7 +338,6 @@ public class DetachedResourceRequestTest { ...@@ -341,7 +338,6 @@ public class DetachedResourceRequestTest {
*/ */
@Test @Test
@SmallTest @SmallTest
@DisableFeatures({ChromeFeatureList.SAFE_BROWSING_DELAYED_WARNINGS})
public void testSafeBrowsingSubresource() throws Exception { public void testSafeBrowsingSubresource() throws Exception {
testSafeBrowsingSubresource(true); testSafeBrowsingSubresource(true);
} }
...@@ -352,10 +348,8 @@ public class DetachedResourceRequestTest { ...@@ -352,10 +348,8 @@ public class DetachedResourceRequestTest {
*/ */
@Test @Test
@SmallTest @SmallTest
@DisableFeatures({ChromeFeatureList.SPLIT_CACHE_BY_NETWORK_ISOLATION_KEY, @DisableFeatures(ChromeFeatureList.SPLIT_CACHE_BY_NETWORK_ISOLATION_KEY)
ChromeFeatureList.SAFE_BROWSING_DELAYED_WARNINGS}) public void testSafeBrowsingMainResourceBeforeNative() throws Exception {
public void
testSafeBrowsingMainResourceBeforeNative() throws Exception {
testSafeBrowsingMainResource(false /* afterNative */, false /* splitCacheEnabled */); testSafeBrowsingMainResource(false /* afterNative */, false /* splitCacheEnabled */);
} }
...@@ -365,7 +359,6 @@ public class DetachedResourceRequestTest { ...@@ -365,7 +359,6 @@ public class DetachedResourceRequestTest {
*/ */
@Test @Test
@SmallTest @SmallTest
@Features.DisableFeatures({ChromeFeatureList.SAFE_BROWSING_DELAYED_WARNINGS})
public void testSafeBrowsingSubresourceBeforeNative() throws Exception { public void testSafeBrowsingSubresourceBeforeNative() throws Exception {
testSafeBrowsingSubresource(false); testSafeBrowsingSubresource(false);
} }
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/android/customtabs/client_data_header_web_contents_observer.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/prerender/chrome_prerender_contents_delegate.h" #include "chrome/browser/prerender/chrome_prerender_contents_delegate.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -26,6 +28,10 @@ ...@@ -26,6 +28,10 @@
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
#if defined(OS_ANDROID)
#include "chrome/browser/android/tab_android.h"
#endif
namespace safe_browsing { namespace safe_browsing {
namespace { namespace {
...@@ -56,6 +62,14 @@ void CreateSafeBrowsingUserInteractionObserver( ...@@ -56,6 +62,14 @@ void CreateSafeBrowsingUserInteractionObserver(
SafeBrowsingUIManager::StartDisplayingBlockingPage(ui_manager, resource); SafeBrowsingUIManager::StartDisplayingBlockingPage(ui_manager, resource);
return; return;
} }
#if defined(OS_ANDROID)
// Don't delay the interstitial for Chrome Custom Tabs.
auto* tab_android = TabAndroid::FromWebContents(web_contents);
if (tab_android && tab_android->IsCustomTab()) {
SafeBrowsingUIManager::StartDisplayingBlockingPage(ui_manager, resource);
return;
}
#endif
SafeBrowsingUserInteractionObserver::CreateForWebContents( SafeBrowsingUserInteractionObserver::CreateForWebContents(
web_contents, resource, is_main_frame, ui_manager); web_contents, resource, is_main_frame, ui_manager);
} }
......
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