summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/Source/modules/notifications/NotificationPermissionClient.cpp
blob: 74e365ec7d7989437892dcd68aa9a0dc16b7ce1d (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
// 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.

#include "modules/notifications/NotificationPermissionClient.h"

#include "core/dom/Document.h"
#include "core/dom/ExecutionContext.h"
#include "core/frame/LocalFrame.h"

namespace blink {

const char* NotificationPermissionClient::supplementName()
{
    return "NotificationPermissionClient";
}

NotificationPermissionClient* NotificationPermissionClient::from(ExecutionContext* context)
{
    if (!context->isDocument())
        return nullptr;

    const Document* document = toDocument(context);
    if (!document->frame() || !document->frame()->isLocalFrame())
        return nullptr;

    return static_cast<NotificationPermissionClient*>(WillBeHeapSupplement<LocalFrame>::from(document->frame(), supplementName()));
}

void provideNotificationPermissionClientTo(LocalFrame& frame, PassOwnPtrWillBeRawPtr<NotificationPermissionClient> client)
{
    frame.provideSupplement(NotificationPermissionClient::supplementName(), client);
}

} // namespace blink