| 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/webrtc/media_stream_devices_controller.h" | 5 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } | 213 } |
| 214 | 214 |
| 215 bool MediaStreamDevicesController::Request::IsAskingForAudio() const { | 215 bool MediaStreamDevicesController::Request::IsAskingForAudio() const { |
| 216 return is_asking_for_audio_; | 216 return is_asking_for_audio_; |
| 217 } | 217 } |
| 218 | 218 |
| 219 bool MediaStreamDevicesController::Request::IsAskingForVideo() const { | 219 bool MediaStreamDevicesController::Request::IsAskingForVideo() const { |
| 220 return is_asking_for_video_; | 220 return is_asking_for_video_; |
| 221 } | 221 } |
| 222 | 222 |
| 223 PermissionRequest::IconId MediaStreamDevicesController::Request::GetIconId() |
| 224 const { |
| 225 #if defined(OS_ANDROID) |
| 226 return IsAskingForVideo() ? IDR_INFOBAR_MEDIA_STREAM_CAMERA |
| 227 : IDR_INFOBAR_MEDIA_STREAM_MIC; |
| 228 #else |
| 229 return IsAskingForVideo() ? ui::kVideocamIcon : ui::kMicrophoneIcon; |
| 230 #endif |
| 231 } |
| 232 |
| 233 #if defined(OS_ANDROID) |
| 223 base::string16 MediaStreamDevicesController::Request::GetMessageText() const { | 234 base::string16 MediaStreamDevicesController::Request::GetMessageText() const { |
| 224 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; | 235 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; |
| 225 if (!IsAskingForAudio()) | 236 if (!IsAskingForAudio()) |
| 226 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; | 237 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; |
| 227 else if (!IsAskingForVideo()) | 238 else if (!IsAskingForVideo()) |
| 228 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; | 239 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; |
| 229 return l10n_util::GetStringFUTF16( | 240 return l10n_util::GetStringFUTF16( |
| 230 message_id, | 241 message_id, |
| 231 url_formatter::FormatUrlForSecurityDisplay( | 242 url_formatter::FormatUrlForSecurityDisplay( |
| 232 GetOrigin(), url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); | 243 GetOrigin(), url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); |
| 233 } | 244 } |
| 234 | |
| 235 PermissionRequest::IconId MediaStreamDevicesController::Request::GetIconId() | |
| 236 const { | |
| 237 #if defined(OS_ANDROID) | |
| 238 return IsAskingForVideo() ? IDR_INFOBAR_MEDIA_STREAM_CAMERA | |
| 239 : IDR_INFOBAR_MEDIA_STREAM_MIC; | |
| 240 #else | |
| 241 return IsAskingForVideo() ? ui::kVideocamIcon : ui::kMicrophoneIcon; | |
| 242 #endif | 245 #endif |
| 243 } | |
| 244 | 246 |
| 245 base::string16 MediaStreamDevicesController::Request::GetMessageTextFragment() | 247 base::string16 MediaStreamDevicesController::Request::GetMessageTextFragment() |
| 246 const { | 248 const { |
| 247 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO_PERMISSION_FRAGMENT; | 249 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO_PERMISSION_FRAGMENT; |
| 248 if (!IsAskingForAudio()) | 250 if (!IsAskingForAudio()) |
| 249 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_FRAGMENT; | 251 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_FRAGMENT; |
| 250 else if (!IsAskingForVideo()) | 252 else if (!IsAskingForVideo()) |
| 251 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT; | 253 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT; |
| 252 return l10n_util::GetStringUTF16(message_id); | 254 return l10n_util::GetStringUTF16(message_id); |
| 253 } | 255 } |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 } | 772 } |
| 771 } | 773 } |
| 772 | 774 |
| 773 // Don't approve device requests if the tab was hidden. | 775 // Don't approve device requests if the tab was hidden. |
| 774 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 776 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
| 775 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? | 777 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
| 776 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 778 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
| 777 #endif | 779 #endif |
| 778 return true; | 780 return true; |
| 779 } | 781 } |
| OLD | NEW |