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

Unified Diff: chrome/browser/permissions/grouped_permission_infobar_delegate.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: Rebase Created 4 years, 7 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/permissions/grouped_permission_infobar_delegate.cc
diff --git a/chrome/browser/permissions/grouped_permission_infobar_delegate.cc b/chrome/browser/permissions/grouped_permission_infobar_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6757f95ce698bdaf1a7a9782d1e05c43252b9b34
--- /dev/null
+++ b/chrome/browser/permissions/grouped_permission_infobar_delegate.cc
@@ -0,0 +1,70 @@
+// Copyright 2016 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/permissions/grouped_permission_infobar_delegate.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/url_formatter/elide_url.h"
+#include "grit/theme_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+
+GroupedPermissionInfoBarDelegate::GroupedPermissionInfoBarDelegate(
+ const GURL& requesting_origin,
+ const std::vector<ContentSettingsType>& types)
+ : requesting_origin_(requesting_origin), types_(types) {}
+
+GroupedPermissionInfoBarDelegate::~GroupedPermissionInfoBarDelegate() {}
+
+infobars::InfoBarDelegate::Type
+GroupedPermissionInfoBarDelegate::GetInfoBarType() const {
+ return PAGE_ACTION_TYPE;
+}
+
+base::string16 GroupedPermissionInfoBarDelegate::GetButtonLabel(
+ InfoBarButton button) const {
+ return l10n_util::GetStringUTF16(
+ (button == BUTTON_OK) ? IDS_PERMISSION_ALLOW : IDS_PERMISSION_DENY);
+}
+
+base::string16 GroupedPermissionInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringFUTF16(
+ IDS_PERMISSIONS_BUBBLE_PROMPT,
+ url_formatter::FormatUrlForSecurityDisplay(requesting_origin_));
+}
+
+int GroupedPermissionInfoBarDelegate::GetPermissionCount() const {
+ return types_.size();
+}
+
+ContentSettingsType GroupedPermissionInfoBarDelegate::GetContentSettingType(
+ int index) const {
+ DCHECK(index >= 0 && index < static_cast<int>(types_.size()));
+ return types_[index];
+}
+
+int GroupedPermissionInfoBarDelegate::GetIconIdForPermission(int index) const {
+ DCHECK(index >= 0 && index < static_cast<int>(types_.size()));
+ ContentSettingsType type = types_[index];
+ if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) {
+ return IDR_INFOBAR_MEDIA_STREAM_MIC;
+ } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) {
+ return IDR_INFOBAR_MEDIA_STREAM_CAMERA;
+ }
+ return IDR_INFOBAR_WARNING;
+}
+
+base::string16 GroupedPermissionInfoBarDelegate::GetMessageTextFragment(
+ int index) const {
+ DCHECK(index >= 0 && index < static_cast<int>(types_.size()));
+ ContentSettingsType type = types_[index];
+ int message_id;
+ if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) {
+ message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT;
+ } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) {
+ message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_FRAGMENT;
+ } else {
+ NOTREACHED();
+ return base::string16();
+ }
+ return l10n_util::GetStringUTF16(message_id);
+}
« no previous file with comments | « chrome/browser/permissions/grouped_permission_infobar_delegate.h ('k') | chrome/browser/ui/android/infobars/confirm_infobar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698