summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/Source/modules/credentialmanager/CredentialManagerClient.h
blob: d7233f2c3585f9a9c0ddb27e5a8dd3891ab9200a (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
// Copyright 2014 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.

#ifndef CredentialManagerClient_h
#define CredentialManagerClient_h

#include "core/page/Page.h"
#include "modules/ModulesExport.h"
#include "platform/Supplementable.h"
#include "public/platform/WebCredentialManagerClient.h"
#include "public/platform/WebVector.h"

namespace blink {

class ExecutionContext;
class Page;
class WebCredential;
class WebURL;

// CredentialManagerClient lives as a supplement to Page, and wraps the embedder-provided
// WebCredentialManagerClient's methods to make them visible to the bindings code.
class MODULES_EXPORT CredentialManagerClient final : public NoBaseWillBeGarbageCollectedFinalized<CredentialManagerClient>, public WillBeHeapSupplement<Page> {
    WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(CredentialManagerClient);
    USING_FAST_MALLOC_WILL_BE_REMOVED(CredentialManagerClient);
public:
    explicit CredentialManagerClient(WebCredentialManagerClient*);
    virtual ~CredentialManagerClient();
    DECLARE_VIRTUAL_TRACE();

    static const char* supplementName();
    static CredentialManagerClient* from(Page*);
    static CredentialManagerClient* from(ExecutionContext*);

    // Ownership of the callback is transferred to the callee for each of
    // the following methods.
    virtual void dispatchFailedSignIn(const WebCredential&, WebCredentialManagerClient::NotificationCallbacks*);
    virtual void dispatchStore(const WebCredential&, WebCredentialManagerClient::NotificationCallbacks*);
    virtual void dispatchRequireUserMediation(WebCredentialManagerClient::NotificationCallbacks*);
    virtual void dispatchGet(bool zeroClickOnly, const WebVector<WebURL>& federations, WebCredentialManagerClient::RequestCallbacks*);

private:
    WebCredentialManagerClient* m_client;
};

MODULES_EXPORT void provideCredentialManagerClientTo(Page&, CredentialManagerClient*);

} // namespace blink

#endif // CredentialManagerClient_h