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 29 matching lines...) Expand all Loading... |
40 #include "Notification.h" | 40 #include "Notification.h" |
41 #include "NotificationCenter.h" | 41 #include "NotificationCenter.h" |
42 #include <runtime/Error.h> | 42 #include <runtime/Error.h> |
43 | 43 |
44 using namespace JSC; | 44 using namespace JSC; |
45 | 45 |
46 namespace WebCore { | 46 namespace WebCore { |
47 | 47 |
48 JSValue JSNotificationCenter::requestPermission(ExecState* exec) | 48 JSValue JSNotificationCenter::requestPermission(ExecState* exec) |
49 { | 49 { |
50 ScriptExecutionContext* context = impl()->context(); | 50 ScriptExecutionContext* context = impl()->scriptExecutionContext(); |
51 | 51 |
52 // Make sure that script execution context is valid. | 52 // Make sure that script execution context is valid. |
53 if (!context) { | 53 if (!context) { |
54 setDOMException(exec, INVALID_STATE_ERR); | 54 setDOMException(exec, INVALID_STATE_ERR); |
55 return jsUndefined(); | 55 return jsUndefined(); |
56 } | 56 } |
57 | 57 |
58 // Permission request is only valid from page context. | 58 // Permission request is only valid from page context. |
59 if (context->isWorkerContext()) | 59 if (context->isWorkerContext()) |
60 return throwSyntaxError(exec); | 60 return throwSyntaxError(exec); |
61 | 61 |
62 if (!exec->argument(0).isObject()) | 62 if (!exec->argument(0).isObject()) |
63 return throwTypeError(exec); | 63 return throwTypeError(exec); |
64 | 64 |
65 PassRefPtr<JSCustomVoidCallback> callback = JSCustomVoidCallback::create(exe
c->argument(0).getObject(), toJSDOMGlobalObject(static_cast<Document*>(context),
exec)); | 65 PassRefPtr<JSCustomVoidCallback> callback = JSCustomVoidCallback::create(exe
c->argument(0).getObject(), toJSDOMGlobalObject(static_cast<Document*>(context),
exec)); |
66 | 66 |
67 impl()->requestPermission(callback); | 67 impl()->requestPermission(callback); |
68 return jsUndefined(); | 68 return jsUndefined(); |
69 } | 69 } |
70 | 70 |
71 } // namespace | 71 } // namespace |
72 | 72 |
73 #endif // ENABLE(NOTIFICATIONS) | 73 #endif // ENABLE(NOTIFICATIONS) |
OLD | NEW |