OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "public/web/WebMediaDeviceChangeObserver.h" | |
6 | |
7 #include "core/dom/Document.h" | |
8 #include "modules/mediastream/MediaDevices.h" | |
9 #include "platform/weborigin/SecurityOrigin.h" | |
10 #include "public/platform/WebSecurityOrigin.h" | |
11 | |
12 namespace blink { | |
13 | |
14 WebMediaDeviceChangeObserver::WebMediaDeviceChangeObserver() | |
15 : private_(nullptr) {} | |
16 | |
17 WebMediaDeviceChangeObserver::WebMediaDeviceChangeObserver(bool unused) | |
18 : private_(MediaDevices::Create(Document::Create())) {} | |
19 | |
20 WebMediaDeviceChangeObserver::WebMediaDeviceChangeObserver( | |
21 const WebMediaDeviceChangeObserver& other) { | |
22 Assign(other); | |
23 } | |
24 | |
25 WebMediaDeviceChangeObserver& WebMediaDeviceChangeObserver::operator=( | |
26 const WebMediaDeviceChangeObserver& other) { | |
27 Assign(other); | |
28 return *this; | |
29 } | |
30 | |
31 WebMediaDeviceChangeObserver::WebMediaDeviceChangeObserver( | |
32 MediaDevices* observer) | |
33 : private_(observer) {} | |
34 | |
35 WebMediaDeviceChangeObserver::~WebMediaDeviceChangeObserver() { | |
36 Reset(); | |
37 } | |
38 | |
39 bool WebMediaDeviceChangeObserver::IsNull() const { | |
40 return private_.IsNull(); | |
41 } | |
42 | |
43 void WebMediaDeviceChangeObserver::DidChangeMediaDevices() { | |
44 if (private_.IsNull()) | |
45 return; | |
46 | |
47 private_->DidChangeMediaDevices(); | |
48 } | |
49 | |
50 WebSecurityOrigin WebMediaDeviceChangeObserver::GetSecurityOrigin() const { | |
51 if (private_.IsNull()) | |
52 return WebSecurityOrigin(); | |
53 | |
54 return WebSecurityOrigin( | |
55 private_->GetExecutionContext()->GetSecurityOrigin()); | |
56 } | |
57 | |
58 void WebMediaDeviceChangeObserver::Assign( | |
59 const WebMediaDeviceChangeObserver& other) { | |
60 private_ = other.private_; | |
61 } | |
62 | |
63 void WebMediaDeviceChangeObserver::Reset() { | |
64 private_.Reset(); | |
65 } | |
66 | |
67 } // namespace blink | |
OLD | NEW |