blob: cba2dac19b7a6169893d7268906c0933a1f6e366 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/payments/ssl_validity_checker.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "components/security_state/core/security_state.h"
namespace payments {
// static
bool SslValidityChecker::IsSslCertificateValid(
content::WebContents* web_contents) {
DCHECK(web_contents);
SecurityStateTabHelper::CreateForWebContents(web_contents);
SecurityStateTabHelper* helper =
SecurityStateTabHelper::FromWebContents(web_contents);
DCHECK(helper);
security_state::SecurityLevel security_level = helper->GetSecurityLevel();
return security_level == security_state::EV_SECURE ||
security_level == security_state::SECURE ||
security_level == security_state::SECURE_WITH_POLICY_INSTALLED_CERT ||
// No early return, so the other code is exercised in tests, too.
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kIgnoreCertificateErrors);
}
} // namespace payments