Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: Source/modules/permissions/Permissions.cpp

Issue 1233173002: Have ScriptPromiseResolver on the Oilpan heap always. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: smaller review updates Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 if (!client) 44 if (!client)
45 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, "In its current state, the global scope can't query pe rmissions.")); 45 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, "In its current state, the global scope can't query pe rmissions."));
46 46
47 TrackExceptionState exceptionState; 47 TrackExceptionState exceptionState;
48 PermissionDescriptor permission = NativeValueTraits<PermissionDescriptor>::n ativeValue(scriptState->isolate(), rawPermission.v8Value(), exceptionState); 48 PermissionDescriptor permission = NativeValueTraits<PermissionDescriptor>::n ativeValue(scriptState->isolate(), rawPermission.v8Value(), exceptionState);
49 49
50 50
51 if (exceptionState.hadException()) 51 if (exceptionState.hadException())
52 return ScriptPromise::reject(scriptState, v8::Exception::TypeError(v8Str ing(scriptState->isolate(), exceptionState.message()))); 52 return ScriptPromise::reject(scriptState, v8::Exception::TypeError(v8Str ing(scriptState->isolate(), exceptionState.message())));
53 53
54 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); 54 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
55 ScriptPromise promise = resolver->promise(); 55 ScriptPromise promise = resolver->promise();
56 56
57 String name = permission.name(); 57 String name = permission.name();
58 WebPermissionType type; 58 WebPermissionType type;
59 if (name == "geolocation") { 59 if (name == "geolocation") {
60 type = WebPermissionTypeGeolocation; 60 type = WebPermissionTypeGeolocation;
61 } else if (name == "notifications") { 61 } else if (name == "notifications") {
62 type = WebPermissionTypeNotifications; 62 type = WebPermissionTypeNotifications;
63 } else if (name == "push") { 63 } else if (name == "push") {
64 PushPermissionDescriptor pushPermission = NativeValueTraits<PushPermissi onDescriptor>::nativeValue(scriptState->isolate(), rawPermission.v8Value(), exce ptionState); 64 PushPermissionDescriptor pushPermission = NativeValueTraits<PushPermissi onDescriptor>::nativeValue(scriptState->isolate(), rawPermission.v8Value(), exce ptionState);
(...skipping 18 matching lines...) Expand all
83 83
84 // If the current origin is a file scheme, it will unlikely return a 84 // If the current origin is a file scheme, it will unlikely return a
85 // meaningful value because most APIs are broken on file scheme and no 85 // meaningful value because most APIs are broken on file scheme and no
86 // permission prompt will be shown even if the returned permission will most 86 // permission prompt will be shown even if the returned permission will most
87 // likely be "prompt". 87 // likely be "prompt".
88 client->queryPermission(type, KURL(KURL(), scriptState->executionContext()-> securityOrigin()->toString()), new PermissionQueryCallback(resolver, type)); 88 client->queryPermission(type, KURL(KURL(), scriptState->executionContext()-> securityOrigin()->toString()), new PermissionQueryCallback(resolver, type));
89 return promise; 89 return promise;
90 } 90 }
91 91
92 } // namespace blink 92 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698