| 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 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 virtual base::string16 GetMessageText() const OVERRIDE; | 77 virtual base::string16 GetMessageText() const OVERRIDE; |
| 78 virtual base::string16 GetMessageTextFragment() const OVERRIDE; | 78 virtual base::string16 GetMessageTextFragment() const OVERRIDE; |
| 79 virtual bool HasUserGesture() const OVERRIDE; | 79 virtual bool HasUserGesture() const OVERRIDE; |
| 80 virtual GURL GetRequestingHostname() const OVERRIDE; | 80 virtual GURL GetRequestingHostname() const OVERRIDE; |
| 81 virtual void PermissionGranted() OVERRIDE; | 81 virtual void PermissionGranted() OVERRIDE; |
| 82 virtual void PermissionDenied() OVERRIDE; | 82 virtual void PermissionDenied() OVERRIDE; |
| 83 virtual void Cancelled() OVERRIDE; | 83 virtual void Cancelled() OVERRIDE; |
| 84 virtual void RequestFinished() OVERRIDE; | 84 virtual void RequestFinished() OVERRIDE; |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 enum DevicePolicy { | |
| 88 POLICY_NOT_SET, | |
| 89 ALWAYS_DENY, | |
| 90 ALWAYS_ALLOW, | |
| 91 }; | |
| 92 | |
| 93 // Called by GetAudioDevicePolicy and GetVideoDevicePolicy to check | |
| 94 // the currently set capture device policy. | |
| 95 DevicePolicy GetDevicePolicy(const char* policy_name, | |
| 96 const char* whitelist_policy_name) const; | |
| 97 | |
| 98 // Returns true if the origin of the request has been granted the media | 87 // Returns true if the origin of the request has been granted the media |
| 99 // access before, otherwise returns false. | 88 // access before, otherwise returns false. |
| 100 bool IsRequestAllowedByDefault() const; | 89 bool IsRequestAllowedByDefault() const; |
| 101 | 90 |
| 102 // Check if any device of the request has been blocked for the origin of the | 91 // Check if any device of the request has been blocked for the origin of the |
| 103 // request and clears |microphone_requested_| or |webcam_requested_| flags if | 92 // request and clears |microphone_requested_| or |webcam_requested_| flags if |
| 104 // they are not allowed anymore. Returns the number of devices that are | 93 // they are not allowed anymore. Returns the number of devices that are |
| 105 // allowed after this step. If the count reaches zero the request can be | 94 // allowed after this step. If the count reaches zero the request can be |
| 106 // denied completely, else it still has to be partially fullfilled. | 95 // denied completely, else it still has to be partially fullfilled. |
| 107 int FilterBlockedByDefaultDevices(); | 96 int FilterBlockedByDefaultDevices(); |
| 108 | 97 |
| 109 // Returns true if the media section in content settings is set to | 98 // Returns true if the media section in content settings is set to |
| 110 // |CONTENT_SETTING_BLOCK|, otherwise returns false. | 99 // |CONTENT_SETTING_BLOCK|, otherwise returns false. |
| 111 bool IsDefaultMediaAccessBlocked() const; | 100 bool IsDefaultMediaAccessBlocked() const; |
| 112 | 101 |
| 113 // Returns true if the origin is a secure scheme, otherwise returns false. | 102 // Returns true if the origin is a secure scheme, otherwise returns false. |
| 114 bool IsSchemeSecure() const; | 103 bool IsSchemeSecure() const; |
| 115 | 104 |
| 116 // Returns true if request's origin is from internal objects like | |
| 117 // chrome://URLs, otherwise returns false. | |
| 118 bool ShouldAlwaysAllowOrigin() const; | |
| 119 | |
| 120 // Sets the permission of the origin of the request. This is triggered when | 105 // Sets the permission of the origin of the request. This is triggered when |
| 121 // the users deny the request or allow the request for https sites. | 106 // the users deny the request or allow the request for https sites. |
| 122 void SetPermission(bool allowed) const; | 107 void SetPermission(bool allowed) const; |
| 123 | 108 |
| 124 // Notifies the content setting UI that the media stream access request or | 109 // Notifies the content setting UI that the media stream access request or |
| 125 // part of the request is accepted. | 110 // part of the request is accepted. |
| 126 void NotifyUIRequestAccepted() const; | 111 void NotifyUIRequestAccepted() const; |
| 127 | 112 |
| 128 // Notifies the content setting UI that the media stream access request or | 113 // Notifies the content setting UI that the media stream access request or |
| 129 // part of the request is denied. | 114 // part of the request is denied. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // passed to the tab specific content settings when the permissions have been | 150 // passed to the tab specific content settings when the permissions have been |
| 166 // resolved. Currently only used by MEDIA_DEVICE_AUDIO_CAPTURE and | 151 // resolved. Currently only used by MEDIA_DEVICE_AUDIO_CAPTURE and |
| 167 // MEDIA_DEVICE_VIDEO_CAPTURE since those are the only types that require | 152 // MEDIA_DEVICE_VIDEO_CAPTURE since those are the only types that require |
| 168 // updates in the settings. | 153 // updates in the settings. |
| 169 MediaStreamTypeSettingsMap request_permissions_; | 154 MediaStreamTypeSettingsMap request_permissions_; |
| 170 | 155 |
| 171 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); | 156 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); |
| 172 }; | 157 }; |
| 173 | 158 |
| 174 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ | 159 #endif // CHROME_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ |
| OLD | NEW |