Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/notifications/NotificationManager.h" | 5 #include "modules/notifications/NotificationManager.h" |
| 6 | 6 |
| 7 #include "platform/weborigin/SecurityOrigin.h" | 7 #include "platform/weborigin/SecurityOrigin.h" |
| 8 #include "public/platform/InterfaceProvider.h" | |
| 8 #include "public/platform/Platform.h" | 9 #include "public/platform/Platform.h" |
| 9 #include "public/platform/ServiceRegistry.h" | |
| 10 #include "public/platform/modules/permissions/permission_status.mojom-blink.h" | 10 #include "public/platform/modules/permissions/permission_status.mojom-blink.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 // static | 14 // static |
| 15 NotificationManager* NotificationManager::from(ExecutionContext* executionContex t) | 15 NotificationManager* NotificationManager::from(ExecutionContext* executionContex t) |
| 16 { | 16 { |
| 17 DCHECK(executionContext); | 17 DCHECK(executionContext); |
| 18 DCHECK(executionContext->isContextThread()); | 18 DCHECK(executionContext->isContextThread()); |
| 19 | 19 |
| 20 NotificationManager* manager = static_cast<NotificationManager*>(Supplement< ExecutionContext>::from(executionContext, supplementName())); | 20 NotificationManager* manager = static_cast<NotificationManager*>(Supplement< ExecutionContext>::from(executionContext, supplementName())); |
| 21 if (!manager) { | 21 if (!manager) { |
| 22 manager = new NotificationManager(executionContext); | 22 manager = new NotificationManager(executionContext); |
| 23 Supplement<ExecutionContext>::provideTo(*executionContext, supplementNam e(), manager); | 23 Supplement<ExecutionContext>::provideTo(*executionContext, supplementNam e(), manager); |
| 24 } | 24 } |
| 25 | 25 |
| 26 return manager; | 26 return manager; |
| 27 } | 27 } |
| 28 | 28 |
| 29 // static | 29 // static |
| 30 const char* NotificationManager::supplementName() | 30 const char* NotificationManager::supplementName() |
| 31 { | 31 { |
| 32 return "NotificationManager"; | 32 return "NotificationManager"; |
| 33 } | 33 } |
| 34 | 34 |
| 35 NotificationManager::NotificationManager(ExecutionContext* executionContext) | 35 NotificationManager::NotificationManager(ExecutionContext* executionContext) |
| 36 : ContextLifecycleObserver(executionContext) | 36 : ContextLifecycleObserver(executionContext) |
| 37 { | 37 { |
| 38 Platform::current()->serviceRegistry()->connectToRemoteService(mojo::GetProx y(&m_service)); | 38 Platform::current()->interfaceProvider()->getInterface(mojo::GetProxy(&m_ser vice)); |
|
haraken
2016/07/30 15:39:06
Not directly related to this CL, should we try to
| |
| 39 } | 39 } |
| 40 | 40 |
| 41 NotificationManager::~NotificationManager() | 41 NotificationManager::~NotificationManager() |
| 42 { | 42 { |
| 43 } | 43 } |
| 44 | 44 |
| 45 mojom::blink::PermissionStatus NotificationManager::permissionStatus() const | 45 mojom::blink::PermissionStatus NotificationManager::permissionStatus() const |
| 46 { | 46 { |
| 47 mojom::blink::PermissionStatus permissionStatus; | 47 mojom::blink::PermissionStatus permissionStatus; |
| 48 | 48 |
| 49 const bool result = | 49 const bool result = |
| 50 m_service->GetPermissionStatus(getExecutionContext()->getSecurityOrigin( )->toString(), &permissionStatus); | 50 m_service->GetPermissionStatus(getExecutionContext()->getSecurityOrigin( )->toString(), &permissionStatus); |
| 51 DCHECK(result); | 51 DCHECK(result); |
| 52 | 52 |
| 53 return permissionStatus; | 53 return permissionStatus; |
| 54 } | 54 } |
| 55 | 55 |
| 56 void NotificationManager::contextDestroyed() | 56 void NotificationManager::contextDestroyed() |
| 57 { | 57 { |
| 58 m_service.reset(); | 58 m_service.reset(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 DEFINE_TRACE(NotificationManager) | 61 DEFINE_TRACE(NotificationManager) |
| 62 { | 62 { |
| 63 ContextLifecycleObserver::trace(visitor); | 63 ContextLifecycleObserver::trace(visitor); |
| 64 Supplement<ExecutionContext>::trace(visitor); | 64 Supplement<ExecutionContext>::trace(visitor); |
| 65 } | 65 } |
| 66 | 66 |
| 67 } // namespace blink | 67 } // namespace blink |
| OLD | NEW |