| 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 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_MEDIA_STREAM_DEVICES_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_MEDIA_STREAM_DEVICES_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_WEBRTC_MEDIA_STREAM_DEVICES_CONTROLLER_H_ | 6 #define CHROME_BROWSER_MEDIA_WEBRTC_MEDIA_STREAM_DEVICES_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "chrome/browser/permissions/permission_request.h" | 12 #include "chrome/browser/permissions/permission_request.h" |
| 13 #include "components/content_settings/core/common/content_settings.h" | 13 #include "components/content_settings/core/common/content_settings.h" |
| 14 #include "content/public/browser/web_contents_delegate.h" | 14 #include "content/public/browser/web_contents_delegate.h" |
| 15 | 15 |
| 16 class Profile; | 16 class Profile; |
| 17 class TabSpecificContentSettings; | 17 class TabSpecificContentSettings; |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 class WebContents; | 20 class WebContents; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace user_prefs { | 23 namespace user_prefs { |
| 24 class PrefRegistrySyncable; | 24 class PrefRegistrySyncable; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace policy { |
| 28 class MediaStreamDevicesControllerBrowserTest; |
| 29 } |
| 30 |
| 27 class MediaStreamDevicesController : public PermissionRequest { | 31 class MediaStreamDevicesController : public PermissionRequest { |
| 28 public: | 32 public: |
| 29 MediaStreamDevicesController(content::WebContents* web_contents, | 33 static void RequestPermissions( |
| 30 const content::MediaStreamRequest& request, | 34 content::WebContents* web_contents, |
| 31 const content::MediaResponseCallback& callback); | 35 const content::MediaStreamRequest& request, |
| 32 | 36 const content::MediaResponseCallback& callback); |
| 33 ~MediaStreamDevicesController() override; | |
| 34 | 37 |
| 35 // Registers the prefs backing the audio and video policies. | 38 // Registers the prefs backing the audio and video policies. |
| 36 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 39 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 37 | 40 |
| 38 bool IsAllowedForAudio() const; | 41 ~MediaStreamDevicesController() override; |
| 39 bool IsAllowedForVideo() const; | 42 |
| 40 bool IsAskingForAudio() const; | 43 bool IsAskingForAudio() const; |
| 41 bool IsAskingForVideo() const; | 44 bool IsAskingForVideo() const; |
| 42 base::string16 GetMessageText() const; | 45 base::string16 GetMessageText() const; |
| 43 | 46 |
| 44 // Forces the permissions to be denied (without being persisted) regardless | 47 // Forces the permissions to be denied (without being persisted) regardless |
| 45 // of what the previous state was. If the user had previously allowed the | 48 // of what the previous state was. If the user had previously allowed the |
| 46 // site video or audio access, this ignores that and informs the site it was | 49 // site video or audio access, this ignores that and informs the site it was |
| 47 // denied. | 50 // denied. |
| 48 // | 51 // |
| 49 // This differs from PermissionGranted/PermissionDenied as they only operate | 52 // This differs from PermissionGranted/PermissionDenied as they only operate |
| 50 // on the permissions if they are in the ASK state. | 53 // on the permissions if they are in the ASK state. |
| 51 void ForcePermissionDeniedTemporarily(); | 54 void ForcePermissionDeniedTemporarily(); |
| 52 | 55 |
| 53 bool ShouldShowPersistenceToggle() const override; | 56 bool ShouldShowPersistenceToggle() const override; |
| 54 | 57 |
| 55 // PermissionRequest: | 58 // PermissionRequest: |
| 56 IconId GetIconId() const override; | 59 IconId GetIconId() const override; |
| 57 base::string16 GetMessageTextFragment() const override; | 60 base::string16 GetMessageTextFragment() const override; |
| 58 GURL GetOrigin() const override; | 61 GURL GetOrigin() const override; |
| 59 void PermissionGranted() override; | 62 void PermissionGranted() override; |
| 60 void PermissionDenied() override; | 63 void PermissionDenied() override; |
| 61 void Cancelled() override; | 64 void Cancelled() override; |
| 62 void RequestFinished() override; | 65 void RequestFinished() override; |
| 63 PermissionRequestType GetPermissionRequestType() const override; | 66 PermissionRequestType GetPermissionRequestType() const override; |
| 64 | 67 |
| 65 private: | 68 private: |
| 69 friend class MediaStreamDevicesControllerTest; |
| 70 friend class policy::MediaStreamDevicesControllerBrowserTest; |
| 71 |
| 72 MediaStreamDevicesController(content::WebContents* web_contents, |
| 73 const content::MediaStreamRequest& request, |
| 74 const content::MediaResponseCallback& callback); |
| 75 |
| 76 bool IsAllowedForAudio() const; |
| 77 bool IsAllowedForVideo() const; |
| 78 |
| 66 // Returns a list of devices available for the request for the given | 79 // Returns a list of devices available for the request for the given |
| 67 // audio/video permission settings. | 80 // audio/video permission settings. |
| 68 content::MediaStreamDevices GetDevices(ContentSetting audio_setting, | 81 content::MediaStreamDevices GetDevices(ContentSetting audio_setting, |
| 69 ContentSetting video_setting); | 82 ContentSetting video_setting); |
| 70 | 83 |
| 71 // Runs |callback_| with the given audio/video permission settings. If neither | 84 // Runs |callback_| with the given audio/video permission settings. If neither |
| 72 // |audio_setting| or |video_setting| is set to allow, |denial_reason| should | 85 // |audio_setting| or |video_setting| is set to allow, |denial_reason| should |
| 73 // be set to the error to be reported when running |callback_|. | 86 // be set to the error to be reported when running |callback_|. |
| 74 void RunCallback(ContentSetting audio_setting, | 87 void RunCallback(ContentSetting audio_setting, |
| 75 ContentSetting video_setting, | 88 ContentSetting video_setting, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 const content::MediaStreamRequest request_; | 136 const content::MediaStreamRequest request_; |
| 124 | 137 |
| 125 // The callback that needs to be Run to notify WebRTC of whether access to | 138 // The callback that needs to be Run to notify WebRTC of whether access to |
| 126 // audio/video devices was granted or not. | 139 // audio/video devices was granted or not. |
| 127 content::MediaResponseCallback callback_; | 140 content::MediaResponseCallback callback_; |
| 128 | 141 |
| 129 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); | 142 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); |
| 130 }; | 143 }; |
| 131 | 144 |
| 132 #endif // CHROME_BROWSER_MEDIA_WEBRTC_MEDIA_STREAM_DEVICES_CONTROLLER_H_ | 145 #endif // CHROME_BROWSER_MEDIA_WEBRTC_MEDIA_STREAM_DEVICES_CONTROLLER_H_ |
| OLD | NEW |