| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 return throwError(ec); | 74 return throwError(ec); |
| 75 | 75 |
| 76 notification->ref(); | 76 notification->ref(); |
| 77 return toV8(notification.get()); | 77 return toV8(notification.get()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 v8::Handle<v8::Value> V8NotificationCenter::requestPermissionCallback(const v8::
Arguments& args) | 80 v8::Handle<v8::Value> V8NotificationCenter::requestPermissionCallback(const v8::
Arguments& args) |
| 81 { | 81 { |
| 82 INC_STATS(L"DOM.NotificationCenter.RequestPermission()"); | 82 INC_STATS(L"DOM.NotificationCenter.RequestPermission()"); |
| 83 NotificationCenter* notificationCenter = V8NotificationCenter::toNative(args
.Holder()); | 83 NotificationCenter* notificationCenter = V8NotificationCenter::toNative(args
.Holder()); |
| 84 ScriptExecutionContext* context = notificationCenter->context(); | 84 ScriptExecutionContext* context = notificationCenter->scriptExecutionContext
(); |
| 85 | 85 |
| 86 // Make sure that script execution context is valid. | 86 // Make sure that script execution context is valid. |
| 87 if (!context) | 87 if (!context) |
| 88 return throwError(INVALID_STATE_ERR); | 88 return throwError(INVALID_STATE_ERR); |
| 89 | 89 |
| 90 // Requesting permission is only valid from a page context. | 90 // Requesting permission is only valid from a page context. |
| 91 if (context->isWorkerContext()) | 91 if (context->isWorkerContext()) |
| 92 return throwError(NOT_SUPPORTED_ERR); | 92 return throwError(NOT_SUPPORTED_ERR); |
| 93 | 93 |
| 94 RefPtr<V8CustomVoidCallback> callback; | 94 RefPtr<V8CustomVoidCallback> callback; |
| 95 if (args.Length() > 0) { | 95 if (args.Length() > 0) { |
| 96 if (!args[0]->IsObject()) | 96 if (!args[0]->IsObject()) |
| 97 return throwError("Callback must be of valid type.", V8Proxy::TypeEr
ror); | 97 return throwError("Callback must be of valid type.", V8Proxy::TypeEr
ror); |
| 98 | 98 |
| 99 callback = V8CustomVoidCallback::create(args[0], context); | 99 callback = V8CustomVoidCallback::create(args[0], context); |
| 100 } | 100 } |
| 101 | 101 |
| 102 notificationCenter->requestPermission(callback.release()); | 102 notificationCenter->requestPermission(callback.release()); |
| 103 return v8::Undefined(); | 103 return v8::Undefined(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 | 106 |
| 107 } // namespace WebCore | 107 } // namespace WebCore |
| 108 | 108 |
| 109 #endif // ENABLE(NOTIFICATIONS) | 109 #endif // ENABLE(NOTIFICATIONS) |
| OLD | NEW |