summaryrefslogtreecommitdiffstats
path: root/src/core/quota_request_controller_impl.cpp
blob: 32d7a6d63084fa9e8733db3b11274ea1d5c088bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "quota_request_controller_impl.h"

#include "type_conversion.h"

namespace QtWebEngineCore {

QuotaRequestControllerImpl::QuotaRequestControllerImpl(QuotaPermissionContextQt *context,
    const content::StorageQuotaParams &params,
    content::QuotaPermissionContext::PermissionCallback callback)
    : QuotaRequestController(
        toQt(params.origin_url),
        params.requested_size)
    , m_context(context)
    , m_callback(std::move(callback))
{}

QuotaRequestControllerImpl::~QuotaRequestControllerImpl()
{
    if (m_callback)
        m_context->dispatchCallbackOnIOThread(std::move(m_callback), content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_CANCELLED);
}

void QuotaRequestControllerImpl::accepted()
{
    m_context->dispatchCallbackOnIOThread(std::move(m_callback), content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW);
}

void QuotaRequestControllerImpl::rejected()
{
    m_context->dispatchCallbackOnIOThread(std::move(m_callback), content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_DISALLOW);
}

} // namespace QtWebEngineCore