| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_PUBLIC_COMMON_DESKTOP_MEDIA_ID_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_ |
| 6 #define CONTENT_PUBLIC_COMMON_DESKTOP_MEDIA_ID_H_ | 6 #define CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 | 14 |
| 15 namespace aura { |
| 16 class Window; |
| 17 } // namespace aura |
| 18 |
| 15 namespace content { | 19 namespace content { |
| 16 | 20 |
| 17 // Type used to identify desktop media sources. It's converted to string and | 21 // Type used to identify desktop media sources. It's converted to string and |
| 18 // stored in MediaStreamRequest::requested_video_device_id . | 22 // stored in MediaStreamRequest::requested_video_device_id . |
| 19 struct CONTENT_EXPORT DesktopMediaID { | 23 struct CONTENT_EXPORT DesktopMediaID { |
| 20 public: | 24 public: |
| 21 enum Type { | 25 enum Type { |
| 22 TYPE_NONE, | 26 TYPE_NONE, |
| 23 TYPE_SCREEN, | 27 TYPE_SCREEN, |
| 24 TYPE_WINDOW, | 28 TYPE_WINDOW, |
| 29 TYPE_AURA_WINDOW, |
| 25 }; | 30 }; |
| 26 typedef intptr_t Id; | 31 typedef intptr_t Id; |
| 27 | 32 |
| 33 // Assigns integer identifier to the |window| and returns DesktopMediaID of |
| 34 // type TYPE_AURA_WINDOW that corresponds to that |window|. |
| 35 static DesktopMediaID RegisterAuraWindow(aura::Window* window); |
| 36 |
| 37 // For DesktopMediaID of type TYPE_AURA_WINDOW returns the |window| that was |
| 38 // previously registered using RegisterAuraWindow(). |
| 39 static aura::Window* GetAuraWindowById(const DesktopMediaID& id); |
| 40 |
| 28 static DesktopMediaID Parse(const std::string& str); | 41 static DesktopMediaID Parse(const std::string& str); |
| 29 | 42 |
| 30 DesktopMediaID() | 43 DesktopMediaID() |
| 31 : type(TYPE_NONE), | 44 : type(TYPE_NONE), |
| 32 id(0) { | 45 id(0) { |
| 33 } | 46 } |
| 34 DesktopMediaID(Type type, Id id) | 47 DesktopMediaID(Type type, Id id) |
| 35 : type(type), | 48 : type(type), |
| 36 id(id) { | 49 id(id) { |
| 37 } | 50 } |
| 38 | 51 |
| 39 // Operators so that DesktopMediaID can be used with STL containers. | 52 // Operators so that DesktopMediaID can be used with STL containers. |
| 40 bool operator<(const DesktopMediaID& other) const { | 53 bool operator<(const DesktopMediaID& other) const { |
| 41 return type < other.type || (type == other.type && id < other.id); | 54 return type < other.type || (type == other.type && id < other.id); |
| 42 } | 55 } |
| 43 bool operator==(const DesktopMediaID& other) const { | 56 bool operator==(const DesktopMediaID& other) const { |
| 44 return type == other.type && id == other.id; | 57 return type == other.type && id == other.id; |
| 45 } | 58 } |
| 46 | 59 |
| 47 bool is_null() { return type == TYPE_NONE; } | 60 bool is_null() { return type == TYPE_NONE; } |
| 48 | 61 |
| 49 std::string ToString(); | 62 std::string ToString(); |
| 50 | 63 |
| 51 Type type; | 64 Type type; |
| 52 Id id; | 65 Id id; |
| 53 }; | 66 }; |
| 54 | 67 |
| 55 } // namespace content | 68 } // namespace content |
| 56 | 69 |
| 57 #endif // CONTENT_PUBLIC_COMMON_DESKTOP_MEDIA_ID_H_ | 70 #endif // CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_ |
| OLD | NEW |