Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1167)

Unified Diff: content/public/browser/desktop_media_id.cc

Issue 1503563004: Desktop chrome tab capture-chooseDesktopMedia() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/browser/desktop_media_id.h ('k') | content/public/browser/web_contents_media_capture_id.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « content/public/browser/desktop_media_id.h ('k') | content/public/browser/web_contents_media_capture_id.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698