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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 NotifyUIRequestDenied(); | 342 NotifyUIRequestDenied(); |
343 | 343 |
344 if (update_content_setting) | 344 if (update_content_setting) |
345 SetPermission(false); | 345 SetPermission(false); |
346 | 346 |
347 content::MediaResponseCallback cb = callback_; | 347 content::MediaResponseCallback cb = callback_; |
348 callback_.Reset(); | 348 callback_.Reset(); |
349 cb.Run(content::MediaStreamDevices(), scoped_ptr<content::MediaStreamUI>()); | 349 cb.Run(content::MediaStreamDevices(), scoped_ptr<content::MediaStreamUI>()); |
350 } | 350 } |
351 | 351 |
| 352 int MediaStreamDevicesController::GetIconID() const { |
| 353 if (HasVideo()) |
| 354 return IDR_INFOBAR_MEDIA_STREAM_CAMERA; |
| 355 |
| 356 return IDR_INFOBAR_MEDIA_STREAM_MIC; |
| 357 } |
| 358 |
352 base::string16 MediaStreamDevicesController::GetMessageText() const { | 359 base::string16 MediaStreamDevicesController::GetMessageText() const { |
353 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; | 360 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; |
354 if (!HasAudio()) | 361 if (!HasAudio()) |
355 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; | 362 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; |
356 else if (!HasVideo()) | 363 else if (!HasVideo()) |
357 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; | 364 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; |
358 return l10n_util::GetStringFUTF16( | 365 return l10n_util::GetStringFUTF16( |
359 message_id, base::UTF8ToUTF16(GetSecurityOriginSpec())); | 366 message_id, base::UTF8ToUTF16(GetSecurityOriginSpec())); |
360 } | 367 } |
361 | 368 |
362 base::string16 MediaStreamDevicesController::GetMessageTextFragment() const { | 369 base::string16 MediaStreamDevicesController::GetMessageTextFragment() const { |
363 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO_PERMISSION_FRAGMENT; | 370 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO_PERMISSION_FRAGMENT; |
364 if (!HasAudio()) | 371 if (!HasAudio()) |
365 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_FRAGMENT; | 372 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_FRAGMENT; |
366 else if (!HasVideo()) | 373 else if (!HasVideo()) |
367 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT; | 374 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT; |
368 return l10n_util::GetStringUTF16(message_id); | 375 return l10n_util::GetStringUTF16(message_id); |
369 } | 376 } |
370 | 377 |
371 base::string16 | 378 bool MediaStreamDevicesController::HasUserGesture() const { |
372 MediaStreamDevicesController::GetAlternateAcceptButtonText() const { | 379 // TODO(gbillock): plumb this through |
373 return l10n_util::GetStringUTF16(IDS_MEDIA_CAPTURE_ALLOW); | 380 return false; |
374 } | |
375 | |
376 base::string16 | |
377 MediaStreamDevicesController::GetAlternateDenyButtonText() const { | |
378 return l10n_util::GetStringUTF16(IDS_MEDIA_CAPTURE_DENY); | |
379 } | 381 } |
380 | 382 |
381 void MediaStreamDevicesController::PermissionGranted() { | 383 void MediaStreamDevicesController::PermissionGranted() { |
382 GURL origin(GetSecurityOriginSpec()); | 384 GURL origin(GetSecurityOriginSpec()); |
383 if (origin.SchemeIsSecure()) { | 385 if (origin.SchemeIsSecure()) { |
384 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", | 386 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", |
385 kAllowHttps, kPermissionActionsMax); | 387 kAllowHttps, kPermissionActionsMax); |
386 } else { | 388 } else { |
387 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", | 389 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", |
388 kAllowHttp, kPermissionActionsMax); | 390 kAllowHttp, kPermissionActionsMax); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 it->second.permission == MEDIA_ALLOWED); | 622 it->second.permission == MEDIA_ALLOWED); |
621 } | 623 } |
622 | 624 |
623 bool MediaStreamDevicesController::IsDeviceVideoCaptureRequestedAndAllowed() | 625 bool MediaStreamDevicesController::IsDeviceVideoCaptureRequestedAndAllowed() |
624 const { | 626 const { |
625 MediaStreamTypeSettingsMap::const_iterator it = | 627 MediaStreamTypeSettingsMap::const_iterator it = |
626 request_permissions_.find(content::MEDIA_DEVICE_VIDEO_CAPTURE); | 628 request_permissions_.find(content::MEDIA_DEVICE_VIDEO_CAPTURE); |
627 return (it != request_permissions_.end() && | 629 return (it != request_permissions_.end() && |
628 it->second.permission == MEDIA_ALLOWED); | 630 it->second.permission == MEDIA_ALLOWED); |
629 } | 631 } |
OLD | NEW |