Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2006)

Unified Diff: chrome/browser/media/media_stream_infobar_delegate_android.cc

Issue 1889643003: Permissions: Add new Infobar to support grouped permission requests on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/media_stream_infobar_delegate_android.cc
diff --git a/chrome/browser/media/media_stream_infobar_delegate_android.cc b/chrome/browser/media/media_stream_infobar_delegate_android.cc
index fe04c526f624d932c7fc00c99d1fb30e25c66c2b..74566b6040adead57af3429d186a96fdf5a9a0e7 100644
--- a/chrome/browser/media/media_stream_infobar_delegate_android.cc
+++ b/chrome/browser/media/media_stream_infobar_delegate_android.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
+#include "components/content_settings/core/common/content_settings_types.h"
#include "components/google/core/browser/google_util.h"
#include "components/infobars/core/infobar.h"
#include "content/public/browser/web_contents.h"
@@ -32,6 +33,16 @@ enum DevicePermissionActions {
kPermissionActionsMax // Must always be last!
};
+std::vector<ContentSettingsType> GetContentSettingsTypes(
+ MediaStreamDevicesController* controller) {
+ std::vector<ContentSettingsType> types;
+ if (controller->IsAskingForAudio())
+ types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
+ if (controller->IsAskingForVideo())
+ types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
+ return types;
+}
+
} // namespace
MediaStreamInfoBarDelegateAndroid::~MediaStreamInfoBarDelegateAndroid() {}
@@ -50,8 +61,8 @@ bool MediaStreamInfoBarDelegateAndroid::Create(
}
std::unique_ptr<infobars::InfoBar> infobar(
- infobar_service->CreateConfirmInfoBar(
- std::unique_ptr<ConfirmInfoBarDelegate>(
+ GroupedPermissionInfoBarDelegate::CreateInfoBar(infobar_service,
+ std::unique_ptr<GroupedPermissionInfoBarDelegate>(
new MediaStreamInfoBarDelegateAndroid(std::move(controller)))));
for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
infobars::InfoBar* old_infobar = infobar_service->infobar_at(i);
@@ -64,14 +75,6 @@ bool MediaStreamInfoBarDelegateAndroid::Create(
return true;
}
-bool MediaStreamInfoBarDelegateAndroid::IsRequestingVideoAccess() const {
- return controller_->IsAskingForVideo();
-}
-
-bool MediaStreamInfoBarDelegateAndroid::IsRequestingMicrophoneAccess() const {
- return controller_->IsAskingForAudio();
-}
-
infobars::InfoBarDelegate::InfoBarIdentifier
MediaStreamInfoBarDelegateAndroid::GetIdentifier() const {
return MEDIA_STREAM_INFOBAR_DELEGATE_ANDROID;
@@ -79,21 +82,14 @@ MediaStreamInfoBarDelegateAndroid::GetIdentifier() const {
MediaStreamInfoBarDelegateAndroid::MediaStreamInfoBarDelegateAndroid(
std::unique_ptr<MediaStreamDevicesController> controller)
- : ConfirmInfoBarDelegate(), controller_(std::move(controller)) {
+ : GroupedPermissionInfoBarDelegate(
+ controller->GetOrigin(),
+ GetContentSettingsTypes(controller.get())),
+ controller_(std::move(controller)) {
DCHECK(controller_.get());
DCHECK(controller_->IsAskingForAudio() || controller_->IsAskingForVideo());
}
-infobars::InfoBarDelegate::Type
-MediaStreamInfoBarDelegateAndroid::GetInfoBarType() const {
- return PAGE_ACTION_TYPE;
-}
-
-int MediaStreamInfoBarDelegateAndroid::GetIconId() const {
- return controller_->IsAskingForVideo() ? IDR_INFOBAR_MEDIA_STREAM_CAMERA
- : IDR_INFOBAR_MEDIA_STREAM_MIC;
-}
-
void MediaStreamInfoBarDelegateAndroid::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.
@@ -107,23 +103,6 @@ MediaStreamInfoBarDelegateAndroid::AsMediaStreamInfoBarDelegateAndroid() {
return this;
}
-base::string16 MediaStreamInfoBarDelegateAndroid::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 MediaStreamInfoBarDelegateAndroid::GetButtonLabel(
- InfoBarButton button) const {
- return l10n_util::GetStringUTF16((button == BUTTON_OK)
- ? IDS_MEDIA_CAPTURE_ALLOW
- : IDS_MEDIA_CAPTURE_BLOCK);
-}
-
bool MediaStreamInfoBarDelegateAndroid::Accept() {
GURL origin(controller_->GetSecurityOriginSpec());
if (content::IsOriginSecure(origin)) {
@@ -143,11 +122,3 @@ bool MediaStreamInfoBarDelegateAndroid::Cancel() {
controller_->PermissionDenied();
return true;
}
-
-base::string16 MediaStreamInfoBarDelegateAndroid::GetLinkText() const {
- return base::string16();
-}
-
-GURL MediaStreamInfoBarDelegateAndroid::GetLinkURL() const {
- return GURL(chrome::kMediaAccessLearnMoreUrl);
-}

Powered by Google App Engine
This is Rietveld 408576698