Chromium Code Reviews| 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 NotificationPermissionClient* permissionClient = NotificationPermissionClien t::from(context); |
| 172 NotificationController::clientFrom(context).requestPermission(context, callb ack); | 173 if (permissionClient) { |
|
abarth-chromium
2014/07/29 16:52:29
You can merge these two lines.
Peter Beverloo
2014/07/30 11:22:55
Done.
| |
| 174 permissionClient->requestPermission(context, callback); | |
| 175 return; | |
| 176 } | |
| 177 | |
| 178 // FIXME: What is the intended behavior for Notification.requestPermission w hen called | |
| 179 // from a Worker context? Should it be a no-op, or should |callback| be invo ked with | |
| 180 // the current permission level? | |
|
Peter Beverloo
2014/07/28 17:03:16
note: I've sent an e-mail to the WHATWG list to cl
| |
| 173 } | 181 } |
| 174 | 182 |
| 175 bool Notification::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) | 183 bool Notification::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) |
| 176 { | 184 { |
| 177 ASSERT(m_state != NotificationStateClosed); | 185 ASSERT(m_state != NotificationStateClosed); |
| 178 | 186 |
| 179 return EventTarget::dispatchEvent(event); | 187 return EventTarget::dispatchEvent(event); |
| 180 } | 188 } |
| 181 | 189 |
| 182 const AtomicString& Notification::interfaceName() const | 190 const AtomicString& Notification::interfaceName() const |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 195 | 203 |
| 196 m_asyncRunner.stop(); | 204 m_asyncRunner.stop(); |
| 197 } | 205 } |
| 198 | 206 |
| 199 bool Notification::hasPendingActivity() const | 207 bool Notification::hasPendingActivity() const |
| 200 { | 208 { |
| 201 return m_state == NotificationStateShowing || m_asyncRunner.isActive(); | 209 return m_state == NotificationStateShowing || m_asyncRunner.isActive(); |
| 202 } | 210 } |
| 203 | 211 |
| 204 } // namespace blink | 212 } // namespace blink |
| OLD | NEW |