1197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch// Copyright 2014 The Chromium Authors. All rights reserved.
2197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch// Use of this source code is governed by a BSD-style license that can be
3197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch// found in the LICENSE file.
4197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
5197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "config.h"
6197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "modules/notifications/NotificationPermissionClient.h"
7197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
8197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "core/dom/Document.h"
9197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "core/dom/ExecutionContext.h"
10197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "core/frame/LocalFrame.h"
11197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
12c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
13197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
14197021e6b966cfb06891637935ef33fff06433d1Ben Murdochconst char* NotificationPermissionClient::supplementName()
15197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{
16197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    return "NotificationPermissionClient";
17197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}
18197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
19197021e6b966cfb06891637935ef33fff06433d1Ben MurdochNotificationPermissionClient* NotificationPermissionClient::from(ExecutionContext* context)
20197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{
21197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    if (!context->isDocument())
22197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch        return 0;
23197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
24197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    const Document* document = toDocument(context);
25197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    ASSERT(document->frame());
26197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
27197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    if (!document->frame()->isLocalFrame())
28197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch        return 0;
29197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
30197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    return static_cast<NotificationPermissionClient*>(WillBeHeapSupplement<LocalFrame>::from(document->frame(), supplementName()));
31197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}
32197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
339e12abdf8c3a23d52091ea54ebb6a04d327f9300Torne (Richard Coles)void provideNotificationPermissionClientTo(LocalFrame& frame, PassOwnPtrWillBeRawPtr<NotificationPermissionClient> client)
34197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{
35197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    frame.provideSupplement(NotificationPermissionClient::supplementName(), client);
36197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}
37197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
38197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}
39