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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 ScriptPromise promise = resolver->promise(); | 57 ScriptPromise promise = resolver->promise(); |
58 | 58 |
59 String name = permission.name(); | 59 String name = permission.name(); |
60 WebPermissionType type; | 60 WebPermissionType type; |
61 if (name == "geolocation") { | 61 if (name == "geolocation") { |
62 type = WebPermissionTypeGeolocation; | 62 type = WebPermissionTypeGeolocation; |
63 } else if (name == "notifications") { | 63 } else if (name == "notifications") { |
64 type = WebPermissionTypeNotifications; | 64 type = WebPermissionTypeNotifications; |
65 } else if (name == "push") { | 65 } else if (name == "push") { |
66 PushPermissionDescriptor pushPermission = NativeValueTraits<PushPermissi
onDescriptor>::nativeValue(scriptState->isolate(), rawPermission.v8Value(), exce
ptionState); | 66 PushPermissionDescriptor pushPermission = NativeValueTraits<PushPermissi
onDescriptor>::nativeValue(scriptState->isolate(), rawPermission.v8Value(), exce
ptionState); |
67 // The only "userVisible" push is supported for now. | 67 // Only "userVisible" push is supported for now. |
68 if (!pushPermission.userVisible()) { | 68 if (!pushPermission.userVisible()) { |
69 resolver->resolve(new PermissionStatus(scriptState->executionContext
(), WebPermissionStatusDenied)); | 69 resolver->resolve(PermissionStatus::create(scriptState->executionCon
text(), WebPermissionStatusDenied, WebPermissionTypePush)); |
70 return promise; | 70 return promise; |
71 } | 71 } |
72 type = WebPermissionTypePushNotifications; | 72 type = WebPermissionTypePushNotifications; |
73 } else if (name == "midi") { | 73 } else if (name == "midi") { |
74 MidiPermissionDescriptor midiPermission = NativeValueTraits<MidiPermissi
onDescriptor>::nativeValue(scriptState->isolate(), rawPermission.v8Value(), exce
ptionState); | 74 MidiPermissionDescriptor midiPermission = NativeValueTraits<MidiPermissi
onDescriptor>::nativeValue(scriptState->isolate(), rawPermission.v8Value(), exce
ptionState); |
75 // Only sysex usage requires a permission for now. | 75 // Only sysex usage requires a permission for now. |
76 if (!midiPermission.sysex()) { | 76 if (!midiPermission.sysex()) { |
77 resolver->resolve(new PermissionStatus(scriptState->executionContext
(), WebPermissionStatusGranted)); | 77 resolver->resolve(PermissionStatus::create(scriptState->executionCon
text(), WebPermissionStatusGranted, WebPermissionTypeMidi)); |
78 return promise; | 78 return promise; |
79 } | 79 } |
80 type = WebPermissionTypeMidiSysEx; | 80 type = WebPermissionTypeMidiSysEx; |
81 } else { | 81 } else { |
82 ASSERT_NOT_REACHED(); | 82 ASSERT_NOT_REACHED(); |
83 type = WebPermissionTypeGeolocation; | 83 type = WebPermissionTypeGeolocation; |
84 } | 84 } |
85 | 85 |
86 // If the current origin is a file scheme, it will unlikely return a | 86 // If the current origin is a file scheme, it will unlikely return a |
87 // meaningful value because most APIs are broken on file scheme and no | 87 // meaningful value because most APIs are broken on file scheme and no |
88 // permission prompt will be shown even if the returned permission will most | 88 // permission prompt will be shown even if the returned permission will most |
89 // likely be "prompt". | 89 // likely be "prompt". |
90 client->queryPermission(type, KURL(KURL(), scriptState->executionContext()->
securityOrigin()->toString()), new PermissionQueryCallback(resolver, type)); | 90 client->queryPermission(type, KURL(KURL(), scriptState->executionContext()->
securityOrigin()->toString()), new PermissionQueryCallback(resolver, type)); |
91 return promise; | 91 return promise; |
92 } | 92 } |
93 | 93 |
94 } // namespace blink | 94 } // namespace blink |
OLD | NEW |