Chromium Code Reviews| 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 #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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 } | 226 } |
| 227 | 227 |
| 228 bool MediaStreamDevicesController::IsAskingForAudio() const { | 228 bool MediaStreamDevicesController::IsAskingForAudio() const { |
| 229 return old_audio_setting_ == CONTENT_SETTING_ASK; | 229 return old_audio_setting_ == CONTENT_SETTING_ASK; |
| 230 } | 230 } |
| 231 | 231 |
| 232 bool MediaStreamDevicesController::IsAskingForVideo() const { | 232 bool MediaStreamDevicesController::IsAskingForVideo() const { |
| 233 return old_video_setting_ == CONTENT_SETTING_ASK; | 233 return old_video_setting_ == CONTENT_SETTING_ASK; |
| 234 } | 234 } |
| 235 | 235 |
| 236 base::string16 MediaStreamDevicesController::GetMessageText() const { | |
|
felt
2016/04/21 13:57:08
why does media stream still need this?
benwells
2016/04/21 23:47:57
Media Stream is a bit wonky still (but Tim's fixin
| |
| 237 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; | |
| 238 if (!IsAskingForAudio()) | |
| 239 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; | |
| 240 else if (!IsAskingForVideo()) | |
| 241 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; | |
| 242 return l10n_util::GetStringFUTF16( | |
| 243 message_id, | |
| 244 url_formatter::FormatUrlForSecurityDisplay( | |
| 245 GetOrigin(), url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); | |
| 246 } | |
| 247 | |
| 236 void MediaStreamDevicesController::ForcePermissionDeniedTemporarily() { | 248 void MediaStreamDevicesController::ForcePermissionDeniedTemporarily() { |
| 237 base::AutoReset<bool> persist_permissions( | 249 base::AutoReset<bool> persist_permissions( |
| 238 &persist_permission_changes_, false); | 250 &persist_permission_changes_, false); |
| 239 // TODO(tsergeant): Determine whether it is appropriate to record permission | 251 // TODO(tsergeant): Determine whether it is appropriate to record permission |
| 240 // action metrics here, as this is a different sort of user action. | 252 // action metrics here, as this is a different sort of user action. |
| 241 RunCallback(CONTENT_SETTING_BLOCK, | 253 RunCallback(CONTENT_SETTING_BLOCK, |
| 242 CONTENT_SETTING_BLOCK, | 254 CONTENT_SETTING_BLOCK, |
| 243 content::MEDIA_DEVICE_PERMISSION_DENIED); | 255 content::MEDIA_DEVICE_PERMISSION_DENIED); |
| 244 } | 256 } |
| 245 | 257 |
| 246 int MediaStreamDevicesController::GetIconId() const { | 258 int MediaStreamDevicesController::GetIconId() const { |
| 247 if (IsAskingForVideo()) | 259 if (IsAskingForVideo()) |
| 248 return IDR_INFOBAR_MEDIA_STREAM_CAMERA; | 260 return IDR_INFOBAR_MEDIA_STREAM_CAMERA; |
| 249 | 261 |
| 250 return IDR_INFOBAR_MEDIA_STREAM_MIC; | 262 return IDR_INFOBAR_MEDIA_STREAM_MIC; |
| 251 } | 263 } |
| 252 | 264 |
| 253 base::string16 MediaStreamDevicesController::GetMessageText() const { | |
| 254 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; | |
| 255 if (!IsAskingForAudio()) | |
| 256 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; | |
| 257 else if (!IsAskingForVideo()) | |
| 258 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; | |
| 259 return l10n_util::GetStringFUTF16( | |
| 260 message_id, | |
| 261 url_formatter::FormatUrlForSecurityDisplay( | |
| 262 GetOrigin(), url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); | |
| 263 } | |
| 264 | |
| 265 base::string16 MediaStreamDevicesController::GetMessageTextFragment() const { | 265 base::string16 MediaStreamDevicesController::GetMessageTextFragment() const { |
| 266 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO_PERMISSION_FRAGMENT; | 266 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO_PERMISSION_FRAGMENT; |
| 267 if (!IsAskingForAudio()) | 267 if (!IsAskingForAudio()) |
| 268 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_FRAGMENT; | 268 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_FRAGMENT; |
| 269 else if (!IsAskingForVideo()) | 269 else if (!IsAskingForVideo()) |
| 270 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT; | 270 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT; |
| 271 return l10n_util::GetStringUTF16(message_id); | 271 return l10n_util::GetStringUTF16(message_id); |
| 272 } | 272 } |
| 273 | 273 |
| 274 GURL MediaStreamDevicesController::GetOrigin() const { | 274 GURL MediaStreamDevicesController::GetOrigin() const { |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 if (android_permission_blocked) | 615 if (android_permission_blocked) |
| 616 return false; | 616 return false; |
| 617 | 617 |
| 618 // Don't approve device requests if the tab was hidden. | 618 // Don't approve device requests if the tab was hidden. |
| 619 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 619 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
| 620 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? | 620 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
| 621 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 621 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
| 622 #endif | 622 #endif |
| 623 return true; | 623 return true; |
| 624 } | 624 } |
| OLD | NEW |