Commit 31e23637 authored by Carlos IL's avatar Carlos IL Committed by Commit Bot

Cleanup kSupervisedUserCommittedInterstitials flag.

Feature launched in M70, and has been default enabled since, this CL
removes the flag from Chrome's code, and the switch from
chrome://flags

Bug: 936008
Change-Id: I57772ccc041b137255e39b220777e739d72c9789
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1644788
Commit-Queue: Carlos IL <carlosil@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Reviewed-by: default avatarHenrique Grandinetti <hgrandinetti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#667233}
parent 8f0b748a
...@@ -2939,12 +2939,6 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -2939,12 +2939,6 @@ const FeatureEntry kFeatureEntries[] = {
FEATURE_VALUE_TYPE(features::kViewsCastDialog)}, FEATURE_VALUE_TYPE(features::kViewsCastDialog)},
#endif // defined(TOOLKIT_VIEWS) #endif // defined(TOOLKIT_VIEWS)
{"SupervisedUserCommittedInterstitials",
flag_descriptions::kSupervisedUserCommittedInterstitialsName,
flag_descriptions::kSupervisedUserCommittedInterstitialsDescription,
kOsAll,
FEATURE_VALUE_TYPE(features::kSupervisedUserCommittedInterstitials)},
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
{"enable-horizontal-tab-switcher", {"enable-horizontal-tab-switcher",
flag_descriptions::kHorizontalTabSwitcherAndroidName, flag_descriptions::kHorizontalTabSwitcherAndroidName,
......
...@@ -128,16 +128,10 @@ void AddCompleteFileTypeInfo( ...@@ -128,16 +128,10 @@ void AddCompleteFileTypeInfo(
// error pages (failed DNS lookups, SSL errors, etc), which shouldn't affect // error pages (failed DNS lookups, SSL errors, etc), which shouldn't affect
// functionality. // functionality.
bool IsErrorPage(content::WebContents* web_contents) { bool IsErrorPage(content::WebContents* web_contents) {
if (base::FeatureList::IsEnabled( if (web_contents->GetController().GetActiveEntry() == NULL)
features::kSupervisedUserCommittedInterstitials)) { return false;
if (web_contents->GetController().GetActiveEntry() == NULL) return web_contents->GetController().GetLastCommittedEntry()->GetPageType() ==
return false; content::PAGE_TYPE_ERROR;
return web_contents->GetController()
.GetLastCommittedEntry()
->GetPageType() == content::PAGE_TYPE_ERROR;
}
// Fallback if someone ever disables committed interstitials.
return web_contents->ShowingInterstitialPage();
} }
} // anonymous namespace } // anonymous namespace
......
...@@ -1657,12 +1657,6 @@ const char kHistoryManipulationInterventionDescription[] = ...@@ -1657,12 +1657,6 @@ const char kHistoryManipulationInterventionDescription[] =
"If a page does a client side redirect or adds to the history without a " "If a page does a client side redirect or adds to the history without a "
"user gesture, then skip it on back/forward UI."; "user gesture, then skip it on back/forward UI.";
const char kSupervisedUserCommittedInterstitialsName[] =
"Enable Supervised User Committed Interstitials";
const char kSupervisedUserCommittedInterstitialsDescription[] =
"Use committed error pages instead of transient navigation entries for "
"supervised user interstitials";
const char kSilentDebuggerExtensionApiName[] = "Silent Debugging"; const char kSilentDebuggerExtensionApiName[] = "Silent Debugging";
const char kSilentDebuggerExtensionApiDescription[] = const char kSilentDebuggerExtensionApiDescription[] =
"Do not show the infobar when an extension attaches to a page via " "Do not show the infobar when an extension attaches to a page via "
......
...@@ -981,9 +981,6 @@ extern const char kSkiaRendererDescription[]; ...@@ -981,9 +981,6 @@ extern const char kSkiaRendererDescription[];
extern const char kHistoryManipulationIntervention[]; extern const char kHistoryManipulationIntervention[];
extern const char kHistoryManipulationInterventionDescription[]; extern const char kHistoryManipulationInterventionDescription[];
extern const char kSupervisedUserCommittedInterstitialsName[];
extern const char kSupervisedUserCommittedInterstitialsDescription[];
extern const char kEnableDrawOcclusionName[]; extern const char kEnableDrawOcclusionName[];
extern const char kEnableDrawOcclusionDescription[]; extern const char kEnableDrawOcclusionDescription[];
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/values.h" #include "base/values.h"
...@@ -22,7 +21,6 @@ ...@@ -22,7 +21,6 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/supervised_user/supervised_user_service.h" #include "chrome/browser/supervised_user/supervised_user_service.h"
#include "chrome/browser/supervised_user/supervised_user_service_factory.h" #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/infobars/core/infobar.h" #include "components/infobars/core/infobar.h"
...@@ -120,36 +118,16 @@ const content::InterstitialPageDelegate::TypeID ...@@ -120,36 +118,16 @@ const content::InterstitialPageDelegate::TypeID
SupervisedUserInterstitial::kTypeForTesting = SupervisedUserInterstitial::kTypeForTesting =
&SupervisedUserInterstitial::kTypeForTesting; &SupervisedUserInterstitial::kTypeForTesting;
// TODO(carlosil): Remove Show function and the rest of non-committed
// interstitials code once committed interstitials are the only code path.
// static
void SupervisedUserInterstitial::Show(
WebContents* web_contents,
const GURL& url,
supervised_user_error_page::FilteringBehaviorReason reason,
bool initial_page_load,
const base::Callback<void(bool)>& callback) {
DCHECK(!base::FeatureList::IsEnabled(
features::kSupervisedUserCommittedInterstitials));
// |interstitial_page_| is responsible for deleting the interstitial.
SupervisedUserInterstitial* interstitial = new SupervisedUserInterstitial(
web_contents, url, reason, initial_page_load, callback);
interstitial->Init();
}
// static // static
std::unique_ptr<SupervisedUserInterstitial> SupervisedUserInterstitial::Create( std::unique_ptr<SupervisedUserInterstitial> SupervisedUserInterstitial::Create(
WebContents* web_contents, WebContents* web_contents,
const GURL& url, const GURL& url,
supervised_user_error_page::FilteringBehaviorReason reason, supervised_user_error_page::FilteringBehaviorReason reason,
bool initial_page_load, bool initial_page_load,
const base::Callback<void(bool)>& callback) { base::OnceClosure callback) {
DCHECK(base::FeatureList::IsEnabled(
features::kSupervisedUserCommittedInterstitials));
std::unique_ptr<SupervisedUserInterstitial> interstitial( std::unique_ptr<SupervisedUserInterstitial> interstitial(
new SupervisedUserInterstitial(web_contents, url, reason, new SupervisedUserInterstitial(web_contents, url, reason,
initial_page_load, callback)); initial_page_load, std::move(callback)));
// Caller is responsible for deleting the interstitial. // Caller is responsible for deleting the interstitial.
interstitial->Init(); interstitial->Init();
...@@ -162,15 +140,12 @@ SupervisedUserInterstitial::SupervisedUserInterstitial( ...@@ -162,15 +140,12 @@ SupervisedUserInterstitial::SupervisedUserInterstitial(
const GURL& url, const GURL& url,
supervised_user_error_page::FilteringBehaviorReason reason, supervised_user_error_page::FilteringBehaviorReason reason,
bool initial_page_load, bool initial_page_load,
const base::Callback<void(bool)>& callback) base::OnceClosure callback)
: web_contents_(web_contents), : web_contents_(web_contents),
profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())),
interstitial_page_(NULL),
url_(url), url_(url),
reason_(reason), reason_(reason),
initial_page_load_(initial_page_load), callback_(std::move(callback)),
proceeded_(false),
callback_(callback),
scoped_observer_(this), scoped_observer_(this),
weak_ptr_factory_(this) {} weak_ptr_factory_(this) {}
...@@ -207,15 +182,6 @@ void SupervisedUserInterstitial::Init() { ...@@ -207,15 +182,6 @@ void SupervisedUserInterstitial::Init() {
SupervisedUserService* supervised_user_service = SupervisedUserService* supervised_user_service =
SupervisedUserServiceFactory::GetForProfile(profile_); SupervisedUserServiceFactory::GetForProfile(profile_);
scoped_observer_.Add(supervised_user_service); scoped_observer_.Add(supervised_user_service);
if (!base::FeatureList::IsEnabled(
features::kSupervisedUserCommittedInterstitials)) {
// If committed interstitials are enabled we do not create an
// interstitial_page
interstitial_page_ = content::InterstitialPage::Create(
web_contents_, initial_page_load_, url_, this);
interstitial_page_->Show();
}
} }
// static // static
...@@ -259,12 +225,7 @@ void SupervisedUserInterstitial::CommandReceived(const std::string& command) { ...@@ -259,12 +225,7 @@ void SupervisedUserInterstitial::CommandReceived(const std::string& command) {
UMA_HISTOGRAM_ENUMERATION("ManagedMode.BlockingInterstitialCommand", UMA_HISTOGRAM_ENUMERATION("ManagedMode.BlockingInterstitialCommand",
BACK, BACK,
HISTOGRAM_BOUNDING_VALUE); HISTOGRAM_BOUNDING_VALUE);
if (base::FeatureList::IsEnabled( DontProceedInternal();
features::kSupervisedUserCommittedInterstitials)) {
DontProceedInternal();
} else {
interstitial_page_->DontProceed();
}
return; return;
} }
...@@ -275,9 +236,7 @@ void SupervisedUserInterstitial::CommandReceived(const std::string& command) { ...@@ -275,9 +236,7 @@ void SupervisedUserInterstitial::CommandReceived(const std::string& command) {
SupervisedUserService* supervised_user_service = SupervisedUserService* supervised_user_service =
SupervisedUserServiceFactory::GetForProfile(profile_); SupervisedUserServiceFactory::GetForProfile(profile_);
supervised_user_service->AddURLAccessRequest( supervised_user_service->AddURLAccessRequest(url_, base::DoNothing());
url_, base::Bind(&SupervisedUserInterstitial::OnAccessRequestAdded,
weak_ptr_factory_.GetWeakPtr()));
return; return;
} }
...@@ -335,29 +294,7 @@ SupervisedUserInterstitial::GetTypeForTesting() const { ...@@ -335,29 +294,7 @@ SupervisedUserInterstitial::GetTypeForTesting() const {
void SupervisedUserInterstitial::OnURLFilterChanged() { void SupervisedUserInterstitial::OnURLFilterChanged() {
if (ShouldProceed()) { if (ShouldProceed()) {
if (base::FeatureList::IsEnabled( ProceedInternal();
features::kSupervisedUserCommittedInterstitials)) {
ProceedInternal();
} else {
// Interstitial page deletes the interstitial when proceeding but not
// synchronously, so a check is required to avoid calling proceed twice.
if (!proceeded_)
interstitial_page_->Proceed();
proceeded_ = true;
}
}
}
void SupervisedUserInterstitial::OnAccessRequestAdded(bool success) {
DCHECK(!base::FeatureList::IsEnabled(
features::kSupervisedUserCommittedInterstitials));
VLOG(1) << "Sent access request for " << url_.spec()
<< (success ? " successfully" : " unsuccessfully");
std::string jsFunc =
base::StringPrintf("setRequestStatus(%s);", success ? "true" : "false");
if (interstitial_page_->GetMainFrame()) {
interstitial_page_->GetMainFrame()->ExecuteJavaScript(
base::ASCIIToUTF16(jsFunc), base::NullCallback());
} }
} }
...@@ -382,20 +319,6 @@ void SupervisedUserInterstitial::MoveAwayFromCurrentPage() { ...@@ -382,20 +319,6 @@ void SupervisedUserInterstitial::MoveAwayFromCurrentPage() {
if (web_contents_->IsBeingDestroyed()) if (web_contents_->IsBeingDestroyed())
return; return;
// If the interstitial was shown during a page load and there is no history
// entry to go back to, attempt to close the tab.
// This check is skipped when committed interstitials are on, because all
// interstitials are treated as initial page loads in this case, the case
// where there is nothing to go back to will be handled by the default case at
// the end.
if (!base::FeatureList::IsEnabled(
features::kSupervisedUserCommittedInterstitials) &&
initial_page_load_) {
if (web_contents_->GetController().IsInitialBlankNavigation())
TabCloser::MaybeClose(web_contents_);
return;
}
// If the interstitial was shown over an existing page, navigate back from // If the interstitial was shown over an existing page, navigate back from
// that page. If that is not possible, attempt to close the entire tab. // that page. If that is not possible, attempt to close the entire tab.
if (web_contents_->GetController().CanGoBack()) { if (web_contents_->GetController().CanGoBack()) {
...@@ -406,9 +329,8 @@ void SupervisedUserInterstitial::MoveAwayFromCurrentPage() { ...@@ -406,9 +329,8 @@ void SupervisedUserInterstitial::MoveAwayFromCurrentPage() {
TabCloser::MaybeClose(web_contents_); TabCloser::MaybeClose(web_contents_);
} }
void SupervisedUserInterstitial::DispatchContinueRequest( void SupervisedUserInterstitial::OnInterstitialDone() {
bool continue_request) { std::move(callback_).Run();
callback_.Run(continue_request);
// After this, the WebContents may be destroyed. Make sure we don't try to use // After this, the WebContents may be destroyed. Make sure we don't try to use
// it again. // it again.
...@@ -416,17 +338,15 @@ void SupervisedUserInterstitial::DispatchContinueRequest( ...@@ -416,17 +338,15 @@ void SupervisedUserInterstitial::DispatchContinueRequest(
} }
void SupervisedUserInterstitial::ProceedInternal() { void SupervisedUserInterstitial::ProceedInternal() {
if (base::FeatureList::IsEnabled( if (web_contents_) {
features::kSupervisedUserCommittedInterstitials) &&
web_contents_) {
// In the committed interstitials case, there will be nothing to resume, so // In the committed interstitials case, there will be nothing to resume, so
// refresh instead. // refresh instead.
web_contents_->GetController().Reload(content::ReloadType::NORMAL, true); web_contents_->GetController().Reload(content::ReloadType::NORMAL, true);
} }
DispatchContinueRequest(true); OnInterstitialDone();
} }
void SupervisedUserInterstitial::DontProceedInternal() { void SupervisedUserInterstitial::DontProceedInternal() {
MoveAwayFromCurrentPage(); MoveAwayFromCurrentPage();
DispatchContinueRequest(false); OnInterstitialDone();
} }
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "url/gurl.h" #include "url/gurl.h"
namespace content { namespace content {
class InterstitialPage;
class WebContents; class WebContents;
} }
...@@ -36,18 +35,12 @@ class SupervisedUserInterstitial : public content::InterstitialPageDelegate, ...@@ -36,18 +35,12 @@ class SupervisedUserInterstitial : public content::InterstitialPageDelegate,
// Interstitial type, used for testing. // Interstitial type, used for testing.
static const content::InterstitialPageDelegate::TypeID kTypeForTesting; static const content::InterstitialPageDelegate::TypeID kTypeForTesting;
static void Show(content::WebContents* web_contents,
const GURL& url,
supervised_user_error_page::FilteringBehaviorReason reason,
bool initial_page_load,
const base::Callback<void(bool)>& callback);
static std::unique_ptr<SupervisedUserInterstitial> Create( static std::unique_ptr<SupervisedUserInterstitial> Create(
content::WebContents* web_contents, content::WebContents* web_contents,
const GURL& url, const GURL& url,
supervised_user_error_page::FilteringBehaviorReason reason, supervised_user_error_page::FilteringBehaviorReason reason,
bool initial_page_load, bool initial_page_load,
const base::Callback<void(bool)>& callback); base::OnceClosure callback);
static std::string GetHTMLContents( static std::string GetHTMLContents(
Profile* profile, Profile* profile,
...@@ -70,7 +63,7 @@ class SupervisedUserInterstitial : public content::InterstitialPageDelegate, ...@@ -70,7 +63,7 @@ class SupervisedUserInterstitial : public content::InterstitialPageDelegate,
const GURL& url, const GURL& url,
supervised_user_error_page::FilteringBehaviorReason reason, supervised_user_error_page::FilteringBehaviorReason reason,
bool initial_page_load, bool initial_page_load,
const base::Callback<void(bool)>& callback); base::OnceClosure callback);
void Init(); void Init();
...@@ -84,8 +77,6 @@ class SupervisedUserInterstitial : public content::InterstitialPageDelegate, ...@@ -84,8 +77,6 @@ class SupervisedUserInterstitial : public content::InterstitialPageDelegate,
void OnURLFilterChanged() override; void OnURLFilterChanged() override;
// TODO(treib): Also listen to OnCustodianInfoChanged and update as required. // TODO(treib): Also listen to OnCustodianInfoChanged and update as required.
void OnAccessRequestAdded(bool success);
// Returns whether we should now proceed on a previously-blocked URL. // Returns whether we should now proceed on a previously-blocked URL.
// Called initially before the interstitial is shown (to catch race // Called initially before the interstitial is shown (to catch race
// conditions), or when the URL filtering prefs change. Note that this does // conditions), or when the URL filtering prefs change. Note that this does
...@@ -97,7 +88,7 @@ class SupervisedUserInterstitial : public content::InterstitialPageDelegate, ...@@ -97,7 +88,7 @@ class SupervisedUserInterstitial : public content::InterstitialPageDelegate,
// the request. // the request.
void MoveAwayFromCurrentPage(); void MoveAwayFromCurrentPage();
void DispatchContinueRequest(bool continue_request); void OnInterstitialDone();
void ProceedInternal(); void ProceedInternal();
...@@ -108,20 +99,10 @@ class SupervisedUserInterstitial : public content::InterstitialPageDelegate, ...@@ -108,20 +99,10 @@ class SupervisedUserInterstitial : public content::InterstitialPageDelegate,
Profile* profile_; Profile* profile_;
content::InterstitialPage* interstitial_page_; // Owns us.
GURL url_; GURL url_;
supervised_user_error_page::FilteringBehaviorReason reason_; supervised_user_error_page::FilteringBehaviorReason reason_;
// True if the interstitial was shown while loading a page (with a pending base::OnceClosure callback_;
// navigation), false if it was shown over an already loaded page.
// Interstitials behave very differently in those cases.
bool initial_page_load_;
// True if we have already called Proceed() on the interstitial page.
bool proceeded_;
base::Callback<void(bool)> callback_;
ScopedObserver<SupervisedUserService, SupervisedUserInterstitial> ScopedObserver<SupervisedUserService, SupervisedUserInterstitial>
scoped_observer_; scoped_observer_;
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/feature_list.h"
#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/supervised_user/supervised_user_interstitial.h" #include "chrome/browser/supervised_user/supervised_user_interstitial.h"
...@@ -14,7 +13,6 @@ ...@@ -14,7 +13,6 @@
#include "chrome/browser/supervised_user/supervised_user_service.h" #include "chrome/browser/supervised_user/supervised_user_service.h"
#include "chrome/browser/supervised_user/supervised_user_service_factory.h" #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/tab_contents/tab_util.h" #include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/common/chrome_features.h"
#include "components/history/content/browser/history_context_helper.h" #include "components/history/content/browser/history_context_helper.h"
#include "components/history/core/browser/history_service.h" #include "components/history/core/browser/history_service.h"
#include "components/history/core/browser/history_types.h" #include "components/history/core/browser/history_types.h"
...@@ -66,12 +64,10 @@ void SupervisedUserNavigationObserver::OnRequestBlocked( ...@@ -66,12 +64,10 @@ void SupervisedUserNavigationObserver::OnRequestBlocked(
void SupervisedUserNavigationObserver::DidFinishNavigation( void SupervisedUserNavigationObserver::DidFinishNavigation(
content::NavigationHandle* navigation_handle) { content::NavigationHandle* navigation_handle) {
// With committed interstitials on, if this is a different navigation than the // If this is a different navigation than the one that triggered the
// one that triggered the interstitial, clear is_showing_interstitial_ // interstitial, clear is_showing_interstitial_
if (is_showing_interstitial_ && if (is_showing_interstitial_ &&
navigation_handle->GetNavigationId() != interstitial_navigation_id_ && navigation_handle->GetNavigationId() != interstitial_navigation_id_) {
base::FeatureList::IsEnabled(
features::kSupervisedUserCommittedInterstitials)) {
is_showing_interstitial_ = false; is_showing_interstitial_ = false;
} }
...@@ -150,22 +146,8 @@ void SupervisedUserNavigationObserver::URLFilterCheckCallback( ...@@ -150,22 +146,8 @@ void SupervisedUserNavigationObserver::URLFilterCheckCallback(
if (!is_showing_interstitial_ && if (!is_showing_interstitial_ &&
behavior == SupervisedUserURLFilter::FilteringBehavior::BLOCK) { behavior == SupervisedUserURLFilter::FilteringBehavior::BLOCK) {
if (base::FeatureList::IsEnabled( web_contents()->GetController().Reload(content::ReloadType::NORMAL, false);
features::kSupervisedUserCommittedInterstitials)) { return;
web_contents()->GetController().Reload(content::ReloadType::NORMAL,
false);
return;
}
// TODO(carlosil): For now, we pass a 0 as the navigation id causing the
// interstitial for the non-committed interstitials case since we don't have
// the real id here, this doesn't cause issues since the navigation id is
// not used when committed interstitials are not enabled. This will be
// removed once committed interstitials are the only code path.
const bool initial_page_load = false;
MaybeShowInterstitial(
url, reason, initial_page_load, 0,
base::Callback<void(
SupervisedUserNavigationThrottle::CallbackActions)>());
} }
} }
...@@ -178,54 +160,30 @@ void SupervisedUserNavigationObserver::MaybeShowInterstitial( ...@@ -178,54 +160,30 @@ void SupervisedUserNavigationObserver::MaybeShowInterstitial(
void(SupervisedUserNavigationThrottle::CallbackActions)>& callback) { void(SupervisedUserNavigationThrottle::CallbackActions)>& callback) {
interstitial_navigation_id_ = navigation_id; interstitial_navigation_id_ = navigation_id;
is_showing_interstitial_ = true; is_showing_interstitial_ = true;
base::Callback<void(bool)> wrapped_callback = interstitial_ = SupervisedUserInterstitial::Create(
base::Bind(&SupervisedUserNavigationObserver::OnInterstitialResult, web_contents(), url, reason, initial_page_load,
weak_ptr_factory_.GetWeakPtr(), callback); base::BindOnce(&SupervisedUserNavigationObserver::OnInterstitialDone,
if (base::FeatureList::IsEnabled( weak_ptr_factory_.GetWeakPtr()));
features::kSupervisedUserCommittedInterstitials)) { callback.Run(SupervisedUserNavigationThrottle::CallbackActions::
interstitial_ = SupervisedUserInterstitial::Create( kCancelWithInterstitial);
web_contents(), url, reason, initial_page_load, wrapped_callback);
callback.Run(SupervisedUserNavigationThrottle::CallbackActions::
kCancelWithInterstitial);
return;
}
SupervisedUserInterstitial::Show(web_contents(), url, reason,
initial_page_load, wrapped_callback);
} }
void SupervisedUserNavigationObserver::OnInterstitialResult( void SupervisedUserNavigationObserver::OnInterstitialDone() {
const base::Callback<
void(SupervisedUserNavigationThrottle::CallbackActions)>& callback,
bool result) {
is_showing_interstitial_ = false; is_showing_interstitial_ = false;
// If committed interstitials are enabled, there is no navigation to cancel or
// defer at this point, so just clear the is_showing_interstitial variable.
if (callback && !base::FeatureList::IsEnabled(
features::kSupervisedUserCommittedInterstitials))
callback.Run(result ? SupervisedUserNavigationThrottle::CallbackActions::
kContinueNavigation
: SupervisedUserNavigationThrottle::CallbackActions::
kCancelNavigation);
} }
void SupervisedUserNavigationObserver::GoBack() { void SupervisedUserNavigationObserver::GoBack() {
DCHECK(base::FeatureList::IsEnabled(
features::kSupervisedUserCommittedInterstitials));
if (interstitial_ && is_showing_interstitial_) if (interstitial_ && is_showing_interstitial_)
interstitial_->CommandReceived("\"back\""); interstitial_->CommandReceived("\"back\"");
} }
void SupervisedUserNavigationObserver::RequestPermission( void SupervisedUserNavigationObserver::RequestPermission(
RequestPermissionCallback callback) { RequestPermissionCallback callback) {
DCHECK(base::FeatureList::IsEnabled(
features::kSupervisedUserCommittedInterstitials));
if (interstitial_ && is_showing_interstitial_) if (interstitial_ && is_showing_interstitial_)
interstitial_->RequestPermission(std::move(callback)); interstitial_->RequestPermission(std::move(callback));
} }
void SupervisedUserNavigationObserver::Feedback() { void SupervisedUserNavigationObserver::Feedback() {
DCHECK(base::FeatureList::IsEnabled(
features::kSupervisedUserCommittedInterstitials));
if (interstitial_ && is_showing_interstitial_) if (interstitial_ && is_showing_interstitial_)
interstitial_->CommandReceived("\"feedback\""); interstitial_->CommandReceived("\"feedback\"");
} }
......
...@@ -82,10 +82,7 @@ class SupervisedUserNavigationObserver ...@@ -82,10 +82,7 @@ class SupervisedUserNavigationObserver
const base::Callback< const base::Callback<
void(SupervisedUserNavigationThrottle::CallbackActions)>& callback); void(SupervisedUserNavigationThrottle::CallbackActions)>& callback);
void OnInterstitialResult( void OnInterstitialDone();
const base::Callback<
void(SupervisedUserNavigationThrottle::CallbackActions)>& callback,
bool result);
// supervised_user::mojom::SupervisedUserCommands implementation. Should not // supervised_user::mojom::SupervisedUserCommands implementation. Should not
// be called when an interstitial is no longer showing. This should be // be called when an interstitial is no longer showing. This should be
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "chrome/browser/supervised_user/supervised_user_navigation_throttle.h" #include "chrome/browser/supervised_user/supervised_user_navigation_throttle.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/feature_list.h"
#include "base/location.h" #include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
...@@ -18,7 +17,6 @@ ...@@ -18,7 +17,6 @@
#include "chrome/browser/supervised_user/supervised_user_service.h" #include "chrome/browser/supervised_user/supervised_user_service.h"
#include "chrome/browser/supervised_user/supervised_user_service_factory.h" #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/supervised_user/supervised_user_url_filter.h" #include "chrome/browser/supervised_user/supervised_user_url_filter.h"
#include "chrome/common/chrome_features.h"
#include "content/public/browser/navigation_handle.h" #include "content/public/browser/navigation_handle.h"
#include "ui/base/page_transition_types.h" #include "ui/base/page_transition_types.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -239,24 +237,16 @@ void SupervisedUserNavigationThrottle::OnCheckDone( ...@@ -239,24 +237,16 @@ void SupervisedUserNavigationThrottle::OnCheckDone(
void SupervisedUserNavigationThrottle::OnInterstitialResult( void SupervisedUserNavigationThrottle::OnInterstitialResult(
CallbackActions action) { CallbackActions action) {
switch (action) { switch (action) {
case kContinueNavigation: {
Resume();
break;
}
case kCancelNavigation: { case kCancelNavigation: {
CancelDeferredNavigation(CANCEL); CancelDeferredNavigation(CANCEL);
break; break;
} }
case kCancelWithInterstitial: { case kCancelWithInterstitial: {
DCHECK(base::FeatureList::IsEnabled(
features::kSupervisedUserCommittedInterstitials));
std::string interstitial_html = std::string interstitial_html =
SupervisedUserInterstitial::GetHTMLContents( SupervisedUserInterstitial::GetHTMLContents(
Profile::FromBrowserContext( Profile::FromBrowserContext(
navigation_handle()->GetWebContents()->GetBrowserContext()), navigation_handle()->GetWebContents()->GetBrowserContext()),
reason_); reason_);
// If committed interstitials are enabled, include the HTML content in the
// ThrottleCheckResult.
CancelDeferredNavigation(content::NavigationThrottle::ThrottleCheckResult( CancelDeferredNavigation(content::NavigationThrottle::ThrottleCheckResult(
CANCEL, net::ERR_BLOCKED_BY_CLIENT, interstitial_html)); CANCEL, net::ERR_BLOCKED_BY_CLIENT, interstitial_html));
} }
......
...@@ -17,11 +17,7 @@ ...@@ -17,11 +17,7 @@
class SupervisedUserNavigationThrottle : public content::NavigationThrottle { class SupervisedUserNavigationThrottle : public content::NavigationThrottle {
public: public:
enum CallbackActions { enum CallbackActions { kCancelNavigation = 0, kCancelWithInterstitial };
kContinueNavigation = 0,
kCancelNavigation,
kCancelWithInterstitial
};
// Returns a new throttle for the given navigation, or nullptr if no // Returns a new throttle for the given navigation, or nullptr if no
// throttling is required. // throttling is required.
......
...@@ -5,11 +5,9 @@ ...@@ -5,11 +5,9 @@
#include <memory> #include <memory>
#include "base/command_line.h" #include "base/command_line.h"
#include "base/feature_list.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/supervised_user/supervised_user_constants.h" #include "chrome/browser/supervised_user/supervised_user_constants.h"
...@@ -19,7 +17,6 @@ ...@@ -19,7 +17,6 @@
#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h" #include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/ui_test_utils.h"
...@@ -48,9 +45,7 @@ static const char* kIframeHost2 = "www.iframe2.com"; ...@@ -48,9 +45,7 @@ static const char* kIframeHost2 = "www.iframe2.com";
} // namespace } // namespace
class SupervisedUserNavigationThrottleTest class SupervisedUserNavigationThrottleTest : public InProcessBrowserTest {
: public InProcessBrowserTest,
public testing::WithParamInterface<bool> {
protected: protected:
SupervisedUserNavigationThrottleTest() {} SupervisedUserNavigationThrottleTest() {}
~SupervisedUserNavigationThrottleTest() override {} ~SupervisedUserNavigationThrottleTest() override {}
...@@ -66,44 +61,24 @@ class SupervisedUserNavigationThrottleTest ...@@ -66,44 +61,24 @@ class SupervisedUserNavigationThrottleTest
supervised_users::kContentPackManualBehaviorHosts, std::move(dict)); supervised_users::kContentPackManualBehaviorHosts, std::move(dict));
} }
bool AreCommittedInterstitialsEnabled();
bool IsInterstitialBeingShown(Browser* browser); bool IsInterstitialBeingShown(Browser* browser);
private: private:
void SetUpOnMainThread() override; void SetUpOnMainThread() override;
void SetUpCommandLine(base::CommandLine* command_line) override; void SetUpCommandLine(base::CommandLine* command_line) override;
base::test::ScopedFeatureList feature_list;
}; };
bool SupervisedUserNavigationThrottleTest::AreCommittedInterstitialsEnabled() {
return base::FeatureList::IsEnabled(
features::kSupervisedUserCommittedInterstitials);
}
bool SupervisedUserNavigationThrottleTest::IsInterstitialBeingShown( bool SupervisedUserNavigationThrottleTest::IsInterstitialBeingShown(
Browser* browser) { Browser* browser) {
WebContents* tab = browser->tab_strip_model()->GetActiveWebContents(); WebContents* tab = browser->tab_strip_model()->GetActiveWebContents();
if (AreCommittedInterstitialsEnabled()) { base::string16 title;
base::string16 title; ui_test_utils::GetCurrentTabTitle(browser, &title);
ui_test_utils::GetCurrentTabTitle(browser, &title); return tab->GetController().GetLastCommittedEntry()->GetPageType() ==
return tab->GetController().GetLastCommittedEntry()->GetPageType() == content::PAGE_TYPE_ERROR &&
content::PAGE_TYPE_ERROR && title == base::ASCIIToUTF16("Site blocked");
title == base::ASCIIToUTF16("Site blocked");
}
return tab->ShowingInterstitialPage();
} }
void SupervisedUserNavigationThrottleTest::SetUpOnMainThread() { void SupervisedUserNavigationThrottleTest::SetUpOnMainThread() {
if (GetParam()) {
feature_list.InitAndEnableFeature(
features::kSupervisedUserCommittedInterstitials);
} else {
feature_list.InitAndDisableFeature(
features::kSupervisedUserCommittedInterstitials);
}
// Resolve everything to localhost. // Resolve everything to localhost.
host_resolver()->AddIPLiteralRule("*", "127.0.0.1", "localhost"); host_resolver()->AddIPLiteralRule("*", "127.0.0.1", "localhost");
...@@ -121,13 +96,9 @@ void SupervisedUserNavigationThrottleTest::SetUpCommandLine( ...@@ -121,13 +96,9 @@ void SupervisedUserNavigationThrottleTest::SetUpCommandLine(
#endif #endif
} }
INSTANTIATE_TEST_SUITE_P(,
SupervisedUserNavigationThrottleTest,
::testing::Values(false, true));
// Tests that navigating to a blocked page simply fails if there is no // Tests that navigating to a blocked page simply fails if there is no
// SupervisedUserNavigationObserver. // SupervisedUserNavigationObserver.
IN_PROC_BROWSER_TEST_P(SupervisedUserNavigationThrottleTest, IN_PROC_BROWSER_TEST_F(SupervisedUserNavigationThrottleTest,
NoNavigationObserverBlock) { NoNavigationObserverBlock) {
Profile* profile = browser()->profile(); Profile* profile = browser()->profile();
SupervisedUserSettingsService* supervised_user_settings_service = SupervisedUserSettingsService* supervised_user_settings_service =
...@@ -150,7 +121,7 @@ IN_PROC_BROWSER_TEST_P(SupervisedUserNavigationThrottleTest, ...@@ -150,7 +121,7 @@ IN_PROC_BROWSER_TEST_P(SupervisedUserNavigationThrottleTest,
EXPECT_FALSE(observer.last_navigation_succeeded()); EXPECT_FALSE(observer.last_navigation_succeeded());
} }
IN_PROC_BROWSER_TEST_P(SupervisedUserNavigationThrottleTest, IN_PROC_BROWSER_TEST_F(SupervisedUserNavigationThrottleTest,
BlockMainFrameWithInterstitial) { BlockMainFrameWithInterstitial) {
BlockHost(kExampleHost2); BlockHost(kExampleHost2);
...@@ -165,7 +136,7 @@ IN_PROC_BROWSER_TEST_P(SupervisedUserNavigationThrottleTest, ...@@ -165,7 +136,7 @@ IN_PROC_BROWSER_TEST_P(SupervisedUserNavigationThrottleTest,
EXPECT_TRUE(IsInterstitialBeingShown(browser())); EXPECT_TRUE(IsInterstitialBeingShown(browser()));
} }
IN_PROC_BROWSER_TEST_P(SupervisedUserNavigationThrottleTest, IN_PROC_BROWSER_TEST_F(SupervisedUserNavigationThrottleTest,
DontBlockSubFrame) { DontBlockSubFrame) {
BlockHost(kExampleHost2); BlockHost(kExampleHost2);
BlockHost(kIframeHost2); BlockHost(kIframeHost2);
...@@ -199,11 +170,7 @@ class SupervisedUserNavigationThrottleNotSupervisedTest ...@@ -199,11 +170,7 @@ class SupervisedUserNavigationThrottleNotSupervisedTest
void SetUpCommandLine(base::CommandLine* command_line) override {} void SetUpCommandLine(base::CommandLine* command_line) override {}
}; };
INSTANTIATE_TEST_SUITE_P(, IN_PROC_BROWSER_TEST_F(SupervisedUserNavigationThrottleNotSupervisedTest,
SupervisedUserNavigationThrottleNotSupervisedTest,
::testing::Values(false, true));
IN_PROC_BROWSER_TEST_P(SupervisedUserNavigationThrottleNotSupervisedTest,
DontBlock) { DontBlock) {
BlockHost(kExampleHost); BlockHost(kExampleHost);
......
...@@ -618,11 +618,6 @@ const base::Feature kNativeSmb{"NativeSmb", base::FEATURE_ENABLED_BY_DEFAULT}; ...@@ -618,11 +618,6 @@ const base::Feature kNativeSmb{"NativeSmb", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kSoundContentSetting{"SoundContentSetting", const base::Feature kSoundContentSetting{"SoundContentSetting",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
// Enables or disabled committed interstitials for Supervised User
// interstitials.
const base::Feature kSupervisedUserCommittedInterstitials{
"SupervisedUserCommittedInterstitials", base::FEATURE_ENABLED_BY_DEFAULT};
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// Enables or disables chrome://sys-internals. // Enables or disables chrome://sys-internals.
const base::Feature kSysInternals{"SysInternals", const base::Feature kSysInternals{"SysInternals",
......
...@@ -390,9 +390,6 @@ COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kNativeSmb; ...@@ -390,9 +390,6 @@ COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kNativeSmb;
COMPONENT_EXPORT(CHROME_FEATURES) COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kSoundContentSetting; extern const base::Feature kSoundContentSetting;
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kSupervisedUserCommittedInterstitials;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
COMPONENT_EXPORT(CHROME_FEATURES) COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kSysInternals; extern const base::Feature kSysInternals;
......
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