Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / web / WebUserMediaRequest.cpp
blobd55a429bb619aa34777c9aaa06af2337e1487dd3
1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "config.h"
33 #include "public/web/WebUserMediaRequest.h"
35 #include "core/dom/Document.h"
36 #include "modules/mediastream/UserMediaRequest.h"
37 #include "platform/mediastream/MediaStreamDescriptor.h"
38 #include "platform/mediastream/MediaStreamSource.h"
39 #include "platform/weborigin/SecurityOrigin.h"
40 #include "public/platform/WebMediaConstraints.h"
41 #include "public/platform/WebMediaStream.h"
42 #include "public/platform/WebMediaStreamSource.h"
43 #include "public/platform/WebSecurityOrigin.h"
44 #include "public/platform/WebString.h"
45 #include "public/web/WebDocument.h"
47 namespace blink {
49 WebUserMediaRequest::WebUserMediaRequest(UserMediaRequest* request)
50 : m_private(request)
54 void WebUserMediaRequest::reset()
56 m_private.reset();
59 bool WebUserMediaRequest::audio() const
61 ASSERT(!isNull());
62 return m_private->audio();
65 bool WebUserMediaRequest::video() const
67 ASSERT(!isNull());
68 return m_private->video();
71 WebMediaConstraints WebUserMediaRequest::audioConstraints() const
73 ASSERT(!isNull());
74 return m_private->audioConstraints();
77 WebMediaConstraints WebUserMediaRequest::videoConstraints() const
79 ASSERT(!isNull());
80 return m_private->videoConstraints();
83 WebSecurityOrigin WebUserMediaRequest::securityOrigin() const
85 ASSERT(!isNull() && m_private->executionContext());
86 return WebSecurityOrigin(m_private->executionContext()->securityOrigin());
89 WebDocument WebUserMediaRequest::ownerDocument() const
91 ASSERT(!isNull());
92 return WebDocument(m_private->ownerDocument());
95 void WebUserMediaRequest::requestSucceeded(const WebMediaStream& streamDescriptor)
97 ASSERT(!isNull() && !streamDescriptor.isNull());
98 m_private->succeed(streamDescriptor);
101 void WebUserMediaRequest::requestDenied(const WebString& description)
103 ASSERT(!isNull());
104 m_private->failPermissionDenied(description);
107 void WebUserMediaRequest::requestFailedConstraint(const WebString& constraintName, const WebString& description)
109 ASSERT(!isNull());
110 m_private->failConstraint(constraintName, description);
113 void WebUserMediaRequest::requestFailedUASpecific(const WebString& name, const WebString& constraintName, const WebString& description)
115 ASSERT(!isNull());
116 m_private->failUASpecific(name, constraintName, description);
119 bool WebUserMediaRequest::equals(const WebUserMediaRequest& other) const
121 if (isNull() || other.isNull())
122 return false;
123 return m_private.get() == other.m_private.get();
126 void WebUserMediaRequest::assign(const WebUserMediaRequest& other)
128 m_private = other.m_private;
131 WebUserMediaRequest::operator UserMediaRequest*() const
133 return m_private.get();
136 } // namespace blink