1
// vim:expandtab:shiftwidth=2:tabstop=2:
2
// Copyright (C) 2015 Canonical Ltd.
4
// This library is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU Lesser General Public
6
// License as published by the Free Software Foundation; either
7
// version 2.1 of the License, or (at your option) any later version.
9
// This library is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
// Lesser General Public License for more details.
14
// You should have received a copy of the GNU Lesser General Public
15
// License along with this library; if not, write to the Free Software
16
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
#include "oxide_certificate_error_proxy.h"
20
#include "base/logging.h"
22
#include "oxide_certificate_error_placeholder_page.h"
26
CertificateErrorProxy::~CertificateErrorProxy() {
27
DCHECK(did_respond_ || is_cancelled_);
30
CertificateErrorProxy::CertificateErrorProxy(
31
const base::Callback<void(bool)>& callback)
32
: callback_(callback),
35
placeholder_page_(nullptr) {}
37
void CertificateErrorProxy::Allow() {
38
DCHECK(!did_respond_);
39
DCHECK(!is_cancelled_);
40
DCHECK(!callback_.is_null());
47
if (placeholder_page_) {
48
placeholder_page_->Proceed();
49
placeholder_page_ = nullptr;
53
void CertificateErrorProxy::Deny() {
54
DCHECK(!did_respond_);
55
DCHECK(!is_cancelled_);
59
if (!callback_.is_null()) {
64
if (placeholder_page_) {
65
placeholder_page_->DontProceed();
66
placeholder_page_ = nullptr;
70
void CertificateErrorProxy::Cancel() {
71
DCHECK(!is_cancelled_);
72
DCHECK(placeholder_page_);
75
// Calling Deny() ends up here via InterstitialPageDelegate::OnDontProceed
80
placeholder_page_ = nullptr;
82
if (!callback_.is_null()) {
87
if (!cancel_callback_.is_null()) {
88
cancel_callback_.Run();
89
cancel_callback_.Reset();
93
void CertificateErrorProxy::SetPlaceholderPage(
94
CertificateErrorPlaceholderPage* placeholder) {
95
DCHECK(!did_respond_);
96
DCHECK(!is_cancelled_);
97
placeholder_page_ = placeholder;