| 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_infobar_delegate.h" | 5 #include "chrome/browser/media/media_stream_infobar_delegate.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate( | 69 MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate( |
| 70 scoped_ptr<MediaStreamDevicesController> controller) | 70 scoped_ptr<MediaStreamDevicesController> controller) |
| 71 : ConfirmInfoBarDelegate(), | 71 : ConfirmInfoBarDelegate(), |
| 72 controller_(controller.Pass()) { | 72 controller_(controller.Pass()) { |
| 73 DCHECK(controller_.get()); | 73 DCHECK(controller_.get()); |
| 74 DCHECK(controller_->HasAudio() || controller_->HasVideo()); | 74 DCHECK(controller_->HasAudio() || controller_->HasVideo()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void MediaStreamInfoBarDelegate::InfoBarDismissed() { | 77 infobars::InfoBarDelegate::Type |
| 78 // Deny the request if the infobar was closed with the 'x' button, since | 78 MediaStreamInfoBarDelegate::GetInfoBarType() const { |
| 79 // we don't want WebRTC to be waiting for an answer that will never come. | 79 return PAGE_ACTION_TYPE; |
| 80 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", | |
| 81 kCancel, kPermissionActionsMax); | |
| 82 controller_->Deny(false, content::MEDIA_DEVICE_PERMISSION_DISMISSED); | |
| 83 } | 80 } |
| 84 | 81 |
| 85 int MediaStreamInfoBarDelegate::GetIconID() const { | 82 int MediaStreamInfoBarDelegate::GetIconID() const { |
| 86 return controller_->HasVideo() ? | 83 return controller_->HasVideo() ? |
| 87 IDR_INFOBAR_MEDIA_STREAM_CAMERA : IDR_INFOBAR_MEDIA_STREAM_MIC; | 84 IDR_INFOBAR_MEDIA_STREAM_CAMERA : IDR_INFOBAR_MEDIA_STREAM_MIC; |
| 88 } | 85 } |
| 89 | 86 |
| 90 infobars::InfoBarDelegate::Type MediaStreamInfoBarDelegate::GetInfoBarType() | 87 void MediaStreamInfoBarDelegate::InfoBarDismissed() { |
| 91 const { | 88 // Deny the request if the infobar was closed with the 'x' button, since |
| 92 return PAGE_ACTION_TYPE; | 89 // we don't want WebRTC to be waiting for an answer that will never come. |
| 90 UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions", |
| 91 kCancel, kPermissionActionsMax); |
| 92 controller_->Deny(false, content::MEDIA_DEVICE_PERMISSION_DISMISSED); |
| 93 } | 93 } |
| 94 | 94 |
| 95 MediaStreamInfoBarDelegate* | 95 MediaStreamInfoBarDelegate* |
| 96 MediaStreamInfoBarDelegate::AsMediaStreamInfoBarDelegate() { | 96 MediaStreamInfoBarDelegate::AsMediaStreamInfoBarDelegate() { |
| 97 return this; | 97 return this; |
| 98 } | 98 } |
| 99 | 99 |
| 100 base::string16 MediaStreamInfoBarDelegate::GetMessageText() const { | 100 base::string16 MediaStreamInfoBarDelegate::GetMessageText() const { |
| 101 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; | 101 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; |
| 102 if (!controller_->HasAudio()) | 102 if (!controller_->HasAudio()) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 WindowOpenDisposition disposition) { | 141 WindowOpenDisposition disposition) { |
| 142 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( | 142 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( |
| 143 content::OpenURLParams( | 143 content::OpenURLParams( |
| 144 GURL(chrome::kMediaAccessLearnMoreUrl), | 144 GURL(chrome::kMediaAccessLearnMoreUrl), |
| 145 content::Referrer(), | 145 content::Referrer(), |
| 146 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 146 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 147 ui::PAGE_TRANSITION_LINK, false)); | 147 ui::PAGE_TRANSITION_LINK, false)); |
| 148 | 148 |
| 149 return false; // Do not dismiss the info bar. | 149 return false; // Do not dismiss the info bar. |
| 150 } | 150 } |
| OLD | NEW |