| 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 1ec49b7b4de8594b3788e8b3a250ad3bf9164f6c..ef8e3439968e46098a7d2edca3a1be216786b742 100644
|
| --- a/content/public/browser/desktop_media_id.cc
|
| +++ b/content/public/browser/desktop_media_id.cc
|
| @@ -79,7 +79,7 @@ const char kWindowPrefix[] = "window";
|
| // static
|
| DesktopMediaID DesktopMediaID::RegisterAuraWindow(DesktopMediaID::Type type,
|
| aura::Window* window) {
|
| - DCHECK(type == TYPE_SCREEN || type == TYPE_WINDOW);
|
| + DCHECK(type == TYPE_SCREEN || type == TYPE_WINDOW || type == TYPE_TAB);
|
| DCHECK(window);
|
| DesktopMediaID media_id(type, kNullId);
|
| media_id.aura_id = AuraWindowRegistry::GetInstance()->RegisterWindow(window);
|
| @@ -93,45 +93,81 @@ 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, tab_id) <
|
| + std::tie(other.type, other.id, other.aura_id, other.tab_id);
|
| +#else
|
| + return std::tie(type, id, tab_id) < std::tie(other.type, other.id, tab_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 &&
|
| + tab_id == other.tab_id;
|
| +#else
|
| + return type == other.type && id == other.id && tab_id == other.tab_id;
|
| +#endif
|
| +}
|
| +
|
| // static
|
| +// Input string should in format:
|
| +// for tab: web-contents-media-stream://"render_process_id":"render_process_id"
|
| +// for no tab and aura: screen:"window_id" or window:"window_id"
|
| +// for no tab and no aura: screen:"window_id:aura_id" or
|
| +// window:"window_id:aura_id".
|
| DesktopMediaID DesktopMediaID::Parse(const std::string& str) {
|
| std::vector<std::string> parts = base::SplitString(
|
| str, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
|
|
| -#if defined(USE_AURA)
|
| - if (parts.size() != 3)
|
| - return DesktopMediaID();
|
| -#else
|
| - if (parts.size() != 2)
|
| + if (parts.size() < 2)
|
| return DesktopMediaID();
|
| -#endif
|
|
|
| Type type = TYPE_NONE;
|
| if (parts[0] == kScreenPrefix) {
|
| type = TYPE_SCREEN;
|
| } else if (parts[0] == kWindowPrefix) {
|
| type = TYPE_WINDOW;
|
| + } else if (parts[0] == kTabPrefix) {
|
| + type = TYPE_TAB;
|
| } else {
|
| return DesktopMediaID();
|
| }
|
|
|
| - int64 id;
|
| - if (!base::StringToInt64(parts[1], &id))
|
| + // Tab type.
|
| + if (type == TYPE_TAB) {
|
| + WebContentsMediaCaptureId temp_id = WebContentsMediaCaptureId::Parse(str);
|
| + return DesktopMediaID(type, 0, temp_id);
|
| + }
|
| +
|
| +// Screen and window types.
|
| +#if defined(USE_AURA)
|
| + if (parts.size() != 3)
|
| + return DesktopMediaID();
|
| +#else
|
| + if (parts.size() != 2)
|
| + return DesktopMediaID();
|
| +#endif // defined(USE_AURA)
|
| +
|
| + int64 tempid;
|
| + if (!base::StringToInt64(parts[1], &tempid))
|
| return DesktopMediaID();
|
|
|
| - DesktopMediaID media_id(type, id);
|
| + DesktopMediaID media_id(type, tempid);
|
|
|
| #if defined(USE_AURA)
|
| int64 aura_id;
|
| if (!base::StringToInt64(parts[2], &aura_id))
|
| return DesktopMediaID();
|
| +
|
| media_id.aura_id = aura_id;
|
| #endif // defined(USE_AURA)
|
|
|
| return media_id;
|
| }
|
|
|
| -std::string DesktopMediaID::ToString() {
|
| +std::string DesktopMediaID::ToString() const {
|
| std::string prefix;
|
| switch (type) {
|
| case TYPE_NONE:
|
| @@ -143,9 +179,13 @@ std::string DesktopMediaID::ToString() {
|
| case TYPE_WINDOW:
|
| prefix = kWindowPrefix;
|
| break;
|
| + case TYPE_TAB:
|
| + return tab_id.ToString();
|
| + break;
|
| }
|
| DCHECK(!prefix.empty());
|
|
|
| + // Screen and Window types.
|
| prefix.append(":");
|
| prefix.append(base::Int64ToString(id));
|
|
|
|
|