| 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_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 <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/ui/website_settings/permission_bubble_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 class MediaStreamDevicesController : public PermissionBubbleRequest { | 27 class MediaStreamDevicesController : public PermissionRequest { |
| 28 public: | 28 public: |
| 29 MediaStreamDevicesController(content::WebContents* web_contents, | 29 MediaStreamDevicesController(content::WebContents* web_contents, |
| 30 const content::MediaStreamRequest& request, | 30 const content::MediaStreamRequest& request, |
| 31 const content::MediaResponseCallback& callback); | 31 const content::MediaResponseCallback& callback); |
| 32 | 32 |
| 33 ~MediaStreamDevicesController() override; | 33 ~MediaStreamDevicesController() override; |
| 34 | 34 |
| 35 // Registers the prefs backing the audio and video policies. | 35 // Registers the prefs backing the audio and video policies. |
| 36 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 36 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 37 | 37 |
| 38 bool IsAllowedForAudio() const; | 38 bool IsAllowedForAudio() const; |
| 39 bool IsAllowedForVideo() const; | 39 bool IsAllowedForVideo() const; |
| 40 bool IsAskingForAudio() const; | 40 bool IsAskingForAudio() const; |
| 41 bool IsAskingForVideo() const; | 41 bool IsAskingForVideo() const; |
| 42 base::string16 GetMessageText() const; | 42 base::string16 GetMessageText() const; |
| 43 | 43 |
| 44 // Forces the permissions to be denied (without being persisted) regardless | 44 // Forces the permissions to be denied (without being persisted) regardless |
| 45 // of what the previous state was. If the user had previously allowed the | 45 // 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 | 46 // site video or audio access, this ignores that and informs the site it was |
| 47 // denied. | 47 // denied. |
| 48 // | 48 // |
| 49 // This differs from PermissionGranted/PermissionDenied as they only operate | 49 // This differs from PermissionGranted/PermissionDenied as they only operate |
| 50 // on the permissions if they are in the ASK state. | 50 // on the permissions if they are in the ASK state. |
| 51 void ForcePermissionDeniedTemporarily(); | 51 void ForcePermissionDeniedTemporarily(); |
| 52 | 52 |
| 53 // Answers a permission request with (possibly) different values for | 53 // Answers a permission request with (possibly) different values for |
| 54 // |audio_accepted| and |video_accepted|. Intended for use from | 54 // |audio_accepted| and |video_accepted|. Intended for use from |
| 55 // MediaStreamInfobarDelegateAndroid. | 55 // MediaStreamInfobarDelegateAndroid. |
| 56 // TODO(tsergeant): Remove this by refactoring Android to use | 56 // TODO(tsergeant): Remove this by refactoring Android to use |
| 57 // PermissionBubbleRequest instead of a custom infobar delegate. | 57 // PermissionRequest instead of a custom infobar delegate. |
| 58 void GroupedRequestFinished(bool audio_accepted, bool video_accepted); | 58 void GroupedRequestFinished(bool audio_accepted, bool video_accepted); |
| 59 | 59 |
| 60 // PermissionBubbleRequest: | 60 // PermissionRequest: |
| 61 int GetIconId() const override; | 61 int GetIconId() const override; |
| 62 base::string16 GetMessageTextFragment() const override; | 62 base::string16 GetMessageTextFragment() const override; |
| 63 GURL GetOrigin() const override; | 63 GURL GetOrigin() const override; |
| 64 void PermissionGranted() override; | 64 void PermissionGranted() override; |
| 65 void PermissionDenied() override; | 65 void PermissionDenied() override; |
| 66 void Cancelled() override; | 66 void Cancelled() override; |
| 67 void RequestFinished() override; | 67 void RequestFinished() override; |
| 68 PermissionBubbleType GetPermissionBubbleType() const override; | 68 PermissionRequestType GetPermissionRequestType() const override; |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 // Returns a list of devices available for the request for the given | 71 // Returns a list of devices available for the request for the given |
| 72 // audio/video permission settings. | 72 // audio/video permission settings. |
| 73 content::MediaStreamDevices GetDevices(ContentSetting audio_setting, | 73 content::MediaStreamDevices GetDevices(ContentSetting audio_setting, |
| 74 ContentSetting video_setting); | 74 ContentSetting video_setting); |
| 75 | 75 |
| 76 // Runs |callback_| with the given audio/video permission settings. If neither | 76 // Runs |callback_| with the given audio/video permission settings. If neither |
| 77 // |audio_setting| or |video_setting| is set to allow, |denial_reason| should | 77 // |audio_setting| or |video_setting| is set to allow, |denial_reason| should |
| 78 // be set to the error to be reported when running |callback_|. | 78 // be set to the error to be reported when running |callback_|. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // audio/video devices was granted or not. | 131 // audio/video devices was granted or not. |
| 132 content::MediaResponseCallback callback_; | 132 content::MediaResponseCallback callback_; |
| 133 | 133 |
| 134 // Whether the permissions granted or denied by the user should be persisted. | 134 // Whether the permissions granted or denied by the user should be persisted. |
| 135 bool persist_permission_changes_; | 135 bool persist_permission_changes_; |
| 136 | 136 |
| 137 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); | 137 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ | 140 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ |
| OLD | NEW |