| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/permissions/grouped_permission_infobar_delegate_android
.h" | 5 #include "chrome/browser/permissions/grouped_permission_infobar_delegate_android
.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/infobars/infobar_service.h" | 8 #include "chrome/browser/infobars/infobar_service.h" |
| 9 #include "chrome/browser/permissions/permission_util.h" | 9 #include "chrome/browser/permissions/permission_util.h" |
| 10 #include "chrome/browser/ui/android/infobars/grouped_permission_infobar.h" | 10 #include "chrome/browser/ui/android/infobars/grouped_permission_infobar.h" |
| 11 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
| 12 #include "chrome/grit/theme_resources.h" | 12 #include "chrome/grit/theme_resources.h" |
| 13 #include "components/infobars/core/infobar.h" | 13 #include "components/infobars/core/infobar.h" |
| 14 #include "components/url_formatter/elide_url.h" | 14 #include "components/url_formatter/elide_url.h" |
| 15 #include "content/public/browser/permission_type.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/strings/grit/ui_strings.h" | 17 #include "ui/strings/grit/ui_strings.h" |
| 17 | 18 |
| 18 GroupedPermissionInfoBarDelegate::~GroupedPermissionInfoBarDelegate() {} | 19 GroupedPermissionInfoBarDelegate::~GroupedPermissionInfoBarDelegate() {} |
| 19 | 20 |
| 20 // static | 21 // static |
| 21 infobars::InfoBar* GroupedPermissionInfoBarDelegate::Create( | 22 infobars::InfoBar* GroupedPermissionInfoBarDelegate::Create( |
| 22 InfoBarService* infobar_service, | 23 InfoBarService* infobar_service, |
| 23 const GURL& requesting_origin, | 24 const GURL& requesting_origin, |
| 24 const std::vector<ContentSettingsType>& types) { | 25 const std::vector<ContentSettingsType>& types) { |
| 25 return infobar_service->AddInfoBar( | 26 return infobar_service->AddInfoBar( |
| 26 base::MakeUnique<GroupedPermissionInfoBar>(base::WrapUnique( | 27 base::MakeUnique<GroupedPermissionInfoBar>(base::WrapUnique( |
| 27 new GroupedPermissionInfoBarDelegate(requesting_origin, types)))); | 28 new GroupedPermissionInfoBarDelegate(requesting_origin, types)))); |
| 28 } | 29 } |
| 29 | 30 |
| 30 bool GroupedPermissionInfoBarDelegate::ShouldShowPersistenceToggle() const { | 31 bool GroupedPermissionInfoBarDelegate::ShouldShowPersistenceToggle() const { |
| 31 return PermissionUtil::ShouldShowPersistenceToggle(); | 32 return PermissionUtil::ShouldShowPersistenceToggle(); |
| 32 } | 33 } |
| 33 | 34 |
| 34 ContentSettingsType GroupedPermissionInfoBarDelegate::GetContentSettingType( | 35 content::PermissionType GroupedPermissionInfoBarDelegate::GetPermissionType( |
| 35 size_t position) const { | 36 size_t position) const { |
| 36 DCHECK_LT(position, types_.size()); | 37 DCHECK_LT(position, types_.size()); |
| 37 return types_[position]; | 38 ContentSettingsType type = types_[position]; |
| 39 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) |
| 40 return content::PermissionType::AUDIO_CAPTURE; |
| 41 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) |
| 42 return content::PermissionType::VIDEO_CAPTURE; |
| 43 |
| 44 NOTREACHED(); |
| 45 return content::PermissionType::NUM; |
| 38 } | 46 } |
| 39 | 47 |
| 40 int GroupedPermissionInfoBarDelegate::GetIconIdForPermission( | 48 int GroupedPermissionInfoBarDelegate::GetIconIdForPermission( |
| 41 size_t position) const { | 49 size_t position) const { |
| 42 DCHECK_LT(position, types_.size()); | 50 DCHECK_LT(position, types_.size()); |
| 43 ContentSettingsType type = types_[position]; | 51 ContentSettingsType type = types_[position]; |
| 44 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) | 52 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) |
| 45 return IDR_INFOBAR_MEDIA_STREAM_MIC; | 53 return IDR_INFOBAR_MEDIA_STREAM_MIC; |
| 46 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) | 54 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) |
| 47 return IDR_INFOBAR_MEDIA_STREAM_CAMERA; | 55 return IDR_INFOBAR_MEDIA_STREAM_CAMERA; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 base::string16 GroupedPermissionInfoBarDelegate::GetButtonLabel( | 115 base::string16 GroupedPermissionInfoBarDelegate::GetButtonLabel( |
| 108 InfoBarButton button) const { | 116 InfoBarButton button) const { |
| 109 if (permission_count() > 1) { | 117 if (permission_count() > 1) { |
| 110 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_APP_OK | 118 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_APP_OK |
| 111 : IDS_APP_CANCEL); | 119 : IDS_APP_CANCEL); |
| 112 } | 120 } |
| 113 | 121 |
| 114 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_PERMISSION_ALLOW | 122 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_PERMISSION_ALLOW |
| 115 : IDS_PERMISSION_DENY); | 123 : IDS_PERMISSION_DENY); |
| 116 } | 124 } |
| OLD | NEW |