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

Side by Side Diff: chrome/browser/media/media_stream_devices_controller.cc

Issue 2342233003: Add a feature-controlled persistence checkbox to geolocation prompts on desktop Views platforms. (Closed)
Patch Set: Created 4 years, 3 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
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 #include "chrome/browser/media/media_stream_devices_controller.h" 5 #include "chrome/browser/media/media_stream_devices_controller.h"
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 }; 158 };
159 159
160 } // namespace 160 } // namespace
161 161
162 MediaStreamDevicesController::MediaStreamDevicesController( 162 MediaStreamDevicesController::MediaStreamDevicesController(
163 content::WebContents* web_contents, 163 content::WebContents* web_contents,
164 const content::MediaStreamRequest& request, 164 const content::MediaStreamRequest& request,
165 const content::MediaResponseCallback& callback) 165 const content::MediaResponseCallback& callback)
166 : web_contents_(web_contents), 166 : web_contents_(web_contents),
167 request_(request), 167 request_(request),
168 callback_(callback), 168 callback_(callback) {
169 persist_(true) {
170 if (request_.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) { 169 if (request_.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) {
171 MediaPermissionRequestLogger::LogRequest( 170 MediaPermissionRequestLogger::LogRequest(
172 web_contents, request.render_process_id, request.render_frame_id, 171 web_contents, request.render_process_id, request.render_frame_id,
173 content::IsOriginSecure(request_.security_origin)); 172 content::IsOriginSecure(request_.security_origin));
174 } 173 }
175 profile_ = Profile::FromBrowserContext(web_contents->GetBrowserContext()); 174 profile_ = Profile::FromBrowserContext(web_contents->GetBrowserContext());
176 content_settings_ = TabSpecificContentSettings::FromWebContents(web_contents); 175 content_settings_ = TabSpecificContentSettings::FromWebContents(web_contents);
177 176
178 content::MediaStreamRequestResult denial_reason = content::MEDIA_DEVICE_OK; 177 content::MediaStreamRequestResult denial_reason = content::MEDIA_DEVICE_OK;
179 old_audio_setting_ = GetContentSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, 178 old_audio_setting_ = GetContentSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 MediaStreamDevicesController::GetPermissionTypeForContentSettingsType( 261 MediaStreamDevicesController::GetPermissionTypeForContentSettingsType(
263 ContentSettingsType content_type) const { 262 ContentSettingsType content_type) const {
264 DCHECK(content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || 263 DCHECK(content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
265 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 264 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
266 content::PermissionType permission = content::PermissionType::NUM; 265 content::PermissionType permission = content::PermissionType::NUM;
267 CHECK(PermissionUtil::GetPermissionType(content_type, &permission)); 266 CHECK(PermissionUtil::GetPermissionType(content_type, &permission));
268 return permission; 267 return permission;
269 } 268 }
270 269
271 void MediaStreamDevicesController::ForcePermissionDeniedTemporarily() { 270 void MediaStreamDevicesController::ForcePermissionDeniedTemporarily() {
272 base::AutoReset<bool> persist_permissions(&persist_, false); 271 set_persist(false);
273 // TODO(tsergeant): Determine whether it is appropriate to record permission 272 // TODO(tsergeant): Determine whether it is appropriate to record permission
274 // action metrics here, as this is a different sort of user action. 273 // action metrics here, as this is a different sort of user action.
275 RunCallback(CONTENT_SETTING_BLOCK, 274 RunCallback(CONTENT_SETTING_BLOCK,
276 CONTENT_SETTING_BLOCK, 275 CONTENT_SETTING_BLOCK,
277 content::MEDIA_DEVICE_PERMISSION_DENIED); 276 content::MEDIA_DEVICE_PERMISSION_DENIED);
278 } 277 }
279 278
280 int MediaStreamDevicesController::GetIconId() const { 279 int MediaStreamDevicesController::GetIconId() const {
281 if (IsAskingForVideo()) 280 if (IsAskingForVideo())
282 return IDR_INFOBAR_MEDIA_STREAM_CAMERA; 281 return IDR_INFOBAR_MEDIA_STREAM_CAMERA;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 audio_accepted ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 331 audio_accepted ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
333 ContentSetting video_setting = 332 ContentSetting video_setting =
334 video_accepted ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 333 video_accepted ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
335 RunCallback(GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, 334 RunCallback(GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
336 old_audio_setting_, audio_setting), 335 old_audio_setting_, audio_setting),
337 GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, 336 GetNewSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
338 old_video_setting_, video_setting), 337 old_video_setting_, video_setting),
339 content::MEDIA_DEVICE_PERMISSION_DENIED); 338 content::MEDIA_DEVICE_PERMISSION_DENIED);
340 } 339 }
341 340
341 bool MediaStreamDevicesController::ShouldShowPersistenceToggle() const {
342 return PermissionUtil::ShouldShowPersistenceToggle();
343 }
344
342 void MediaStreamDevicesController::Cancelled() { 345 void MediaStreamDevicesController::Cancelled() {
343 RecordPermissionAction(request_, profile_, 346 RecordPermissionAction(request_, profile_,
344 base::Bind(PermissionUmaUtil::PermissionDismissed)); 347 base::Bind(PermissionUmaUtil::PermissionDismissed));
345 RunCallback(old_audio_setting_, old_video_setting_, 348 RunCallback(old_audio_setting_, old_video_setting_,
346 content::MEDIA_DEVICE_PERMISSION_DISMISSED); 349 content::MEDIA_DEVICE_PERMISSION_DISMISSED);
347 } 350 }
348 351
349 void MediaStreamDevicesController::RequestFinished() { 352 void MediaStreamDevicesController::RequestFinished() {
350 delete this; 353 delete this;
351 } 354 }
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 if (android_permission_blocked) 647 if (android_permission_blocked)
645 return false; 648 return false;
646 649
647 // Don't approve device requests if the tab was hidden. 650 // Don't approve device requests if the tab was hidden.
648 // TODO(qinmin): Add a test for this. http://crbug.com/396869. 651 // TODO(qinmin): Add a test for this. http://crbug.com/396869.
649 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? 652 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video?
650 return web_contents_->GetRenderWidgetHostView()->IsShowing(); 653 return web_contents_->GetRenderWidgetHostView()->IsShowing();
651 #endif 654 #endif
652 return true; 655 return true;
653 } 656 }
OLDNEW
« no previous file with comments | « chrome/browser/media/media_stream_devices_controller.h ('k') | chrome/browser/permissions/permission_context_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698