OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/callback.h" |
| 12 #include "chrome/browser/media/media_stream_devices_controller.h" |
| 13 #include "content/public/browser/content_browser_client.h" |
| 14 #include "content/public/browser/web_contents_delegate.h" |
| 15 #include "content/public/common/media_stream_request.h" |
| 16 |
| 17 class ContentSettingsPattern; |
| 18 class GURL; |
| 19 class Profile; |
| 20 |
| 21 class MediaStreamDevicesController { |
| 22 public: |
| 23 MediaStreamDevicesController(Profile* profile, |
| 24 const content::MediaStreamRequest* request, |
| 25 const content::MediaResponseCallback& callback); |
| 26 |
| 27 virtual ~MediaStreamDevicesController(); |
| 28 |
| 29 // Public method to be called before creating the MediaStreamInfoBarDelegate. |
| 30 // This function will check the content settings exceptions and take the |
| 31 // corresponding action on exception which matches the request. |
| 32 bool DismissInfoBarAndTakeActionOnSettings(); |
| 33 |
| 34 // Public methods to be called by MediaStreamInfoBarDelegate; |
| 35 bool has_audio() const { return has_audio_; } |
| 36 bool has_video() const { return has_video_; } |
| 37 content::MediaStreamDevices GetAudioDevices() const; |
| 38 content::MediaStreamDevices GetVideoDevices() const; |
| 39 const GURL& GetSecurityOrigin() const; |
| 40 void Accept(const std::string& audio_id, |
| 41 const std::string& video_id, |
| 42 bool always_allow); |
| 43 void Deny(); |
| 44 |
| 45 private: |
| 46 // Finds a device in the current request with the specified |id| and |type|, |
| 47 // adds it to the |devices| array and also return the name of the device. |
| 48 void AddDeviceWithId(content::MediaStreamDeviceType type, |
| 49 const std::string& id, |
| 50 content::MediaStreamDevices* devices, |
| 51 std::string* device_name); |
| 52 |
| 53 // Returns true if the media section in content settings is set to |
| 54 // |CONTENT_SETTING_BLOCK|, otherwise returns false. |
| 55 bool IsMediaDeviceBlocked(); |
| 56 |
| 57 // Returns true if request's origin is from internal objects like |
| 58 // chrome://URLs, otherwise returns false. |
| 59 bool ShouldAlwaysAllowOrigin(); |
| 60 |
| 61 // Grants "always allow" exception for the origin to use the selected devices. |
| 62 void AlwaysAllowOriginAndDevices(const std::string& audio_device, |
| 63 const std::string& video_device); |
| 64 |
| 65 // Gets the respective "always allowed" devices for the origin in |request_|. |
| 66 // |audio_id| and |video_id| will be empty if there is no "always allowed" |
| 67 // device for the origin, or any of the devices is not listed on the devices |
| 68 // list in |request_|. |
| 69 void GetAlwaysAllowedDevices(std::string* audio_id, |
| 70 std::string* video_id); |
| 71 |
| 72 std::string GetDeviceIdByName(content::MediaStreamDeviceType type, |
| 73 const std::string& name); |
| 74 |
| 75 std::string GetFirstDevice(content::MediaStreamDeviceType type); |
| 76 |
| 77 bool has_audio_; |
| 78 bool has_video_; |
| 79 |
| 80 Profile* profile_; |
| 81 |
| 82 // The original request for access to devices. |
| 83 const content::MediaStreamRequest* request_; |
| 84 |
| 85 // The callback that needs to be Run to notify WebRTC of whether access to |
| 86 // audio/video devices was granted or not. |
| 87 content::MediaResponseCallback callback_; |
| 88 }; |
| 89 |
| 90 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ |
OLD | NEW |