1// Copyright 2020 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#import "ios/components/security_interstitials/legacy_tls/legacy_tls_controller_client.h"
6
7#include "components/security_interstitials/core/metrics_helper.h"
8#include "ios/components/security_interstitials/ios_blocking_page_metrics_helper.h"
9#include "ios/components/security_interstitials/legacy_tls/legacy_tls_tab_allow_list.h"
10#import "ios/web/public/web_state.h"
11
12#if !defined(__has_feature) || !__has_feature(objc_arc)
13#error "This file requires ARC support."
14#endif
15
16namespace {
17// Creates a metrics helper for |url|.
18std::unique_ptr<security_interstitials::IOSBlockingPageMetricsHelper>
19CreateMetricsHelper(web::WebState* web_state, const GURL& url) {
20  security_interstitials::MetricsHelper::ReportDetails reporting_info;
21  reporting_info.metric_prefix = "legacy_tls";
22  return std::make_unique<security_interstitials::IOSBlockingPageMetricsHelper>(
23      web_state, url, reporting_info);
24}
25}  // namespace
26
27LegacyTLSControllerClient::LegacyTLSControllerClient(
28    web::WebState* web_state,
29    const GURL& request_url,
30    const std::string& app_locale)
31    : IOSBlockingPageControllerClient(
32          web_state,
33          CreateMetricsHelper(web_state, request_url),
34          app_locale),
35      request_url_(request_url) {}
36
37LegacyTLSControllerClient::~LegacyTLSControllerClient() {}
38
39void LegacyTLSControllerClient::Proceed() {
40  LegacyTLSTabAllowList::FromWebState(web_state())
41      ->AllowDomain(request_url_.host());
42  Reload();
43}
44