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

Side by Side Diff: content/browser/renderer_host/media/web_contents_capture_util.cc

Issue 11451006: Make TabCapture requests use the target render process and render view id's for UI permissions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove early return Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/renderer_host/media/web_contents_capture_util.h" 5 #include "content/browser/renderer_host/media/web_contents_capture_util.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_piece.h" 9 #include "base/string_piece.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 20 matching lines...) Expand all
31 31
32 bool WebContentsCaptureUtil::IsWebContentsDeviceId( 32 bool WebContentsCaptureUtil::IsWebContentsDeviceId(
33 const std::string& device_id) { 33 const std::string& device_id) {
34 return StartsWithASCII(device_id, kVirtualDeviceScheme, true); 34 return StartsWithASCII(device_id, kVirtualDeviceScheme, true);
35 } 35 }
36 36
37 bool WebContentsCaptureUtil::ExtractTabCaptureTarget( 37 bool WebContentsCaptureUtil::ExtractTabCaptureTarget(
38 const std::string& device_id_param, 38 const std::string& device_id_param,
39 int* render_process_id, 39 int* render_process_id,
40 int* render_view_id) { 40 int* render_view_id) {
41 DCHECK(IsWebContentsDeviceId(device_id_param)); 41 if (!IsWebContentsDeviceId(device_id_param))
42 return false;
43
42 const std::string device_id = device_id_param.substr( 44 const std::string device_id = device_id_param.substr(
43 arraysize(kVirtualDeviceScheme) - 1); 45 arraysize(kVirtualDeviceScheme) - 1);
44 46
45 const size_t sep_pos = device_id.find(':'); 47 const size_t sep_pos = device_id.find(':');
46 if (sep_pos == std::string::npos) 48 if (sep_pos == std::string::npos)
47 return false; 49 return false;
48 50
49 const base::StringPiece component1(device_id.data(), sep_pos); 51 const base::StringPiece component1(device_id.data(), sep_pos);
50 const base::StringPiece component2(device_id.data() + sep_pos + 1, 52 const base::StringPiece component2(device_id.data() + sep_pos + 1,
51 device_id.length() - sep_pos - 1); 53 device_id.length() - sep_pos - 1);
52 54
53 return (base::StringToInt(component1, render_process_id) && 55 return (base::StringToInt(component1, render_process_id) &&
54 base::StringToInt(component2, render_view_id)); 56 base::StringToInt(component2, render_view_id));
55 } 57 }
56 58
57 } // namespace content 59 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698