OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "NotificationCenter.h" | 35 #include "NotificationCenter.h" |
36 | 36 |
37 #include "Document.h" | 37 #include "Document.h" |
38 #include "VoidCallback.h" | 38 #include "VoidCallback.h" |
39 #include "WorkerContext.h" | 39 #include "WorkerContext.h" |
40 | 40 |
41 namespace WebCore { | 41 namespace WebCore { |
42 | 42 |
43 NotificationCenter::NotificationCenter(ScriptExecutionContext* context, Notifica
tionPresenter* presenter) | 43 NotificationCenter::NotificationCenter(ScriptExecutionContext* context, Notifica
tionPresenter* presenter) |
44 : ActiveDOMObject(context, this) | 44 : ActiveDOMObject(context, this) |
45 , m_scriptExecutionContext(context) | |
46 , m_notificationPresenter(presenter) {} | 45 , m_notificationPresenter(presenter) {} |
47 | 46 |
48 int NotificationCenter::checkPermission() | 47 int NotificationCenter::checkPermission() |
49 { | 48 { |
50 if (!presenter()) | 49 if (!presenter() || !scriptExecutionContext()) |
51 return NotificationPresenter::PermissionDenied; | 50 return NotificationPresenter::PermissionDenied; |
52 return m_notificationPresenter->checkPermission(m_scriptExecutionContext); | 51 return m_notificationPresenter->checkPermission(scriptExecutionContext()); |
53 } | 52 } |
54 | 53 |
55 void NotificationCenter::requestPermission(PassRefPtr<VoidCallback> callback) | 54 void NotificationCenter::requestPermission(PassRefPtr<VoidCallback> callback) |
56 { | 55 { |
57 if (!presenter()) | 56 if (!presenter() || !scriptExecutionContext()) |
58 return; | 57 return; |
59 m_notificationPresenter->requestPermission(m_scriptExecutionContext, callbac
k); | 58 m_notificationPresenter->requestPermission(scriptExecutionContext(), callbac
k); |
60 } | 59 } |
61 | 60 |
62 void NotificationCenter::disconnectFrame() | 61 void NotificationCenter::disconnectFrame() |
63 { | 62 { |
64 // m_notificationPresenter should never be 0. But just to be safe, we check
it here. | 63 // m_notificationPresenter should never be 0. But just to be safe, we check
it here. |
65 // Due to the mysterious bug http://code.google.com/p/chromium/issues/detail
?id=49323. | 64 // Due to the mysterious bug http://code.google.com/p/chromium/issues/detail
?id=49323. |
66 ASSERT(m_notificationPresenter); | 65 ASSERT(m_notificationPresenter); |
67 if (!m_notificationPresenter) | 66 if (!m_notificationPresenter) |
68 return; | 67 return; |
69 m_notificationPresenter->cancelRequestsForPermission(m_scriptExecutionContex
t); | 68 m_notificationPresenter->cancelRequestsForPermission(scriptExecutionContext(
)); |
70 m_notificationPresenter = 0; | 69 m_notificationPresenter = 0; |
71 m_scriptExecutionContext = 0; | |
72 } | 70 } |
73 | 71 |
74 } // namespace WebCore | 72 } // namespace WebCore |
75 | 73 |
76 #endif // ENABLE(NOTIFICATIONS) | 74 #endif // ENABLE(NOTIFICATIONS) |
OLD | NEW |