Chromium Code Reviews| Index: content/browser/renderer_host/media/web_contents_capture_util.cc |
| diff --git a/content/browser/renderer_host/media/web_contents_capture_util.cc b/content/browser/renderer_host/media/web_contents_capture_util.cc |
| index ed36cb2f80d887e81f1065b6c246c5c8ce86b9c5..d2f457e6d4ea52a198d85547684f1b869d035900 100644 |
| --- a/content/browser/renderer_host/media/web_contents_capture_util.cc |
| +++ b/content/browser/renderer_host/media/web_contents_capture_util.cc |
| @@ -4,15 +4,44 @@ |
| #include "content/browser/renderer_host/media/web_contents_capture_util.h" |
| +#include "base/basictypes.h" |
| #include "base/string_number_conversions.h" |
| #include "base/string_piece.h" |
| +#include "base/string_util.h" |
| + |
| +namespace { |
| + |
| +const char kVirtualDeviceScheme[] = "virtual://"; |
|
Alpha Left Google
2012/11/28 01:04:47
maybe virtual-media-stream?
justinlin
2012/11/28 14:30:31
Done.
|
| + |
| +} // namespace |
| namespace content { |
| +std::string WebContentsCaptureUtil::AppendWebContentsDeviceScheme( |
| + const std::string& device_id) { |
| + return kVirtualDeviceScheme + device_id; |
| +} |
| + |
| +std::string WebContentsCaptureUtil::StripWebContentsDeviceScheme( |
| + const std::string& device_id) { |
| +return (IsWebContentsDeviceId(device_id) ? |
|
Alpha Left Google
2012/11/28 01:04:47
indentation
justinlin
2012/11/28 14:30:31
Done.
|
| + device_id.substr(arraysize(kVirtualDeviceScheme) - 1) : |
|
Alpha Left Google
2012/11/28 01:04:47
Use url_parse? See: http://code.google.com/p/chrom
justinlin
2012/11/28 14:30:31
That seems a bit overkill? All we want is just to
|
| + device_id); |
| +} |
| + |
| +bool WebContentsCaptureUtil::IsWebContentsDeviceId( |
| + const std::string& device_id) { |
| + return StartsWithASCII(device_id, kVirtualDeviceScheme, true); |
| +} |
| + |
| bool WebContentsCaptureUtil::ExtractTabCaptureTarget( |
| - const std::string& device_id, |
| + const std::string& device_id_param, |
| int* render_process_id, |
| int* render_view_id) { |
| + DCHECK(IsWebContentsDeviceId(device_id_param)); |
| + const std::string device_id = device_id_param.substr( |
|
Alpha Left Google
2012/11/28 01:04:47
Use url_parse?
|
| + arraysize(kVirtualDeviceScheme) - 1); |
| + |
| const size_t sep_pos = device_id.find(':'); |
| if (sep_pos == std::string::npos) |
| return false; |