Index: content/public/browser/desktop_media_id.cc |
diff --git a/content/public/browser/desktop_media_id.cc b/content/public/browser/desktop_media_id.cc |
index 523c61d39bc696c912a50f7253076bf912091354..63c2cbf3c61f6a74824511d2544e4bca809c535e 100644 |
--- a/content/public/browser/desktop_media_id.cc |
+++ b/content/public/browser/desktop_media_id.cc |
@@ -96,8 +96,40 @@ aura::Window* DesktopMediaID::GetAuraWindowById(const DesktopMediaID& id) { |
#endif // defined(USE_AURA) |
+bool DesktopMediaID::operator<(const DesktopMediaID& other) const { |
+#if defined(USE_AURA) |
+ return std::tie(type, id, aura_id, web_contents_id) < |
+ std::tie(other.type, other.id, other.aura_id, other.web_contents_id); |
+#else |
+ return std::tie(type, id, web_contents_id) < |
+ std::tie(other.type, other.id, web_contents_id); |
+#endif |
+} |
+ |
+bool DesktopMediaID::operator==(const DesktopMediaID& other) const { |
+#if defined(USE_AURA) |
+ return type == other.type && id == other.id && aura_id == other.aura_id && |
+ web_contents_id == other.web_contents_id; |
+#else |
+ return type == other.type && id == other.id && |
+ web_contents_id == other.web_contents_id; |
+#endif |
+} |
+ |
// static |
+// Input string should in format: |
+// for WebContents: |
+// web-contents-media-stream://"render_process_id":"render_process_id" |
+// for no aura screen and window: screen:"window_id" or window:"window_id" |
+// for aura screen and window: screen:"window_id:aura_id" or |
+// window:"window_id:aura_id". |
DesktopMediaID DesktopMediaID::Parse(const std::string& str) { |
+ // For WebContents type. |
+ WebContentsMediaCaptureId web_id = WebContentsMediaCaptureId::Parse(str); |
+ if (!web_id.is_null()) |
+ return DesktopMediaID(TYPE_WEB_CONTENTS, 0, web_id); |
+ |
+ // For screen and window types. |
std::vector<std::string> parts = base::SplitString( |
str, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
@@ -134,7 +166,7 @@ DesktopMediaID DesktopMediaID::Parse(const std::string& str) { |
return media_id; |
} |
-std::string DesktopMediaID::ToString() { |
+std::string DesktopMediaID::ToString() const { |
std::string prefix; |
switch (type) { |
case TYPE_NONE: |
@@ -146,9 +178,13 @@ std::string DesktopMediaID::ToString() { |
case TYPE_WINDOW: |
prefix = kWindowPrefix; |
break; |
+ case TYPE_WEB_CONTENTS: |
+ return web_contents_id.ToString(); |
+ break; |
} |
DCHECK(!prefix.empty()); |
+ // Screen and Window types. |
prefix.append(":"); |
prefix.append(base::Int64ToString(id)); |