Update V8 to version 4.6.61.
[chromium-blink-merge.git] / content / public / browser / desktop_media_id.h
blob657d4db94508c6d3a8f0517caa34e1b48ee99aea
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_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "content/common/content_export.h"
13 #if defined(USE_AURA)
14 namespace aura {
15 class Window;
16 } // namespace aura
17 #endif // defined(USE_AURA)
19 namespace content {
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 {
24 public:
25 enum Type {
26 TYPE_NONE,
27 TYPE_SCREEN,
28 TYPE_WINDOW,
31 typedef intptr_t Id;
33 // Represents an "unset" value for either |id| or |aura_id|.
34 static const Id kNullId = 0;
36 #if defined(USE_AURA)
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 // TODO(hans): Maybe move inline again after crbug.com/488634.
48 DesktopMediaID();
50 DesktopMediaID(Type type, Id id)
51 : type(type),
52 id(id) {
55 // Operators so that DesktopMediaID can be used with STL containers.
56 bool operator<(const DesktopMediaID& other) const {
57 #if defined(USE_AURA)
58 return (type < other.type ||
59 (type == other.type &&
60 (id < other.id || (id == other.id &&
61 aura_id < other.aura_id))));
62 #else
63 return type < other.type || (type == other.type && id < other.id);
64 #endif
66 bool operator==(const DesktopMediaID& other) const {
67 #if defined(USE_AURA)
68 return type == other.type && id == other.id && aura_id == other.aura_id;
69 #else
70 return type == other.type && id == other.id;
71 #endif
74 bool is_null() { return type == TYPE_NONE; }
76 std::string ToString();
78 Type type = TYPE_NONE;
80 // The IDs referring to the target native screen or window. |id| will be
81 // non-null if and only if it refers to a native screen/window. |aura_id|
82 // will be non-null if and only if it refers to an Aura window. Note that is
83 // it possible for both of these to be non-null, which means both IDs are
84 // referring to the same logical window.
85 Id id = kNullId;
86 #if defined(USE_AURA)
87 // TODO(miu): Make this an int, after clean-up for http://crbug.com/513490.
88 Id aura_id = kNullId;
89 #endif
92 } // namespace content
94 #endif // CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_