Skip to content

Commit

Permalink
[M110][URLFiltering] Make the Proceed Anyway button functional on the…
Browse files Browse the repository at this point in the history
… Enterprise Warn Interstitial Page

After receiving the verdict for enterprise managed policy through RealTimeURLLookup, the enterprise warn interstitials is displayed if the site requires a warning to access. The user can proceed to this site anyway by clicking on the proceed button and that will allowlist the url.

(cherry picked from commit d506c87)

Bug: 1402746
Change-Id: I82b2f827a0f385eb2a7714de777b7814b99f0da3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4108157
Reviewed-by: Sebastien Lalancette <seblalancette@chromium.org>
Commit-Queue: Sneha Nagpaul <snehanagpaul@google.com>
Reviewed-by: Emily Stark <estark@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1084354}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4133329
Reviewed-by: Xinghui Lu <xinghuilu@chromium.org>
Reviewed-by: Dominique Fauteux-Chapleau <domfc@chromium.org>
Cr-Commit-Position: refs/branch-heads/5481@{#131}
Cr-Branched-From: 130f3e4-refs/heads/main@{#1084008}
  • Loading branch information
Sneha Nagpaul authored and Chromium LUCI CQ committed Jan 4, 2023
1 parent 6e36837 commit 394ab94
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 14 deletions.
1 change: 1 addition & 0 deletions chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2276,6 +2276,7 @@ static_library("browser") {
"//components/security_interstitials/content:proto",
"//components/security_interstitials/content:security_interstitial_page",
"//components/security_interstitials/core",
"//components/security_interstitials/core:unsafe_resource",
"//components/security_state/content",
"//components/security_state/core",
"//components/segmentation_platform/embedder",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ void EnterpriseWarnControllerClient::GoBack() {
}

void EnterpriseWarnControllerClient::Proceed() {
// Logic to bypass the warning.
// TODO(b/251184055): Uncomment once hook is implemented for URLFiltering
// WebProtego
// ReputationService::Get(
// Profile::FromBrowserContext(web_contents_->GetBrowserContext()))
// ->SetUserIgnore(request_url_);
// Reload();
// Already allowlisted when used clicked on proceed.
// The reload will just work.
Reload();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <utility>

#include "components/grit/components_resources.h"
#include "components/safe_browsing/content/browser/base_ui_manager.h"
#include "components/security_interstitials/content/security_interstitial_controller_client.h"
#include "components/security_interstitials/core/common_string_util.h"
#include "components/security_interstitials/core/urls.h"
Expand All @@ -23,15 +24,20 @@ const security_interstitials::SecurityInterstitialPage::TypeID
EnterpriseWarnPage::kTypeForTesting = &EnterpriseWarnPage::kTypeForTesting;

EnterpriseWarnPage::EnterpriseWarnPage(
safe_browsing::BaseUIManager* ui_manager,
content::WebContents* web_contents,
const GURL& request_url,
const safe_browsing::SafeBrowsingBlockingPage::UnsafeResourceList&
unsafe_resources,
std::unique_ptr<
security_interstitials::SecurityInterstitialControllerClient>
controller_client)
: security_interstitials::SecurityInterstitialPage(
web_contents,
request_url,
std::move(controller_client)) {}
std::move(controller_client)),
ui_manager_(ui_manager),
unsafe_resources_(unsafe_resources) {}

EnterpriseWarnPage::~EnterpriseWarnPage() = default;

Expand Down Expand Up @@ -83,9 +89,14 @@ void EnterpriseWarnPage::CommandReceived(const std::string& command) {
case security_interstitials::CMD_DONT_PROCEED:
controller()->GoBack();
break;
case security_interstitials::CMD_PROCEED:
case security_interstitials::CMD_PROCEED: {
// Add to allowlist.
ui_manager_->OnBlockingPageDone(unsafe_resources_, /*proceed=*/true,
web_contents(), request_url(),
/*showed_interstitial=*/true);
controller()->Proceed();
break;
}
case security_interstitials::CMD_OPEN_HELP_CENTER:
controller()->OpenUrlInNewForegroundTab(
GURL(security_interstitials::kEnterpriseInterstitialHelpLink));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
#ifndef CHROME_BROWSER_ENTERPRISE_CONNECTORS_INTERSTITIALS_ENTERPRISE_WARN_PAGE_H_
#define CHROME_BROWSER_ENTERPRISE_CONNECTORS_INTERSTITIALS_ENTERPRISE_WARN_PAGE_H_

#include <memory>
#include <string>

#include "base/memory/raw_ptr.h"
#include "components/safe_browsing/content/browser/safe_browsing_blocking_page.h"
#include "components/security_interstitials/content/security_interstitial_page.h"

namespace safe_browsing {
class BaseUIManager;
} // namespace safe_browsing

class GURL;

// This class is responsible for showing/hiding the interstitial page that
Expand All @@ -24,8 +27,11 @@ class EnterpriseWarnPage

// |request_url| is the URL which triggered the interstitial page.
EnterpriseWarnPage(
safe_browsing::BaseUIManager* ui_manager,
content::WebContents* web_contents,
const GURL& request_url,
const safe_browsing::SafeBrowsingBlockingPage::UnsafeResourceList&
unsafe_resources,
std::unique_ptr<
security_interstitials::SecurityInterstitialControllerClient>
controller);
Expand All @@ -47,6 +53,9 @@ class EnterpriseWarnPage
int GetHTMLTemplateId() override;

private:
const raw_ptr<safe_browsing::BaseUIManager> ui_manager_;
const safe_browsing::SafeBrowsingBlockingPage::UnsafeResourceList
unsafe_resources_;
void PopulateStringsForSharedHTML(base::Value::Dict& load_time_data);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ChromeSafeBrowsingBlockingPageFactory::CreateEnterpriseWarnPage(
const GURL& main_frame_url,
const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) {
return new EnterpriseWarnPage(
web_contents, main_frame_url,
ui_manager, web_contents, main_frame_url, unsafe_resources,
std::make_unique<EnterpriseWarnControllerClient>(web_contents,
main_frame_url));
}
Expand Down
20 changes: 19 additions & 1 deletion chrome/browser/ui/webui/interstitials/interstitial_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,26 @@ std::unique_ptr<EnterpriseBlockPage> CreateEnterpriseBlockPage(
std::unique_ptr<EnterpriseWarnPage> CreateEnterpriseWarnPage(
content::WebContents* web_contents) {
const GURL kRequestUrl("https://enterprise-warn.example.net");

auto* ui_manager =
g_browser_process->safe_browsing_service()->ui_manager().get();

const content::GlobalRenderFrameHostId primary_main_frame_id =
web_contents->GetPrimaryMainFrame()->GetGlobalId();
safe_browsing::SafeBrowsingBlockingPage::UnsafeResource resource;
resource.url = kRequestUrl;
resource.is_subresource = false;
resource.is_subframe = false;
resource.threat_type = safe_browsing::SB_THREAT_TYPE_MANAGED_POLICY_WARN;
resource.render_process_id = primary_main_frame_id.child_id;
resource.render_frame_id = primary_main_frame_id.frame_routing_id;
resource.threat_source = g_browser_process->safe_browsing_service()
->database_manager()
->GetThreatSource();

return std::make_unique<EnterpriseWarnPage>(
web_contents, kRequestUrl,
ui_manager, web_contents, kRequestUrl,
safe_browsing::SafeBrowsingBlockingPage::UnsafeResourceList({resource}),
std::make_unique<EnterpriseWarnControllerClient>(web_contents,
kRequestUrl));
}
Expand Down

0 comments on commit 394ab94

Please sign in to comment.