Commit b7a97ae2 authored by Sophie Chang's avatar Sophie Chang Committed by Commit Bot

Always show infobar for https if not seen

Bug: 969558
Change-Id: I1ccb9489e4cc263140950a67fad3b7b03b3a0684
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1743108
Commit-Queue: Sophie Chang <sophiechang@chromium.org>
Reviewed-by: default avatarRobert Ogden <robertogden@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685453}
parent 433c87aa
...@@ -154,7 +154,6 @@ bool ShouldAllowRedirectPreview(content::NavigationHandle* navigation_handle) { ...@@ -154,7 +154,6 @@ bool ShouldAllowRedirectPreview(content::NavigationHandle* navigation_handle) {
// This should always be at the end, but before the control group check. // This should always be at the end, but before the control group check.
if (decider->NeedsToNotifyUser()) { if (decider->NeedsToNotifyUser()) {
decider->NotifyUser(web_contents);
PreviewsLitePageNavigationThrottle::LogIneligibleReason( PreviewsLitePageNavigationThrottle::LogIneligibleReason(
PreviewsLitePageNavigationThrottle::IneligibleReason::kInfoBarNotSeen); PreviewsLitePageNavigationThrottle::IneligibleReason::kInfoBarNotSeen);
return false; return false;
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "components/network_time/network_time_tracker.h" #include "components/network_time/network_time_tracker.h"
#include "components/offline_pages/buildflags/buildflags.h" #include "components/offline_pages/buildflags/buildflags.h"
#include "components/offline_pages/core/offline_page_item.h" #include "components/offline_pages/core/offline_page_item.h"
#include "components/optimization_guide/optimization_guide_features.h"
#include "components/previews/content/previews_decider_impl.h" #include "components/previews/content/previews_decider_impl.h"
#include "components/previews/content/previews_ui_service.h" #include "components/previews/content/previews_ui_service.h"
#include "components/previews/core/previews_experiments.h" #include "components/previews/core/previews_experiments.h"
...@@ -251,9 +250,9 @@ void PreviewsUITabHelper::MaybeRecordPreviewReload( ...@@ -251,9 +250,9 @@ void PreviewsUITabHelper::MaybeRecordPreviewReload(
} }
} }
void PreviewsUITabHelper::MaybeShowInfoBarForHintsFetcher() { void PreviewsUITabHelper::MaybeShowInfoBar(
if (!base::FeatureList::IsEnabled( content::NavigationHandle* navigation_handle) {
optimization_guide::features::kOptimizationHintsFetching)) if (!navigation_handle->GetURL().SchemeIsHTTPOrHTTPS())
return; return;
PreviewsService* previews_service = PreviewsServiceFactory::GetForProfile( PreviewsService* previews_service = PreviewsServiceFactory::GetForProfile(
...@@ -287,7 +286,7 @@ void PreviewsUITabHelper::DidStartNavigation( ...@@ -287,7 +286,7 @@ void PreviewsUITabHelper::DidStartNavigation(
DataSaverTopHostProvider::MaybeUpdateTopHostBlacklist(navigation_handle); DataSaverTopHostProvider::MaybeUpdateTopHostBlacklist(navigation_handle);
MaybeShowInfoBarForHintsFetcher(); MaybeShowInfoBar(navigation_handle);
} }
void PreviewsUITabHelper::DidFinishNavigation( void PreviewsUITabHelper::DidFinishNavigation(
......
...@@ -136,8 +136,8 @@ class PreviewsUITabHelper ...@@ -136,8 +136,8 @@ class PreviewsUITabHelper
void MaybeRecordPreviewReload(content::NavigationHandle* navigation_handle); void MaybeRecordPreviewReload(content::NavigationHandle* navigation_handle);
// Show the user the Infobar if they need to be to notified that Lite mode // Show the user the Infobar if they need to be to notified that Lite mode
// now optimizes HTTPS pages when HintsFetcher is enabled. // now optimizes HTTPS pages.
void MaybeShowInfoBarForHintsFetcher(); void MaybeShowInfoBar(content::NavigationHandle* navigation_handle);
// True if the UI for a preview has been shown for the page. // True if the UI for a preview has been shown for the page.
bool displayed_preview_ui_ = false; bool displayed_preview_ui_ = false;
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "components/offline_pages/buildflags/buildflags.h" #include "components/offline_pages/buildflags/buildflags.h"
#include "components/offline_pages/core/offline_page_item.h" #include "components/offline_pages/core/offline_page_item.h"
#include "components/offline_pages/core/request_header/offline_page_header.h" #include "components/offline_pages/core/request_header/offline_page_header.h"
#include "components/optimization_guide/optimization_guide_features.h"
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "components/previews/content/previews_user_data.h" #include "components/previews/content/previews_user_data.h"
#include "components/previews/core/previews_features.h" #include "components/previews/core/previews_features.h"
...@@ -376,11 +375,7 @@ TEST_F(PreviewsUITabHelperUnitTest, TestReloadWithoutPreviewsDeferAllScript) { ...@@ -376,11 +375,7 @@ TEST_F(PreviewsUITabHelperUnitTest, TestReloadWithoutPreviewsDeferAllScript) {
EXPECT_TRUE(transition_type & ui::PAGE_TRANSITION_RELOAD); EXPECT_TRUE(transition_type & ui::PAGE_TRANSITION_RELOAD);
} }
TEST_F(PreviewsUITabHelperUnitTest, TestInfoBarShownOnHintsFetcherEnabled) { TEST_F(PreviewsUITabHelperUnitTest, TestInfoBarShownOnlyWhenNotSeen) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitWithFeatures(
{optimization_guide::features::kOptimizationHintsFetching}, {});
data_reduction_proxy::DataReductionProxySettings:: data_reduction_proxy::DataReductionProxySettings::
SetDataSaverEnabledForTesting(drp_test_context_->pref_service(), true); SetDataSaverEnabledForTesting(drp_test_context_->pref_service(), true);
...@@ -396,20 +391,3 @@ TEST_F(PreviewsUITabHelperUnitTest, TestInfoBarShownOnHintsFetcherEnabled) { ...@@ -396,20 +391,3 @@ TEST_F(PreviewsUITabHelperUnitTest, TestInfoBarShownOnHintsFetcherEnabled) {
content::WebContentsTester::For(web_contents())->NavigateAndCommit(test_url); content::WebContentsTester::For(web_contents())->NavigateAndCommit(test_url);
EXPECT_FALSE(decider->NeedsToNotifyUser()); EXPECT_FALSE(decider->NeedsToNotifyUser());
} }
TEST_F(PreviewsUITabHelperUnitTest, TestInfoBarNotShownOnHintsFetcherDisabled) {
data_reduction_proxy::DataReductionProxySettings::
SetDataSaverEnabledForTesting(drp_test_context_->pref_service(), true);
PreviewsService* previews_service = PreviewsServiceFactory::GetForProfile(
Profile::FromBrowserContext(web_contents()->GetBrowserContext()));
PreviewsHTTPSNotificationInfoBarDecider* decider =
previews_service->previews_https_notification_infobar_decider();
EXPECT_TRUE(decider->NeedsToNotifyUser());
GURL test_url("https://tribbles.com");
content::WebContentsTester::For(web_contents())->NavigateAndCommit(test_url);
EXPECT_TRUE(decider->NeedsToNotifyUser());
}
...@@ -343,9 +343,6 @@ void PreviewsOptimizationGuide::OnHintsUpdated( ...@@ -343,9 +343,6 @@ void PreviewsOptimizationGuide::OnHintsUpdated(
// If the client is eligible to fetch hints, currently controlled by a feature // If the client is eligible to fetch hints, currently controlled by a feature
// flag |kOptimizationHintsFetching|, fetch hints from the remote Optimization // flag |kOptimizationHintsFetching|, fetch hints from the remote Optimization
// Guide Service. // Guide Service.
//
// TODO(mcrouse): Add a check if Infobar notification needs to be shown to the
// user.
if (!data_reduction_proxy::DataReductionProxySettings:: if (!data_reduction_proxy::DataReductionProxySettings::
IsDataSaverEnabledByUser(pref_service_)) { IsDataSaverEnabledByUser(pref_service_)) {
return; return;
......
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