| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Ericsson AB. All rights reserved. | 2 * Copyright (C) 2011 Ericsson AB. All rights reserved. |
| 3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // While getUserMedia is blocked on insecure origins, we still want to | 133 // While getUserMedia is blocked on insecure origins, we still want to |
| 134 // count attempts to use it. | 134 // count attempts to use it. |
| 135 Deprecation::countDeprecation(document->frame(), UseCounter::GetUserMediaIns
ecureOrigin); | 135 Deprecation::countDeprecation(document->frame(), UseCounter::GetUserMediaIns
ecureOrigin); |
| 136 Deprecation::countDeprecationCrossOriginIframe(*document, UseCounter::GetUse
rMediaInsecureOriginIframe); | 136 Deprecation::countDeprecationCrossOriginIframe(*document, UseCounter::GetUse
rMediaInsecureOriginIframe); |
| 137 OriginsUsingFeatures::countAnyWorld(*document, OriginsUsingFeatures::Feature
::GetUserMediaInsecureOrigin); | 137 OriginsUsingFeatures::countAnyWorld(*document, OriginsUsingFeatures::Feature
::GetUserMediaInsecureOrigin); |
| 138 return false; | 138 return false; |
| 139 } | 139 } |
| 140 | 140 |
| 141 Document* UserMediaRequest::ownerDocument() | 141 Document* UserMediaRequest::ownerDocument() |
| 142 { | 142 { |
| 143 if (ExecutionContext* context = executionContext()) { | 143 if (ExecutionContext* context = getExecutionContext()) { |
| 144 return toDocument(context); | 144 return toDocument(context); |
| 145 } | 145 } |
| 146 | 146 |
| 147 return 0; | 147 return 0; |
| 148 } | 148 } |
| 149 | 149 |
| 150 void UserMediaRequest::start() | 150 void UserMediaRequest::start() |
| 151 { | 151 { |
| 152 if (m_controller) | 152 if (m_controller) |
| 153 m_controller->requestUserMedia(this); | 153 m_controller->requestUserMedia(this); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void UserMediaRequest::succeed(MediaStreamDescriptor* streamDescriptor) | 156 void UserMediaRequest::succeed(MediaStreamDescriptor* streamDescriptor) |
| 157 { | 157 { |
| 158 if (!executionContext()) | 158 if (!getExecutionContext()) |
| 159 return; | 159 return; |
| 160 | 160 |
| 161 RefPtrWillBeRawPtr<MediaStream> stream = MediaStream::create(executionContex
t(), streamDescriptor); | 161 RefPtrWillBeRawPtr<MediaStream> stream = MediaStream::create(getExecutionCon
text(), streamDescriptor); |
| 162 | 162 |
| 163 MediaStreamTrackVector audioTracks = stream->getAudioTracks(); | 163 MediaStreamTrackVector audioTracks = stream->getAudioTracks(); |
| 164 for (MediaStreamTrackVector::iterator iter = audioTracks.begin(); iter != au
dioTracks.end(); ++iter) { | 164 for (MediaStreamTrackVector::iterator iter = audioTracks.begin(); iter != au
dioTracks.end(); ++iter) { |
| 165 (*iter)->component()->source()->setConstraints(m_audio); | 165 (*iter)->component()->source()->setConstraints(m_audio); |
| 166 } | 166 } |
| 167 | 167 |
| 168 MediaStreamTrackVector videoTracks = stream->getVideoTracks(); | 168 MediaStreamTrackVector videoTracks = stream->getVideoTracks(); |
| 169 for (MediaStreamTrackVector::iterator iter = videoTracks.begin(); iter != vi
deoTracks.end(); ++iter) { | 169 for (MediaStreamTrackVector::iterator iter = videoTracks.begin(); iter != vi
deoTracks.end(); ++iter) { |
| 170 (*iter)->component()->source()->setConstraints(m_video); | 170 (*iter)->component()->source()->setConstraints(m_video); |
| 171 } | 171 } |
| 172 | 172 |
| 173 m_successCallback->handleEvent(stream.get()); | 173 m_successCallback->handleEvent(stream.get()); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void UserMediaRequest::failPermissionDenied(const String& message) | 176 void UserMediaRequest::failPermissionDenied(const String& message) |
| 177 { | 177 { |
| 178 if (!executionContext()) | 178 if (!getExecutionContext()) |
| 179 return; | 179 return; |
| 180 m_errorCallback->handleEvent(NavigatorUserMediaError::create(NavigatorUserMe
diaError::NamePermissionDenied, message, String())); | 180 m_errorCallback->handleEvent(NavigatorUserMediaError::create(NavigatorUserMe
diaError::NamePermissionDenied, message, String())); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void UserMediaRequest::failConstraint(const String& constraintName, const String
& message) | 183 void UserMediaRequest::failConstraint(const String& constraintName, const String
& message) |
| 184 { | 184 { |
| 185 ASSERT(!constraintName.isEmpty()); | 185 ASSERT(!constraintName.isEmpty()); |
| 186 if (!executionContext()) | 186 if (!getExecutionContext()) |
| 187 return; | 187 return; |
| 188 m_errorCallback->handleEvent(NavigatorUserMediaError::create(NavigatorUserMe
diaError::NameConstraintNotSatisfied, message, constraintName)); | 188 m_errorCallback->handleEvent(NavigatorUserMediaError::create(NavigatorUserMe
diaError::NameConstraintNotSatisfied, message, constraintName)); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void UserMediaRequest::failUASpecific(const String& name, const String& message,
const String& constraintName) | 191 void UserMediaRequest::failUASpecific(const String& name, const String& message,
const String& constraintName) |
| 192 { | 192 { |
| 193 ASSERT(!name.isEmpty()); | 193 ASSERT(!name.isEmpty()); |
| 194 if (!executionContext()) | 194 if (!getExecutionContext()) |
| 195 return; | 195 return; |
| 196 m_errorCallback->handleEvent(NavigatorUserMediaError::create(name, message,
constraintName)); | 196 m_errorCallback->handleEvent(NavigatorUserMediaError::create(name, message,
constraintName)); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void UserMediaRequest::contextDestroyed() | 199 void UserMediaRequest::contextDestroyed() |
| 200 { | 200 { |
| 201 if (m_controller) { | 201 if (m_controller) { |
| 202 m_controller->cancelUserMediaRequest(this); | 202 m_controller->cancelUserMediaRequest(this); |
| 203 m_controller = nullptr; | 203 m_controller = nullptr; |
| 204 } | 204 } |
| 205 | 205 |
| 206 ContextLifecycleObserver::contextDestroyed(); | 206 ContextLifecycleObserver::contextDestroyed(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 DEFINE_TRACE(UserMediaRequest) | 209 DEFINE_TRACE(UserMediaRequest) |
| 210 { | 210 { |
| 211 visitor->trace(m_controller); | 211 visitor->trace(m_controller); |
| 212 visitor->trace(m_successCallback); | 212 visitor->trace(m_successCallback); |
| 213 visitor->trace(m_errorCallback); | 213 visitor->trace(m_errorCallback); |
| 214 ContextLifecycleObserver::trace(visitor); | 214 ContextLifecycleObserver::trace(visitor); |
| 215 } | 215 } |
| 216 | 216 |
| 217 } // namespace blink | 217 } // namespace blink |
| OLD | NEW |