blob: 82ebe9ca4d2185c822246a9b6f0f398381c0a26c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/common/desktop_media_id.h"
namespace content {
// static
DesktopMediaID DesktopMediaID::Parse(const std::string& str) {
if (str == "screen")
return DesktopMediaID(TYPE_SCREEN, 0);
std::string window_prefix("window:");
if (StartsWithASCII(str, window_prefix, true)) {
int64 id;
if (!base::StringToInt64(str.substr(window_prefix.size()), &id))
return DesktopMediaID(TYPE_NONE, 0);
return DesktopMediaID(TYPE_WINDOW, id);
}
return DesktopMediaID(TYPE_NONE, 0);
}
std::string DesktopMediaID::ToString() {
switch (type) {
case TYPE_NONE:
NOTREACHED();
return std::string();
case TYPE_SCREEN:
return "screen";
case TYPE_WINDOW:
return "window:" + base::Int64ToString(id);
}
NOTREACHED();
return std::string();
}
} // namespace content
|