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

Side by Side Diff: chrome/browser/media/media_stream_devices_controller.h

Issue 10912004: Begin adding support for tab mirroring via the MediaStream audio/video capturing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: AudioManager injection into MediaStreamManager, consistent enum naming; per wjia@ comments. Also, … Created 8 years, 3 months 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 #ifndef CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
6 #define CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ 6 #define CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "content/public/browser/web_contents_delegate.h" 10 #include "content/public/browser/web_contents_delegate.h"
11 11
12 class GURL;
13 class Profile; 12 class Profile;
14 13
15 class MediaStreamDevicesController { 14 class MediaStreamDevicesController {
16 public: 15 public:
17 // TODO(xians): Use const content::MediaStreamRequest& instead of *. 16 // TODO(xians): Use const content::MediaStreamRequest& instead of *.
18 MediaStreamDevicesController(Profile* profile, 17 MediaStreamDevicesController(Profile* profile,
19 const content::MediaStreamRequest* request, 18 const content::MediaStreamRequest* request,
20 const content::MediaResponseCallback& callback); 19 const content::MediaResponseCallback& callback);
21 20
22 virtual ~MediaStreamDevicesController(); 21 virtual ~MediaStreamDevicesController();
23 22
24 // Public method to be called before creating the MediaStreamInfoBarDelegate. 23 // Public method to be called before creating the MediaStreamInfoBarDelegate.
25 // This function will check the content settings exceptions and take the 24 // This function will check the content settings exceptions and take the
26 // corresponding action on exception which matches the request. 25 // corresponding action on exception which matches the request.
27 bool DismissInfoBarAndTakeActionOnSettings(); 26 bool DismissInfoBarAndTakeActionOnSettings();
28 27
29 // Public methods to be called by MediaStreamInfoBarDelegate; 28 // Public methods to be called by MediaStreamInfoBarDelegate;
30 bool has_audio() const { return has_audio_; } 29 bool has_audio() const { return has_audio_; }
31 bool has_video() const { return has_video_; } 30 bool has_video() const { return has_video_; }
31 const std::string& GetSecurityOriginSpec() const;
32 content::MediaStreamDevices GetAudioDevices() const; 32 content::MediaStreamDevices GetAudioDevices() const;
33 content::MediaStreamDevices GetVideoDevices() const; 33 content::MediaStreamDevices GetVideoDevices() const;
34 const GURL& GetSecurityOrigin() const; 34 bool IsSafeToAlwaysAllowAudio() const;
35 bool IsSafeToAlwaysAllowVideo() const;
35 void Accept(const std::string& audio_id, 36 void Accept(const std::string& audio_id,
36 const std::string& video_id, 37 const std::string& video_id,
37 bool always_allow); 38 bool always_allow);
38 void Deny(); 39 void Deny();
39 40
40 private: 41 private:
41 // Finds a device in the current request with the specified |id| and |type|, 42 // Used by the various helper methods below to filter an operation on devices
42 // adds it to the |devices| array and also return the name of the device. 43 // of a particular type.
43 void AddDeviceWithId(content::MediaStreamDeviceType type, 44 typedef bool (*FilterByDeviceTypeFunc)(content::MediaStreamDeviceType);
44 const std::string& id, 45
45 content::MediaStreamDevices* devices, 46 // Returns true if a secure scheme is being used by the origin AND only
46 std::string* device_name); 47 // devices of the given physical |device_type| are present in the subset of
48 // devices selected by the |is_included| function.
49 bool IsSafeToAlwaysAllow(FilterByDeviceTypeFunc is_included,
50 content::MediaStreamDeviceType device_type) const;
47 51
48 // Returns true if the media section in content settings is set to 52 // Returns true if the media section in content settings is set to
49 // |CONTENT_SETTING_BLOCK|, otherwise returns false. 53 // |CONTENT_SETTING_BLOCK|, otherwise returns false.
50 bool IsMediaDeviceBlocked(); 54 bool IsMediaDeviceBlocked();
51 55
56 // NOTE on AlwaysAllowOrigin functionality: The rules only apply to physical
57 // capture devices, and not tab mirroring (or other "virtual device" types).
58 // Virtual devices are always denied an AlwaysAllowOrigin status because they
59 // refer to internal objects whose "IDs" might be re-used for different
60 // objects across browser sessions.
61
52 // Returns true if request's origin is from internal objects like 62 // Returns true if request's origin is from internal objects like
53 // chrome://URLs, otherwise returns false. 63 // chrome://URLs, otherwise returns false.
54 bool ShouldAlwaysAllowOrigin(); 64 bool ShouldAlwaysAllowOrigin();
55 65
56 // Grants "always allow" exception for the origin to use the selected devices. 66 // Grants "always allow" exception for the origin to use the selected devices.
57 void AlwaysAllowOriginAndDevices(const std::string& audio_device, 67 void AlwaysAllowOriginAndDevices(const std::string& audio_device,
58 const std::string& video_device); 68 const std::string& video_device);
59 69
60 // Gets the respective "always allowed" devices for the origin in |request_|. 70 // Gets the respective "always allowed" devices for the origin in |request_|.
61 // |audio_id| and |video_id| will be empty if there is no "always allowed" 71 // |audio_id| and |video_id| will be empty if there is no "always allowed"
62 // device for the origin, or any of the devices is not listed on the devices 72 // device for the origin, or any of the devices is not listed on the devices
63 // list in |request_|. 73 // list in |request_|.
64 void GetAlwaysAllowedDevices(std::string* audio_id, 74 void GetAlwaysAllowedDevices(std::string* audio_id,
65 std::string* video_id); 75 std::string* video_id);
66 76
67 std::string GetDeviceIdByName(content::MediaStreamDeviceType type, 77 std::string GetDeviceIdByName(content::MediaStreamDeviceType type,
68 const std::string& name); 78 const std::string& name);
69 79
70 std::string GetFirstDeviceId(content::MediaStreamDeviceType type); 80 std::string GetFirstDeviceId(content::MediaStreamDeviceType type);
71 81
82 // Copies all devices passing the |is_included| predicate to the given output
83 // container.
84 void FindSubsetOfDevices(FilterByDeviceTypeFunc is_included,
85 content::MediaStreamDevices* out) const;
86
87 // Find the first device with the given |device_id| within the subset of
no longer working on chromium 2012/09/10 09:11:04 nit, Finds
miu 2012/09/10 21:24:38 Done.
88 // devices passing the |is_included| predicate, or return NULL.
89 const content::MediaStreamDevice* FindFirstDeviceWithIdInSubset(
90 FilterByDeviceTypeFunc is_included,
91 const std::string& device_id) const;
92
72 bool has_audio_; 93 bool has_audio_;
73 bool has_video_; 94 bool has_video_;
74 95
75 // The owner of this class needs to make sure it does not outlive the profile. 96 // The owner of this class needs to make sure it does not outlive the profile.
76 Profile* profile_; 97 Profile* profile_;
77 98
78 // The original request for access to devices. 99 // The original request for access to devices.
79 const content::MediaStreamRequest request_; 100 const content::MediaStreamRequest request_;
80 101
81 // The callback that needs to be Run to notify WebRTC of whether access to 102 // The callback that needs to be Run to notify WebRTC of whether access to
82 // audio/video devices was granted or not. 103 // audio/video devices was granted or not.
83 content::MediaResponseCallback callback_; 104 content::MediaResponseCallback callback_;
84 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); 105 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController);
85 }; 106 };
86 107
87 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ 108 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698