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 <string> | 8 #include <string> |
9 | 9 |
10 #include "content/public/browser/web_contents_delegate.h" | 10 #include "content/public/browser/web_contents_delegate.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 } | 21 } |
22 | 22 |
23 class MediaStreamDevicesController { | 23 class MediaStreamDevicesController { |
24 public: | 24 public: |
25 MediaStreamDevicesController(content::WebContents* web_contents, | 25 MediaStreamDevicesController(content::WebContents* web_contents, |
26 const content::MediaStreamRequest& request, | 26 const content::MediaStreamRequest& request, |
27 const content::MediaResponseCallback& callback); | 27 const content::MediaResponseCallback& callback); |
28 | 28 |
29 virtual ~MediaStreamDevicesController(); | 29 virtual ~MediaStreamDevicesController(); |
30 | 30 |
| 31 // TODO(tommi): Clean up all the policy code and integrate with |
| 32 // HostContentSettingsMap instead. This will make creating the UI simpler |
| 33 // and the code cleaner. crbug.com/244389. |
| 34 |
31 // Registers the prefs backing the audio and video policies. | 35 // Registers the prefs backing the audio and video policies. |
32 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); | 36 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); |
33 | 37 |
34 // Public method to be called before creating the MediaStreamInfoBarDelegate. | 38 // Public method to be called before creating the MediaStreamInfoBarDelegate. |
35 // This function will check the content settings exceptions and take the | 39 // This function will check the content settings exceptions and take the |
36 // corresponding action on exception which matches the request. | 40 // corresponding action on exception which matches the request. |
37 bool DismissInfoBarAndTakeActionOnSettings(); | 41 bool DismissInfoBarAndTakeActionOnSettings(); |
38 | 42 |
39 // Public methods to be called by MediaStreamInfoBarDelegate; | 43 // Public methods to be called by MediaStreamInfoBarDelegate; |
40 bool has_audio() const { return microphone_requested_; } | 44 bool has_audio() const { return microphone_requested_; } |
41 bool has_video() const { return webcam_requested_; } | 45 bool has_video() const { return webcam_requested_; } |
42 const std::string& GetSecurityOriginSpec() const; | 46 const std::string& GetSecurityOriginSpec() const; |
43 void Accept(bool update_content_setting); | 47 void Accept(bool update_content_setting); |
44 void Deny(bool update_content_setting); | 48 void Deny(bool update_content_setting); |
45 | 49 |
46 private: | 50 private: |
47 enum DevicePolicy { | 51 enum DevicePolicy { |
48 POLICY_NOT_SET, | 52 POLICY_NOT_SET, |
49 ALWAYS_DENY, | 53 ALWAYS_DENY, |
50 ALWAYS_ALLOW, | 54 ALWAYS_ALLOW, |
51 }; | 55 }; |
52 | 56 |
53 // Called by GetAudioDevicePolicy and GetVideoDevicePolicy to check | 57 // Called by GetAudioDevicePolicy and GetVideoDevicePolicy to check |
54 // the currently set capture device policy. | 58 // the currently set capture device policy. |
55 DevicePolicy GetDevicePolicy(const char* policy_name) const; | 59 DevicePolicy GetDevicePolicy(const char* policy_name, |
| 60 const char* whitelist_policy_name) const; |
56 | 61 |
57 // Returns true if the origin of the request has been granted the media | 62 // Returns true if the origin of the request has been granted the media |
58 // access before, otherwise returns false. | 63 // access before, otherwise returns false. |
59 bool IsRequestAllowedByDefault() const; | 64 bool IsRequestAllowedByDefault() const; |
60 | 65 |
61 // Returns true if the media access for the origin of the request has been | 66 // Returns true if the media access for the origin of the request has been |
62 // blocked before. Otherwise returns false. | 67 // blocked before. Otherwise returns false. |
63 bool IsRequestBlockedByDefault() const; | 68 bool IsRequestBlockedByDefault() const; |
64 | 69 |
65 // Returns true if the media section in content settings is set to | 70 // Returns true if the media section in content settings is set to |
(...skipping 30 matching lines...) Expand all Loading... |
96 // audio/video devices was granted or not. | 101 // audio/video devices was granted or not. |
97 content::MediaResponseCallback callback_; | 102 content::MediaResponseCallback callback_; |
98 | 103 |
99 bool microphone_requested_; | 104 bool microphone_requested_; |
100 bool webcam_requested_; | 105 bool webcam_requested_; |
101 | 106 |
102 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); | 107 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); |
103 }; | 108 }; |
104 | 109 |
105 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ | 110 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ |
OLD | NEW |