summaryrefslogtreecommitdiffstats
path: root/src/core/login_delegate_qt.h
blob: b1bae0c0b2496c1f4b6d3db7a21ac4a3d1053e45 (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
// Copyright (C) 2018 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

#ifndef LOGIN_DELEGATE_QT_H
#define LOGIN_DELEGATE_QT_H

#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/login_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "url/gurl.h"

#include "web_contents_adapter_client.h"

namespace net {
class AuthChallengeInfo;
class AuthCredentials;
}

namespace QtWebEngineCore {

class AuthenticationDialogController;

class LoginDelegateQt : public content::LoginDelegate,
                        public content::WebContentsObserver
{
public:
    LoginDelegateQt(const net::AuthChallengeInfo &authInfo,
                    content::WebContents *web_contents,
                    GURL url,
                    bool first_auth_attempt,
                    LoginAuthRequiredCallback auth_required_callback);

    QUrl url() const;
    QString realm() const;
    QString host() const;
    int port() const;
    bool isProxy() const;

    void sendAuthToRequester(bool success, const QString &user, const QString &password);

private:
    void triggerDialog();

    net::AuthChallengeInfo m_authInfo;

    GURL m_url;
    LoginAuthRequiredCallback m_auth_required_callback;
    base::WeakPtrFactory<LoginDelegateQt> m_weakFactory;

    // This member is used to keep authentication dialog controller alive until
    // authorization is sent or cancelled.
    QSharedPointer<AuthenticationDialogController> m_dialogController;
};

} // namespace QtWebEngineCore

#endif // LOGIN_DELEGATE_QT_H