summaryrefslogtreecommitdiffstats
path: root/src/core/authentication_dialog_controller.cpp
blob: 5ed38ecbd71cd86164018ba334c03c859bac2702 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (C) 2016 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 "authentication_dialog_controller.h"
#include "authentication_dialog_controller_p.h"

#include "base/task/post_task.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/browser_task_traits.h"

namespace QtWebEngineCore {

AuthenticationDialogControllerPrivate::AuthenticationDialogControllerPrivate(base::WeakPtr<LoginDelegateQt> loginDelegate)
    : loginDelegate(loginDelegate)
{
}

void AuthenticationDialogControllerPrivate::dialogFinished(bool accepted, const QString &user, const QString &password)
{
    base::PostTask(FROM_HERE, {content::BrowserThread::UI},
                   base::BindOnce(&LoginDelegateQt::sendAuthToRequester,
                                  loginDelegate, accepted, user, password));
}

AuthenticationDialogController::AuthenticationDialogController(AuthenticationDialogControllerPrivate *dd)
{
    Q_ASSERT(dd);
    d.reset(dd);
}

AuthenticationDialogController::~AuthenticationDialogController()
{
}

QUrl AuthenticationDialogController::url() const
{
    return d->url;
}

QString AuthenticationDialogController::realm() const
{
    return d->realm;
}

QString AuthenticationDialogController::host() const
{
    return d->host;
}

bool AuthenticationDialogController::isProxy() const
{
    return d->isProxy;
}

void AuthenticationDialogController::accept(const QString &user, const QString &password)
{
    d->dialogFinished(true, user, password);
}

void AuthenticationDialogController::reject()
{
    d->dialogFinished(false);
}

} // namespace QtWebEngineCore