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

Side by Side Diff: Source/modules/webmidi/MIDIAccess.cpp

Issue 208243014: Add sysexEnabled readonly attribute to MIDIAccess (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rename everything in blink Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 MIDIAccess::~MIDIAccess() 79 MIDIAccess::~MIDIAccess()
80 { 80 {
81 } 81 }
82 82
83 MIDIAccess::MIDIAccess(const MIDIOptions& options, ExecutionContext* context) 83 MIDIAccess::MIDIAccess(const MIDIOptions& options, ExecutionContext* context)
84 : ActiveDOMObject(context) 84 : ActiveDOMObject(context)
85 , m_state(Requesting) 85 , m_state(Requesting)
86 , m_weakPtrFactory(this) 86 , m_weakPtrFactory(this)
87 , m_options(options) 87 , m_options(options)
88 , m_sysExEnabled(false) 88 , m_sysexEnabled(false)
89 , m_asyncResolveRunner(this, &MIDIAccess::resolveNow) 89 , m_asyncResolveRunner(this, &MIDIAccess::resolveNow)
90 , m_asyncRejectRunner(this, &MIDIAccess::rejectNow) 90 , m_asyncRejectRunner(this, &MIDIAccess::rejectNow)
91 { 91 {
92 ScriptWrappable::init(this); 92 ScriptWrappable::init(this);
93 m_accessor = MIDIAccessor::create(this); 93 m_accessor = MIDIAccessor::create(this);
94 } 94 }
95 95
96 void MIDIAccess::setSysExEnabled(bool enable) 96 void MIDIAccess::setSysexEnabled(bool enable)
97 { 97 {
98 m_sysExEnabled = enable; 98 m_sysexEnabled = enable;
99 if (enable) { 99 if (enable) {
100 m_accessor->startSession(); 100 m_accessor->startSession();
101 } else { 101 } else {
102 reject(DOMError::create("SecurityError")); 102 reject(DOMError::create("SecurityError"));
103 } 103 }
104 } 104 }
105 105
106 void MIDIAccess::didAddInputPort(const String& id, const String& manufacturer, c onst String& name, const String& version) 106 void MIDIAccess::didAddInputPort(const String& id, const String& manufacturer, c onst String& name, const String& version)
107 { 107 {
108 ASSERT(isMainThread()); 108 ASSERT(isMainThread());
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 m_error.clear(); 185 m_error.clear();
186 m_accessor.clear(); 186 m_accessor.clear();
187 m_asyncResolveRunner.stop(); 187 m_asyncResolveRunner.stop();
188 m_asyncRejectRunner.stop(); 188 m_asyncRejectRunner.stop();
189 m_weakPtrFactory.revokeAll(); 189 m_weakPtrFactory.revokeAll();
190 if (m_state == Requesting) { 190 if (m_state == Requesting) {
191 Document* document = toDocument(executionContext()); 191 Document* document = toDocument(executionContext());
192 ASSERT(document); 192 ASSERT(document);
193 MIDIController* controller = MIDIController::from(document->page()); 193 MIDIController* controller = MIDIController::from(document->page());
194 ASSERT(controller); 194 ASSERT(controller);
195 controller->cancelSysExPermissionRequest(this); 195 controller->cancelSysexPermissionRequest(this);
196 } 196 }
197 m_state = Stopped; 197 m_state = Stopped;
198 } 198 }
199 199
200 bool MIDIAccess::hasPendingActivity() const 200 bool MIDIAccess::hasPendingActivity() const
201 { 201 {
202 return m_state == Requesting; 202 return m_state == Requesting;
203 } 203 }
204 204
205 void MIDIAccess::permissionDenied() 205 void MIDIAccess::permissionDenied()
(...skipping 10 matching lines...) Expand all
216 PostAction::create(toIsolate(executionContext()), m_weakPtrFactory.creat eWeakPtr(), Stopped)); 216 PostAction::create(toIsolate(executionContext()), m_weakPtrFactory.creat eWeakPtr(), Stopped));
217 217
218 if (!m_options.sysex) { 218 if (!m_options.sysex) {
219 m_accessor->startSession(); 219 m_accessor->startSession();
220 return promise; 220 return promise;
221 } 221 }
222 Document* document = toDocument(executionContext()); 222 Document* document = toDocument(executionContext());
223 ASSERT(document); 223 ASSERT(document);
224 MIDIController* controller = MIDIController::from(document->page()); 224 MIDIController* controller = MIDIController::from(document->page());
225 if (controller) { 225 if (controller) {
226 controller->requestSysExPermission(this); 226 controller->requestSysexPermission(this);
227 } else { 227 } else {
228 reject(DOMError::create("SecurityError")); 228 reject(DOMError::create("SecurityError"));
229 } 229 }
230 return promise; 230 return promise;
231 } 231 }
232 232
233 void MIDIAccess::resolve() 233 void MIDIAccess::resolve()
234 { 234 {
235 m_asyncResolveRunner.runAsync(); 235 m_asyncResolveRunner.runAsync();
236 } 236 }
(...skipping 28 matching lines...) Expand all
265 } 265 }
266 266
267 void MIDIAccess::trace(Visitor* visitor) 267 void MIDIAccess::trace(Visitor* visitor)
268 { 268 {
269 visitor->trace(m_inputs); 269 visitor->trace(m_inputs);
270 visitor->trace(m_outputs); 270 visitor->trace(m_outputs);
271 visitor->trace(m_error); 271 visitor->trace(m_error);
272 } 272 }
273 273
274 } // namespace WebCore 274 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698