Commit 3ee1c1d5 authored by Robert Ogden's avatar Robert Ogden Committed by Commit Bot

HTTPS Previews: Add a cmd line flag to not require the InfoBar

Needed for testing so that we can reliably trigger in cases where we
normally would have needed to show the HTTPS Previews Notification
Infobar first.

Bug: 908491
Change-Id: I83c3ca2bf41de24e5926128804ab523f77608e18
Reviewed-on: https://chromium-review.googlesource.com/c/1352975
Commit-Queue: Robert Ogden <robertogden@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611843}
parent 6fad75ff
......@@ -344,6 +344,10 @@ void PreviewsLitePageDecider::ReportDataSavings(int64_t network_bytes,
bool PreviewsLitePageDecider::NeedsToNotifyUser() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
previews::switches::kDoNotRequireLitePageRedirectInfoBar)) {
return false;
}
return need_to_show_notification_;
}
......
......@@ -6,6 +6,7 @@
#include <memory>
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/scoped_task_environment.h"
#include "base/test/simple_test_tick_clock.h"
......@@ -17,6 +18,7 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h"
#include "components/previews/core/previews_switches.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents.h"
......@@ -231,6 +233,20 @@ TEST_F(PreviewsLitePageDeciderPrefTest, TestDRPEnabled) {
EXPECT_TRUE(manager->NeedsToNotifyUser());
}
TEST_F(PreviewsLitePageDeciderPrefTest, TestDRPEnabledCmdLineIgnored) {
PreviewsLitePageNavigationThrottleManager* manager =
GetManagerWithDRPEnabled(true);
base::CommandLine::ForCurrentProcess()->AppendSwitch(
previews::switches::kDoNotRequireLitePageRedirectInfoBar);
EXPECT_FALSE(manager->NeedsToNotifyUser());
content::WebContentsTester::For(web_contents())
->NavigateAndCommit(GURL(kTestUrl));
// Should still be false after a navigation.
EXPECT_FALSE(manager->NeedsToNotifyUser());
}
TEST_F(PreviewsLitePageDeciderPrefTest, TestDRPEnabledThenNotify) {
PreviewsLitePageNavigationThrottleManager* manager =
GetManagerWithDRPEnabled(true);
......
......@@ -7,6 +7,11 @@
namespace previews {
namespace switches {
// Do not require the user notification InfoBar to be shown before triggering a
// Lite Page Redirect preview.
const char kDoNotRequireLitePageRedirectInfoBar[] =
"dont-require-litepage-redirect-infobar";
// Ignore decisions made by PreviewsBlackList.
const char kIgnorePreviewsBlacklist[] = "ignore-previews-blacklist";
......
......@@ -8,6 +8,7 @@
namespace previews {
namespace switches {
extern const char kDoNotRequireLitePageRedirectInfoBar[];
extern const char kIgnorePreviewsBlacklist[];
extern const char kLitePageServerPreviewHost[];
extern const char kIgnoreLitePageRedirectOptimizationBlacklist[];
......
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