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

Unified Diff: chrome/browser/permissions/grouped_permission_infobar_delegate.cc

Issue 2019573002: Permissions: Allow control of individual requests in media permission infobars (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bracket nit Created 4 years, 6 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
index 6757f95ce698bdaf1a7a9782d1e05c43252b9b34..46795c43fa3350fc94c9536e35f385514b60bdf6 100644
--- a/chrome/browser/permissions/grouped_permission_infobar_delegate.cc
+++ b/chrome/browser/permissions/grouped_permission_infobar_delegate.cc
@@ -11,7 +11,9 @@
GroupedPermissionInfoBarDelegate::GroupedPermissionInfoBarDelegate(
const GURL& requesting_origin,
const std::vector<ContentSettingsType>& types)
- : requesting_origin_(requesting_origin), types_(types) {}
+ : requesting_origin_(requesting_origin),
+ types_(types),
+ accept_states_(types_.size(), true) {}
GroupedPermissionInfoBarDelegate::~GroupedPermissionInfoBarDelegate() {}
@@ -20,10 +22,21 @@ GroupedPermissionInfoBarDelegate::GetInfoBarType() const {
return PAGE_ACTION_TYPE;
}
+int GroupedPermissionInfoBarDelegate::GetButtons() const {
+ if (GetPermissionCount() >= 2)
+ return ConfirmInfoBarDelegate::InfoBarButton::BUTTON_OK;
+ else
+ return ConfirmInfoBarDelegate::GetButtons();
+}
+
base::string16 GroupedPermissionInfoBarDelegate::GetButtonLabel(
InfoBarButton button) const {
- return l10n_util::GetStringUTF16(
- (button == BUTTON_OK) ? IDS_PERMISSION_ALLOW : IDS_PERMISSION_DENY);
+ if (GetPermissionCount() >= 2) {
+ return ConfirmInfoBarDelegate::GetButtonLabel(button);
+ } else {
+ return l10n_util::GetStringUTF16(
+ (button == BUTTON_OK) ? IDS_PERMISSION_ALLOW : IDS_PERMISSION_DENY);
+ }
}
base::string16 GroupedPermissionInfoBarDelegate::GetMessageText() const {
@@ -68,3 +81,14 @@ base::string16 GroupedPermissionInfoBarDelegate::GetMessageTextFragment(
}
return l10n_util::GetStringUTF16(message_id);
}
+
+void GroupedPermissionInfoBarDelegate::ToggleAccept(int position,
+ bool new_value) {
+ DCHECK(position >= 0 && position < static_cast<int>(types_.size()));
+ accept_states_[position] = new_value;
+}
+
+bool GroupedPermissionInfoBarDelegate::GetAcceptState(int position) {
+ DCHECK(position >= 0 && position < static_cast<int>(types_.size()));
+ return accept_states_[position];
+}

Powered by Google App Engine
This is Rietveld 408576698