Content settings: remove some plugin-related code/resources when... there are no...
[chromium-blink-merge.git] / content / public / browser / desktop_media_id.h
blobc31875b310cce402aeeb8c91c17c6f696b988b30
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 DesktopMediaID() = default;
49 DesktopMediaID(Type type, Id id)
50 : type(type),
51 id(id) {
54 // Operators so that DesktopMediaID can be used with STL containers.
55 bool operator<(const DesktopMediaID& other) const {
56 #if defined(USE_AURA)
57 return (type < other.type ||
58 (type == other.type &&
59 (id < other.id || (id == other.id &&
60 aura_id < other.aura_id))));
61 #else
62 return type < other.type || (type == other.type && id < other.id);
63 #endif
65 bool operator==(const DesktopMediaID& other) const {
66 #if defined(USE_AURA)
67 return type == other.type && id == other.id && aura_id == other.aura_id;
68 #else
69 return type == other.type && id == other.id;
70 #endif
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.
84 Id id = kNullId;
85 #if defined(USE_AURA)
86 // TODO(miu): Make this an int, after clean-up for http://crbug.com/513490.
87 Id aura_id = kNullId;
88 #endif
91 } // namespace content
93 #endif // CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_