Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: chrome/browser/media/webrtc/media_stream_devices_controller.h

Issue 2814993003: Simplify the code for updating Android permissions in MediaStreamDevicesController (Closed)
Patch Set: Simplify the code for updating Android permissions in MediaStreamDevicesController Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/media/webrtc/media_stream_devices_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 // Called when a permission prompt has been answered, with the |response| and 108 // Called when a permission prompt has been answered, with the |response| and
109 // whether the choice should be persisted. 109 // whether the choice should be persisted.
110 void PromptAnswered(ContentSetting response, bool persist); 110 void PromptAnswered(ContentSetting response, bool persist);
111 111
112 #if defined(OS_ANDROID) 112 #if defined(OS_ANDROID)
113 // Called when the Android OS-level prompt is answered. 113 // Called when the Android OS-level prompt is answered.
114 void AndroidOSPromptAnswered(bool allowed); 114 void AndroidOSPromptAnswered(bool allowed);
115 #endif // defined(OS_ANDROID) 115 #endif // defined(OS_ANDROID)
116 116
117 // Called when the request is finished and no prompt is required.
118 void RequestFinishedNoPrompt();
119
117 private: 120 private:
118 friend class MediaStreamDevicesControllerTest; 121 friend class MediaStreamDevicesControllerTest;
119 friend class test::MediaStreamDevicesControllerTestApi; 122 friend class test::MediaStreamDevicesControllerTestApi;
120 friend class policy::MediaStreamDevicesControllerBrowserTest; 123 friend class policy::MediaStreamDevicesControllerBrowserTest;
121 124
122 class PermissionPromptDelegateImpl; 125 class PermissionPromptDelegateImpl;
123 126
124 static void RequestPermissionsWithDelegate( 127 static void RequestPermissionsWithDelegate(
125 const content::MediaStreamRequest& request, 128 const content::MediaStreamRequest& request,
126 const content::MediaResponseCallback& callback, 129 const content::MediaResponseCallback& callback,
127 PermissionPromptDelegate* delegate); 130 PermissionPromptDelegate* delegate);
128 131
129 MediaStreamDevicesController(content::WebContents* web_contents, 132 MediaStreamDevicesController(content::WebContents* web_contents,
130 const content::MediaStreamRequest& request, 133 const content::MediaStreamRequest& request,
131 const content::MediaResponseCallback& callback); 134 const content::MediaResponseCallback& callback);
132 135
133 bool IsAllowedForAudio() const; 136 bool IsAllowedForAudio() const;
134 bool IsAllowedForVideo() const; 137 bool IsAllowedForVideo() const;
135 138
136 // Returns a list of devices available for the request for the given 139 // Returns a list of devices available for the request for the given
137 // audio/video permission settings. 140 // audio/video permission settings.
138 content::MediaStreamDevices GetDevices(ContentSetting audio_setting, 141 content::MediaStreamDevices GetDevices(ContentSetting audio_setting,
139 ContentSetting video_setting); 142 ContentSetting video_setting);
140 143
141 // Runs |callback_| with the given audio/video permission settings. If neither 144 // Runs |callback_| with the current audio/video permission settings.
142 // |audio_setting| or |video_setting| is set to allow, |denial_reason| should 145 void RunCallback();
143 // be set to the error to be reported when running |callback_|.
144 void RunCallback(ContentSetting audio_setting,
145 ContentSetting video_setting,
146 content::MediaStreamRequestResult denial_reason);
147 146
148 // Called when the permission has been set to update the 147 // Called when the permission has been set to update the
149 // TabSpecificContentSettings. 148 // TabSpecificContentSettings.
150 void UpdateTabSpecificContentSettings(ContentSetting audio_setting, 149 void UpdateTabSpecificContentSettings(ContentSetting audio_setting,
151 ContentSetting video_setting) const; 150 ContentSetting video_setting) const;
152 151
153 // Returns the content settings for the given content type and request. 152 // Returns the content settings for the given content type and request.
154 ContentSetting GetContentSetting( 153 ContentSetting GetContentSetting(
155 ContentSettingsType content_type, 154 ContentSettingsType content_type,
156 const content::MediaStreamRequest& request, 155 const content::MediaStreamRequest& request,
157 content::MediaStreamRequestResult* denial_reason) const; 156 content::MediaStreamRequestResult* denial_reason) const;
158 157
159 // Returns true if clicking allow on the dialog should give access to the 158 // Returns true if clicking allow on the dialog should give access to the
160 // requested devices. 159 // requested devices.
161 bool IsUserAcceptAllowed(ContentSettingsType content_type) const; 160 bool IsUserAcceptAllowed(ContentSettingsType content_type) const;
162 161
163 // The audio/video content settings BEFORE the user clicks accept/deny. 162 // The current state of the audio/video content settings which may be updated
164 ContentSetting old_audio_setting_; 163 // through the lifetime of the request.
165 ContentSetting old_video_setting_; 164 ContentSetting audio_setting_;
165 ContentSetting video_setting_;
166 content::MediaStreamRequestResult denial_reason_;
166 167
167 content::WebContents* web_contents_; 168 content::WebContents* web_contents_;
168 169
169 // The owner of this class needs to make sure it does not outlive the profile. 170 // The owner of this class needs to make sure it does not outlive the profile.
170 Profile* profile_; 171 Profile* profile_;
171 172
172 // Weak pointer to the tab specific content settings of the tab for which the 173 // Weak pointer to the tab specific content settings of the tab for which the
173 // MediaStreamDevicesController was created. The tab specific content 174 // MediaStreamDevicesController was created. The tab specific content
174 // settings are associated with a the web contents of the tab. The 175 // settings are associated with a the web contents of the tab. The
175 // MediaStreamDeviceController must not outlive the web contents for which it 176 // MediaStreamDeviceController must not outlive the web contents for which it
176 // was created. 177 // was created.
177 TabSpecificContentSettings* content_settings_; 178 TabSpecificContentSettings* content_settings_;
178 179
179 // The original request for access to devices. 180 // The original request for access to devices.
180 const content::MediaStreamRequest request_; 181 const content::MediaStreamRequest request_;
181 182
182 // The callback that needs to be Run to notify WebRTC of whether access to 183 // The callback that needs to be Run to notify WebRTC of whether access to
183 // audio/video devices was granted or not. 184 // audio/video devices was granted or not.
184 content::MediaResponseCallback callback_; 185 content::MediaResponseCallback callback_;
185 186
186 std::unique_ptr<PermissionPromptDelegate> delegate_; 187 std::unique_ptr<PermissionPromptDelegate> delegate_;
187 188
188 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); 189 DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController);
189 }; 190 };
190 191
191 #endif // CHROME_BROWSER_MEDIA_WEBRTC_MEDIA_STREAM_DEVICES_CONTROLLER_H_ 192 #endif // CHROME_BROWSER_MEDIA_WEBRTC_MEDIA_STREAM_DEVICES_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media/webrtc/media_stream_devices_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698