| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/media/capture/web_contents_capture_util.h" | 5 #include "content/browser/media/capture/web_contents_capture_util.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_piece.h" | 9 #include "base/strings/string_piece.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 bool WebContentsCaptureUtil::IsWebContentsDeviceId( | 14 bool WebContentsCaptureUtil::IsWebContentsDeviceId( |
| 15 const std::string& device_id) { | 15 const std::string& device_id) { |
| 16 int ignored; | 16 int ignored; |
| 17 return ExtractTabCaptureTarget(device_id, &ignored, &ignored); | 17 return ExtractTabCaptureTarget(device_id, &ignored, &ignored); |
| 18 } | 18 } |
| 19 | 19 |
| 20 bool WebContentsCaptureUtil::ExtractTabCaptureTarget( | 20 bool WebContentsCaptureUtil::ExtractTabCaptureTarget( |
| 21 const std::string& device_id_param, | 21 const std::string& device_id_param, |
| 22 int* render_process_id, | 22 int* render_process_id, |
| 23 int* main_render_frame_id) { | 23 int* main_render_frame_id) { |
| 24 static const char kDeviceScheme[] = "web-contents-media-stream://"; | 24 static const char kDeviceScheme[] = "web-contents-media-stream://"; |
| 25 if (!base::StartsWithASCII(device_id_param, kDeviceScheme, true)) | 25 if (!base::StartsWith(device_id_param, kDeviceScheme, |
| 26 base::CompareCase::SENSITIVE)) |
| 26 return false; | 27 return false; |
| 27 | 28 |
| 28 const std::string device_id = device_id_param.substr( | 29 const std::string device_id = device_id_param.substr( |
| 29 arraysize(kDeviceScheme) - 1); | 30 arraysize(kDeviceScheme) - 1); |
| 30 | 31 |
| 31 const size_t sep_pos = device_id.find(':'); | 32 const size_t sep_pos = device_id.find(':'); |
| 32 if (sep_pos == std::string::npos) | 33 if (sep_pos == std::string::npos) |
| 33 return false; | 34 return false; |
| 34 | 35 |
| 35 const base::StringPiece component1(device_id.data(), sep_pos); | 36 const base::StringPiece component1(device_id.data(), sep_pos); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 54 const size_t option_pos = device_id.find('?'); | 55 const size_t option_pos = device_id.find('?'); |
| 55 if (option_pos == std::string::npos) | 56 if (option_pos == std::string::npos) |
| 56 return false; | 57 return false; |
| 57 const base::StringPiece component(device_id.data() + option_pos, | 58 const base::StringPiece component(device_id.data() + option_pos, |
| 58 device_id.length() - option_pos); | 59 device_id.length() - option_pos); |
| 59 static const char kEnableFlag[] = "?throttling=auto"; | 60 static const char kEnableFlag[] = "?throttling=auto"; |
| 60 return component.compare(kEnableFlag) == 0; | 61 return component.compare(kEnableFlag) == 0; |
| 61 } | 62 } |
| 62 | 63 |
| 63 } // namespace content | 64 } // namespace content |
| OLD | NEW |