| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 21 matching lines...) Expand all Loading... |
| 32 #include "modules/notifications/Notification.h" | 32 #include "modules/notifications/Notification.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/Dictionary.h" | 34 #include "bindings/core/v8/Dictionary.h" |
| 35 #include "bindings/core/v8/ScriptWrappable.h" | 35 #include "bindings/core/v8/ScriptWrappable.h" |
| 36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| 37 #include "core/events/Event.h" | 37 #include "core/events/Event.h" |
| 38 #include "core/frame/UseCounter.h" | 38 #include "core/frame/UseCounter.h" |
| 39 #include "core/page/WindowFocusAllowedIndicator.h" | 39 #include "core/page/WindowFocusAllowedIndicator.h" |
| 40 #include "modules/notifications/NotificationClient.h" | 40 #include "modules/notifications/NotificationClient.h" |
| 41 #include "modules/notifications/NotificationController.h" | 41 #include "modules/notifications/NotificationController.h" |
| 42 #include "modules/notifications/NotificationPermissionClient.h" |
| 42 | 43 |
| 43 namespace blink { | 44 namespace blink { |
| 44 | 45 |
| 45 Notification* Notification::create(ExecutionContext* context, const String& titl
e, const Dictionary& options) | 46 Notification* Notification::create(ExecutionContext* context, const String& titl
e, const Dictionary& options) |
| 46 { | 47 { |
| 47 NotificationClient& client = NotificationController::clientFrom(context); | 48 NotificationClient& client = NotificationController::clientFrom(context); |
| 48 Notification* notification = adoptRefCountedGarbageCollectedWillBeNoop(new N
otification(title, context, &client)); | 49 Notification* notification = adoptRefCountedGarbageCollectedWillBeNoop(new N
otification(title, context, &client)); |
| 49 | 50 |
| 50 String argument; | 51 String argument; |
| 51 if (DictionaryHelper::get(options, "body", argument)) | 52 if (DictionaryHelper::get(options, "body", argument)) |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 162 } |
| 162 | 163 |
| 163 const String& Notification::permission(ExecutionContext* context) | 164 const String& Notification::permission(ExecutionContext* context) |
| 164 { | 165 { |
| 165 UseCounter::count(context, UseCounter::NotificationPermission); | 166 UseCounter::count(context, UseCounter::NotificationPermission); |
| 166 return permissionString(NotificationController::clientFrom(context).checkPer
mission(context)); | 167 return permissionString(NotificationController::clientFrom(context).checkPer
mission(context)); |
| 167 } | 168 } |
| 168 | 169 |
| 169 void Notification::requestPermission(ExecutionContext* context, PassOwnPtr<Notif
icationPermissionCallback> callback) | 170 void Notification::requestPermission(ExecutionContext* context, PassOwnPtr<Notif
icationPermissionCallback> callback) |
| 170 { | 171 { |
| 171 ASSERT(toDocument(context)->page()); | 172 // FIXME: Assert that this code-path will only be reached for Document envir
onments |
| 172 NotificationController::clientFrom(context).requestPermission(context, callb
ack); | 173 // when Blink supports [Exposed] annotations on class members in IDL definit
ions. |
| 174 |
| 175 if (NotificationPermissionClient* permissionClient = NotificationPermissionC
lient::from(context)) { |
| 176 permissionClient->requestPermission(context, callback); |
| 177 return; |
| 178 } |
| 173 } | 179 } |
| 174 | 180 |
| 175 bool Notification::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) | 181 bool Notification::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) |
| 176 { | 182 { |
| 177 ASSERT(m_state != NotificationStateClosed); | 183 ASSERT(m_state != NotificationStateClosed); |
| 178 | 184 |
| 179 return EventTarget::dispatchEvent(event); | 185 return EventTarget::dispatchEvent(event); |
| 180 } | 186 } |
| 181 | 187 |
| 182 const AtomicString& Notification::interfaceName() const | 188 const AtomicString& Notification::interfaceName() const |
| (...skipping 12 matching lines...) Expand all Loading... |
| 195 | 201 |
| 196 m_asyncRunner.stop(); | 202 m_asyncRunner.stop(); |
| 197 } | 203 } |
| 198 | 204 |
| 199 bool Notification::hasPendingActivity() const | 205 bool Notification::hasPendingActivity() const |
| 200 { | 206 { |
| 201 return m_state == NotificationStateShowing || m_asyncRunner.isActive(); | 207 return m_state == NotificationStateShowing || m_asyncRunner.isActive(); |
| 202 } | 208 } |
| 203 | 209 |
| 204 } // namespace blink | 210 } // namespace blink |
| OLD | NEW |