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

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

Issue 2339863002: Use vector of PermissionRequest instead of ContentSettingsTypes for GroupedPermissionInfoBarDelegate (Closed)
Patch Set: Merge branch 'undo_media_infobar_delegate' into use_array_of_PR_for_GPID Created 4 years, 3 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
« no previous file with comments | « chrome/browser/permissions/grouped_permission_infobar_delegate.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6ea8084bb31673e93eb5b64aec9129488334cd86..6666c5fc6bb9712e6c62a159246f9db3bb6a7de3 100644
--- a/chrome/browser/permissions/grouped_permission_infobar_delegate.cc
+++ b/chrome/browser/permissions/grouped_permission_infobar_delegate.cc
@@ -2,19 +2,50 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/media/webrtc/media_stream_devices_controller.h"
tsergeant 2016/09/22 06:53:56 Is this include necessary?
lshang 2016/09/27 07:21:52 Removed.
#include "chrome/browser/permissions/grouped_permission_infobar_delegate.h"
+#include "chrome/browser/permissions/permission_request.h"
#include "chrome/browser/permissions/permission_util.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
#include "components/url_formatter/elide_url.h"
#include "ui/base/l10n/l10n_util.h"
+namespace {
+
+ContentSettingsType PermissionRequestTypeToContentType(
tsergeant 2016/09/22 06:53:56 I think it would be good to avoid adding this conv
lshang 2016/09/27 07:21:52 I moved this conversion to PermissionRequest, but
+ PermissionRequestType request_type) {
+ ContentSettingsType type = CONTENT_SETTINGS_TYPE_DEFAULT;
+ switch (request_type) {
+ case PermissionRequestType::PERMISSION_GEOLOCATION:
+ type = CONTENT_SETTINGS_TYPE_GEOLOCATION;
+ break;
+ case PermissionRequestType::PERMISSION_NOTIFICATIONS:
+ type = CONTENT_SETTINGS_TYPE_NOTIFICATIONS;
+ break;
+ case PermissionRequestType::PERMISSION_MIDI_SYSEX:
+ type = CONTENT_SETTINGS_TYPE_MIDI_SYSEX;
+ break;
+ case PermissionRequestType::PERMISSION_PUSH_MESSAGING:
+ type = CONTENT_SETTINGS_TYPE_NOTIFICATIONS;
+ break;
+ case PermissionRequestType::PERMISSION_PROTECTED_MEDIA_IDENTIFIER:
+ type = CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER;
+ break;
+ default:
+ NOTREACHED();
+ }
+ return type;
+}
+
+} // namespace
+
GroupedPermissionInfoBarDelegate::GroupedPermissionInfoBarDelegate(
const GURL& requesting_origin,
- const std::vector<ContentSettingsType>& types)
+ const std::vector<PermissionRequest*>& requests)
: requesting_origin_(requesting_origin),
- types_(types),
- accept_states_(types_.size(), true),
+ requests_(requests),
+ accept_states_(requests_.size(), true),
persist_(true) {}
GroupedPermissionInfoBarDelegate::~GroupedPermissionInfoBarDelegate() {}
@@ -52,49 +83,34 @@ base::string16 GroupedPermissionInfoBarDelegate::GetMessageText() const {
}
int GroupedPermissionInfoBarDelegate::GetPermissionCount() const {
- return types_.size();
+ return requests_.size();
}
ContentSettingsType GroupedPermissionInfoBarDelegate::GetContentSettingType(
int index) const {
- DCHECK(index >= 0 && index < static_cast<int>(types_.size()));
- return types_[index];
+ DCHECK(index >= 0 && index < static_cast<int>(requests_.size()));
+ return PermissionRequestTypeToContentType(
tsergeant 2016/09/22 06:53:56 The way that this method was written doesn't neces
lshang 2016/09/27 07:21:52 I think this CL is not ready for adding support fo
tsergeant 2016/09/28 00:01:06 Yeah, you're right -- there are complications in t
+ requests_[index]->GetPermissionRequestType());
}
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;
+ DCHECK(index >= 0 && index < static_cast<int>(requests_.size()));
+ return requests_[index]->GetIconId();
}
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);
+ DCHECK(index >= 0 && index < static_cast<int>(requests_.size()));
+ return requests_[index]->GetMessageTextFragment();
}
void GroupedPermissionInfoBarDelegate::ToggleAccept(int position,
bool new_value) {
- DCHECK(position >= 0 && position < static_cast<int>(types_.size()));
+ DCHECK(position >= 0 && position < static_cast<int>(requests_.size()));
accept_states_[position] = new_value;
}
bool GroupedPermissionInfoBarDelegate::GetAcceptState(int position) {
- DCHECK(position >= 0 && position < static_cast<int>(types_.size()));
+ DCHECK(position >= 0 && position < static_cast<int>(requests_.size()));
return accept_states_[position];
}
« no previous file with comments | « chrome/browser/permissions/grouped_permission_infobar_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698