OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "modules/permissions/Permissions.h" | 6 #include "modules/permissions/Permissions.h" |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "bindings/modules/v8/V8MidiPermissionDescriptor.h" | 10 #include "bindings/modules/v8/V8MidiPermissionDescriptor.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 if (!client) | 41 if (!client) |
42 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "In its current state, the global scope can't query pe
rmissions.")); | 42 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "In its current state, the global scope can't query pe
rmissions.")); |
43 | 43 |
44 TrackExceptionState exceptionState; | 44 TrackExceptionState exceptionState; |
45 PermissionDescriptor permission = NativeValueTraits<PermissionDescriptor>::n
ativeValue(scriptState->isolate(), rawPermission.v8Value(), exceptionState); | 45 PermissionDescriptor permission = NativeValueTraits<PermissionDescriptor>::n
ativeValue(scriptState->isolate(), rawPermission.v8Value(), exceptionState); |
46 | 46 |
47 | 47 |
48 if (exceptionState.hadException()) | 48 if (exceptionState.hadException()) |
49 return ScriptPromise::reject(scriptState, v8::Exception::TypeError(v8Str
ing(scriptState->isolate(), exceptionState.message()))); | 49 return ScriptPromise::reject(scriptState, v8::Exception::TypeError(v8Str
ing(scriptState->isolate(), exceptionState.message()))); |
50 | 50 |
51 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); | 51 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
52 ScriptPromise promise = resolver->promise(); | 52 ScriptPromise promise = resolver->promise(); |
53 | 53 |
54 String name = permission.name(); | 54 String name = permission.name(); |
55 WebPermissionType type; | 55 WebPermissionType type; |
56 if (name == "geolocation") { | 56 if (name == "geolocation") { |
57 type = WebPermissionTypeGeolocation; | 57 type = WebPermissionTypeGeolocation; |
58 } else if (name == "notifications") { | 58 } else if (name == "notifications") { |
59 type = WebPermissionTypeNotifications; | 59 type = WebPermissionTypeNotifications; |
60 } else if (name == "push") { | 60 } else if (name == "push") { |
61 PushPermissionDescriptor pushPermission = NativeValueTraits<PushPermissi
onDescriptor>::nativeValue(scriptState->isolate(), rawPermission.v8Value(), exce
ptionState); | 61 PushPermissionDescriptor pushPermission = NativeValueTraits<PushPermissi
onDescriptor>::nativeValue(scriptState->isolate(), rawPermission.v8Value(), exce
ptionState); |
(...skipping 18 matching lines...) Expand all Loading... |
80 | 80 |
81 // If the current origin is a file scheme, it will unlikely return a | 81 // If the current origin is a file scheme, it will unlikely return a |
82 // meaningful value because most APIs are broken on file scheme and no | 82 // meaningful value because most APIs are broken on file scheme and no |
83 // permission prompt will be shown even if the returned permission will most | 83 // permission prompt will be shown even if the returned permission will most |
84 // likely be "prompt". | 84 // likely be "prompt". |
85 client->queryPermission(type, KURL(KURL(), scriptState->executionContext()->
securityOrigin()->toString()), new PermissionQueryCallback(resolver, type)); | 85 client->queryPermission(type, KURL(KURL(), scriptState->executionContext()->
securityOrigin()->toString()), new PermissionQueryCallback(resolver, type)); |
86 return promise; | 86 return promise; |
87 } | 87 } |
88 | 88 |
89 } // namespace blink | 89 } // namespace blink |
OLD | NEW |