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