| Index: chrome/browser/media/media_stream_infobar_delegate.cc
|
| diff --git a/chrome/browser/media/media_stream_infobar_delegate.cc b/chrome/browser/media/media_stream_infobar_delegate.cc
|
| deleted file mode 100644
|
| index 7fbc26d1149bf7ecc337a5ad20a90c8ca53c812e..0000000000000000000000000000000000000000
|
| --- a/chrome/browser/media/media_stream_infobar_delegate.cc
|
| +++ /dev/null
|
| @@ -1,146 +0,0 @@
|
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| -// Use of this source code is governed by a BSD-style license that can be
|
| -// found in the LICENSE file.
|
| -
|
| -#include "chrome/browser/media/media_stream_infobar_delegate.h"
|
| -
|
| -#include "base/logging.h"
|
| -#include "base/metrics/histogram.h"
|
| -#include "base/strings/utf_string_conversions.h"
|
| -#include "chrome/browser/infobars/infobar_service.h"
|
| -#include "chrome/common/url_constants.h"
|
| -#include "chrome/grit/generated_resources.h"
|
| -#include "components/google/core/browser/google_util.h"
|
| -#include "components/infobars/core/infobar.h"
|
| -#include "content/public/browser/web_contents.h"
|
| -#include "content/public/common/origin_util.h"
|
| -#include "grit/components_strings.h"
|
| -#include "grit/theme_resources.h"
|
| -#include "ui/base/l10n/l10n_util.h"
|
| -#include "url/gurl.h"
|
| -
|
| -namespace {
|
| -
|
| -enum DevicePermissionActions {
|
| - kAllowHttps = 0,
|
| - kAllowHttp,
|
| - kDeny,
|
| - kCancel,
|
| - kPermissionActionsMax // Must always be last!
|
| -};
|
| -
|
| -} // namespace
|
| -
|
| -MediaStreamInfoBarDelegate::~MediaStreamInfoBarDelegate() {
|
| -}
|
| -
|
| -// static
|
| -bool MediaStreamInfoBarDelegate::Create(
|
| - content::WebContents* web_contents,
|
| - scoped_ptr<MediaStreamDevicesController> controller) {
|
| -
|
| - InfoBarService* infobar_service =
|
| - InfoBarService::FromWebContents(web_contents);
|
| - if (!infobar_service) {
|
| - // Deny the request if there is no place to show the infobar, e.g. when
|
| - // the request comes from a background extension page.
|
| - controller->Cancelled();
|
| - return false;
|
| - }
|
| -
|
| - scoped_ptr<infobars::InfoBar> infobar(
|
| - infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>(
|
| - new MediaStreamInfoBarDelegate(controller.Pass()))));
|
| - for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
|
| - infobars::InfoBar* old_infobar = infobar_service->infobar_at(i);
|
| - if (old_infobar->delegate()->AsMediaStreamInfoBarDelegate()) {
|
| - infobar_service->ReplaceInfoBar(old_infobar, infobar.Pass());
|
| - return true;
|
| - }
|
| - }
|
| - infobar_service->AddInfoBar(infobar.Pass());
|
| - return true;
|
| -}
|
| -
|
| -bool MediaStreamInfoBarDelegate::IsRequestingVideoAccess() const {
|
| - return controller_->IsAskingForVideo();
|
| -}
|
| -
|
| -bool MediaStreamInfoBarDelegate::IsRequestingMicrophoneAccess() const {
|
| - return controller_->IsAskingForAudio();
|
| -}
|
| -
|
| -MediaStreamInfoBarDelegate::MediaStreamInfoBarDelegate(
|
| - scoped_ptr<MediaStreamDevicesController> controller)
|
| - : ConfirmInfoBarDelegate(),
|
| - controller_(controller.Pass()) {
|
| - DCHECK(controller_.get());
|
| - DCHECK(controller_->IsAskingForAudio() || controller_->IsAskingForVideo());
|
| -}
|
| -
|
| -infobars::InfoBarDelegate::Type
|
| -MediaStreamInfoBarDelegate::GetInfoBarType() const {
|
| - return PAGE_ACTION_TYPE;
|
| -}
|
| -
|
| -int MediaStreamInfoBarDelegate::GetIconId() const {
|
| - return controller_->IsAskingForVideo() ? IDR_INFOBAR_MEDIA_STREAM_CAMERA
|
| - : IDR_INFOBAR_MEDIA_STREAM_MIC;
|
| -}
|
| -
|
| -void MediaStreamInfoBarDelegate::InfoBarDismissed() {
|
| - // Deny the request if the infobar was closed with the 'x' button, since
|
| - // we don't want WebRTC to be waiting for an answer that will never come.
|
| - UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions",
|
| - kCancel, kPermissionActionsMax);
|
| - controller_->Cancelled();
|
| -}
|
| -
|
| -MediaStreamInfoBarDelegate*
|
| - MediaStreamInfoBarDelegate::AsMediaStreamInfoBarDelegate() {
|
| - return this;
|
| -}
|
| -
|
| -base::string16 MediaStreamInfoBarDelegate::GetMessageText() const {
|
| - int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO;
|
| - if (!controller_->IsAskingForAudio())
|
| - message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY;
|
| - else if (!controller_->IsAskingForVideo())
|
| - message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY;
|
| - return l10n_util::GetStringFUTF16(
|
| - message_id, base::UTF8ToUTF16(controller_->GetSecurityOriginSpec()));
|
| -}
|
| -
|
| -base::string16 MediaStreamInfoBarDelegate::GetButtonLabel(
|
| - InfoBarButton button) const {
|
| - return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
|
| - IDS_MEDIA_CAPTURE_ALLOW : IDS_MEDIA_CAPTURE_BLOCK);
|
| -}
|
| -
|
| -bool MediaStreamInfoBarDelegate::Accept() {
|
| - GURL origin(controller_->GetSecurityOriginSpec());
|
| - if (content::IsOriginSecure(origin)) {
|
| - UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions",
|
| - kAllowHttps, kPermissionActionsMax);
|
| - } else {
|
| - UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions",
|
| - kAllowHttp, kPermissionActionsMax);
|
| - }
|
| - controller_->PermissionGranted();
|
| - return true;
|
| -}
|
| -
|
| -bool MediaStreamInfoBarDelegate::Cancel() {
|
| - UMA_HISTOGRAM_ENUMERATION("Media.DevicePermissionActions",
|
| - kDeny, kPermissionActionsMax);
|
| - controller_->PermissionDenied();
|
| - return true;
|
| -}
|
| -
|
| -base::string16 MediaStreamInfoBarDelegate::GetLinkText() const {
|
| - return base::string16();
|
| -}
|
| -
|
| -GURL MediaStreamInfoBarDelegate::GetLinkURL() const {
|
| - return GURL(chrome::kMediaAccessLearnMoreUrl);
|
| -}
|
|
|