1 // Copyright 2013 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.
5 #ifndef CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_
6 #define CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_
10 #include "base/basictypes.h"
11 #include "content/common/content_export.h"
17 #endif // defined(USE_AURA)
21 // Type used to identify desktop media sources. It's converted to string and
22 // stored in MediaStreamRequest::requested_video_device_id.
23 struct CONTENT_EXPORT DesktopMediaID
{
33 // Represents an "unset" value for either |id| or |aura_id|.
34 static const Id kNullId
= 0;
37 // Assigns integer identifier to the |window| and returns its DesktopMediaID.
38 static DesktopMediaID
RegisterAuraWindow(Type type
, aura::Window
* window
);
40 // Returns the Window that was previously registered using
41 // RegisterAuraWindow(), else nullptr.
42 static aura::Window
* GetAuraWindowById(const DesktopMediaID
& id
);
43 #endif // defined(USE_AURA)
45 static DesktopMediaID
Parse(const std::string
& str
);
47 DesktopMediaID() = default;
49 DesktopMediaID(Type type
, Id id
)
54 // Operators so that DesktopMediaID can be used with STL containers.
55 bool operator<(const DesktopMediaID
& other
) const {
57 return (type
< other
.type
||
58 (type
== other
.type
&&
59 (id
< other
.id
|| (id
== other
.id
&&
60 aura_id
< other
.aura_id
))));
62 return type
< other
.type
|| (type
== other
.type
&& id
< other
.id
);
65 bool operator==(const DesktopMediaID
& other
) const {
67 return type
== other
.type
&& id
== other
.id
&& aura_id
== other
.aura_id
;
69 return type
== other
.type
&& id
== other
.id
;
73 bool is_null() { return type
== TYPE_NONE
; }
75 std::string
ToString();
77 Type type
= TYPE_NONE
;
79 // The IDs referring to the target native screen or window. |id| will be
80 // non-null if and only if it refers to a native screen/window. |aura_id|
81 // will be non-null if and only if it refers to an Aura window. Note that is
82 // it possible for both of these to be non-null, which means both IDs are
83 // referring to the same logical window.
86 // TODO(miu): Make this an int, after clean-up for http://crbug.com/513490.
91 } // namespace content
93 #endif // CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_