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

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

Issue 2329463004: ABANDONED CL: Changes needed to make things compile after running rewrite_to_chrome_style tool. (Closed)
Patch Set: More fixes - things build fine at this point. Created 3 years, 8 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 "modules/permissions/Permissions.h" 5 #include "modules/permissions/Permissions.h"
6 6
7 #include "bindings/core/v8/Dictionary.h" 7 #include "bindings/core/v8/Dictionary.h"
8 #include "bindings/core/v8/Nullable.h" 8 #include "bindings/core/v8/Nullable.h"
9 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
(...skipping 29 matching lines...) Expand all
40 // |exceptionState| should be checked before attempting to use the returned 40 // |exceptionState| should be checked before attempting to use the returned
41 // permission as the non-null assert will be fired otherwise. 41 // permission as the non-null assert will be fired otherwise.
42 // 42 //
43 // Websites will be able to run code when `name()` is called, changing the 43 // Websites will be able to run code when `name()` is called, changing the
44 // current context. The caller should make sure that no assumption is made 44 // current context. The caller should make sure that no assumption is made
45 // after this has been called. 45 // after this has been called.
46 PermissionDescriptorPtr parsePermission(ScriptState* scriptState, 46 PermissionDescriptorPtr parsePermission(ScriptState* scriptState,
47 const Dictionary rawPermission, 47 const Dictionary rawPermission,
48 ExceptionState& exceptionState) { 48 ExceptionState& exceptionState) {
49 PermissionDescriptor permission = 49 PermissionDescriptor permission =
50 NativeValueTraits<PermissionDescriptor>::nativeValue( 50 NativeValueTraits<PermissionDescriptor>::NativeValue(
51 scriptState->isolate(), rawPermission.v8Value(), exceptionState); 51 scriptState->isolate(), rawPermission.v8Value(), exceptionState);
52 52
53 if (exceptionState.hadException()) { 53 if (exceptionState.hadException()) {
54 exceptionState.throwTypeError(exceptionState.message()); 54 exceptionState.throwTypeError(exceptionState.message());
55 return nullptr; 55 return nullptr;
56 } 56 }
57 57
58 const String& name = permission.name(); 58 const String& name = permission.name();
59 if (name == "geolocation") 59 if (name == "geolocation")
60 return createPermissionDescriptor(PermissionName::GEOLOCATION); 60 return createPermissionDescriptor(PermissionName::GEOLOCATION);
61 if (name == "notifications") 61 if (name == "notifications")
62 return createPermissionDescriptor(PermissionName::NOTIFICATIONS); 62 return createPermissionDescriptor(PermissionName::NOTIFICATIONS);
63 if (name == "push") { 63 if (name == "push") {
64 PushPermissionDescriptor pushPermission = 64 PushPermissionDescriptor pushPermission =
65 NativeValueTraits<PushPermissionDescriptor>::nativeValue( 65 NativeValueTraits<PushPermissionDescriptor>::NativeValue(
66 scriptState->isolate(), rawPermission.v8Value(), exceptionState); 66 scriptState->isolate(), rawPermission.v8Value(), exceptionState);
67 if (exceptionState.hadException()) { 67 if (exceptionState.hadException()) {
68 exceptionState.throwTypeError(exceptionState.message()); 68 exceptionState.throwTypeError(exceptionState.message());
69 return nullptr; 69 return nullptr;
70 } 70 }
71 71
72 // Only "userVisibleOnly" push is supported for now. 72 // Only "userVisibleOnly" push is supported for now.
73 if (!pushPermission.userVisibleOnly()) { 73 if (!pushPermission.userVisibleOnly()) {
74 exceptionState.throwDOMException( 74 exceptionState.throwDOMException(
75 NotSupportedError, 75 NotSupportedError,
76 "Push Permission without userVisibleOnly:true isn't supported yet."); 76 "Push Permission without userVisibleOnly:true isn't supported yet.");
77 return nullptr; 77 return nullptr;
78 } 78 }
79 79
80 return createPermissionDescriptor(PermissionName::PUSH_NOTIFICATIONS); 80 return createPermissionDescriptor(PermissionName::PUSH_NOTIFICATIONS);
81 } 81 }
82 if (name == "midi") { 82 if (name == "midi") {
83 MidiPermissionDescriptor midiPermission = 83 MidiPermissionDescriptor midiPermission =
84 NativeValueTraits<MidiPermissionDescriptor>::nativeValue( 84 NativeValueTraits<MidiPermissionDescriptor>::NativeValue(
85 scriptState->isolate(), rawPermission.v8Value(), exceptionState); 85 scriptState->isolate(), rawPermission.v8Value(), exceptionState);
86 return createMidiPermissionDescriptor(midiPermission.sysex()); 86 return createMidiPermissionDescriptor(midiPermission.sysex());
87 } 87 }
88 if (name == "background-sync") 88 if (name == "background-sync")
89 return createPermissionDescriptor(PermissionName::BACKGROUND_SYNC); 89 return createPermissionDescriptor(PermissionName::BACKGROUND_SYNC);
90 90
91 return nullptr; 91 return nullptr;
92 } 92 }
93 93
94 } // anonymous namespace 94 } // anonymous namespace
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 result.reserveInitialCapacity(callerIndexToInternalIndex.size()); 294 result.reserveInitialCapacity(callerIndexToInternalIndex.size());
295 for (int internalIndex : callerIndexToInternalIndex) { 295 for (int internalIndex : callerIndexToInternalIndex) {
296 result.push_back(PermissionStatus::createAndListen( 296 result.push_back(PermissionStatus::createAndListen(
297 resolver->getExecutionContext(), results[internalIndex], 297 resolver->getExecutionContext(), results[internalIndex],
298 descriptors[internalIndex]->Clone())); 298 descriptors[internalIndex]->Clone()));
299 } 299 }
300 resolver->resolve(result); 300 resolver->resolve(result);
301 } 301 }
302 302
303 } // namespace blink 303 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698