Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/WebKit/Source/modules/notifications/NotificationManager.cpp

Issue 1995663003: Revert of Introduce the Blink NotificationService, move permission checks there (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "modules/notifications/NotificationManager.h"
6
7 #include "platform/weborigin/SecurityOrigin.h"
8 #include "public/platform/Platform.h"
9 #include "public/platform/ServiceRegistry.h"
10 #include "public/platform/modules/permissions/permission_status.mojom-blink.h"
11
12 namespace blink {
13
14 // static
15 NotificationManager* NotificationManager::from(ExecutionContext* executionContex t)
16 {
17 DCHECK(executionContext);
18 DCHECK(executionContext->isContextThread());
19
20 NotificationManager* manager = static_cast<NotificationManager*>(Supplement< ExecutionContext>::from(executionContext, supplementName()));
21 if (!manager) {
22 manager = new NotificationManager(executionContext);
23 Supplement<ExecutionContext>::provideTo(*executionContext, supplementNam e(), manager);
24 }
25
26 return manager;
27 }
28
29 // static
30 const char* NotificationManager::supplementName()
31 {
32 return "NotificationManager";
33 }
34
35 NotificationManager::NotificationManager(ExecutionContext* executionContext)
36 : ContextLifecycleObserver(executionContext)
37 {
38 Platform::current()->serviceRegistry()->connectToRemoteService(mojo::GetProx y(&m_service));
39 }
40
41 NotificationManager::~NotificationManager()
42 {
43 }
44
45 mojom::blink::PermissionStatus NotificationManager::permissionStatus() const
46 {
47 mojom::blink::PermissionStatus permissionStatus;
48
49 const bool result =
50 m_service->GetPermissionStatus(getExecutionContext()->getSecurityOrigin( )->toString(), &permissionStatus);
51 DCHECK(result);
52
53 return permissionStatus;
54 }
55
56 void NotificationManager::contextDestroyed()
57 {
58 m_service.reset();
59 }
60
61 DEFINE_TRACE(NotificationManager)
62 {
63 ContextLifecycleObserver::trace(visitor);
64 Supplement<ExecutionContext>::trace(visitor);
65 }
66
67 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698