Chromium Code Reviews| Index: chrome/browser/permissions/permission_infobar_delegate.cc |
| diff --git a/chrome/browser/permissions/permission_infobar_delegate.cc b/chrome/browser/permissions/permission_infobar_delegate.cc |
| index 497ed8579ed992dfe6b6ba1a2db5db2fd8ae080f..90bb20bf4089908b32410304e0f28a40f4b69aff 100644 |
| --- a/chrome/browser/permissions/permission_infobar_delegate.cc |
| +++ b/chrome/browser/permissions/permission_infobar_delegate.cc |
| @@ -4,13 +4,58 @@ |
| #include "chrome/browser/permissions/permission_infobar_delegate.h" |
| +#include "build/build_config.h" |
| +#include "chrome/browser/geolocation/geolocation_infobar_delegate_android.h" |
| +#include "chrome/browser/infobars/infobar_service.h" |
| +#include "chrome/browser/media/midi_permission_infobar_delegate_android.h" |
| +#include "chrome/browser/media/protected_media_identifier_infobar_delegate_android.h" |
| +#include "chrome/browser/notifications/notification_permission_infobar_delegate.h" |
| #include "chrome/browser/permissions/permission_decision_auto_blocker.h" |
| #include "chrome/browser/permissions/permission_request.h" |
| #include "chrome/browser/permissions/permission_uma_util.h" |
| #include "chrome/grit/generated_resources.h" |
| +#include "components/infobars/core/infobar.h" |
| #include "components/url_formatter/elide_url.h" |
| #include "ui/base/l10n/l10n_util.h" |
| +// static |
| +infobars::InfoBar* PermissionInfoBarDelegate::Create( |
| + content::PermissionType type, |
| + InfoBarService* infobar_service, |
| + const GURL& requesting_frame, |
| + bool user_gesture, |
| + Profile* profile, |
| + const PermissionSetCallback& callback) { |
| + switch (type) { |
| + case content::PermissionType::GEOLOCATION: |
| + return infobar_service->AddInfoBar( |
| + CreatePermissionInfoBar(std::unique_ptr<PermissionInfoBarDelegate>( |
| + new GeolocationInfoBarDelegateAndroid( |
| + requesting_frame, user_gesture, profile, callback)))); |
| +#if defined(ENABLE_NOTIFICATIONS) |
| + case content::PermissionType::NOTIFICATIONS: |
| + case content::PermissionType::PUSH_MESSAGING: |
| + return infobar_service->AddInfoBar( |
| + CreatePermissionInfoBar(std::unique_ptr<PermissionInfoBarDelegate>( |
| + new NotificationPermissionInfoBarDelegate( |
| + requesting_frame, user_gesture, profile, callback)))); |
| +#endif // ENABLE_NOTIFICATIONS |
| + case content::PermissionType::MIDI_SYSEX: |
| + return infobar_service->AddInfoBar( |
| + CreatePermissionInfoBar(std::unique_ptr<PermissionInfoBarDelegate>( |
| + new MidiPermissionInfoBarDelegateAndroid( |
| + requesting_frame, user_gesture, profile, callback)))); |
| + case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: |
| + return infobar_service->AddInfoBar( |
| + CreatePermissionInfoBar(std::unique_ptr<PermissionInfoBarDelegate>( |
| + new ProtectedMediaIdentifierInfoBarDelegateAndroid( |
| + requesting_frame, user_gesture, profile, callback)))); |
| + default: |
| + NOTREACHED(); |
| + return nullptr; |
| + } |
| +} |
| + |
| PermissionInfoBarDelegate::~PermissionInfoBarDelegate() { |
| if (!action_taken_) { |
| PermissionUmaUtil::PermissionIgnored( |
| @@ -21,6 +66,17 @@ PermissionInfoBarDelegate::~PermissionInfoBarDelegate() { |
| } |
| } |
| +std::vector<int> PermissionInfoBarDelegate::content_settings() const { |
| + return std::vector<int>{content_settings_type_}; |
| +} |
| + |
| +bool PermissionInfoBarDelegate::ShouldShowPersistenceToggle() const { |
| + return (permission_type_ == content::PermissionType::GEOLOCATION || |
| + permission_type_ == content::PermissionType::AUDIO_CAPTURE || |
| + permission_type_ == content::PermissionType::VIDEO_CAPTURE) && |
| + PermissionUtil::ShouldShowPersistenceToggle(); |
| +} |
|
lshang
2016/10/24 07:10:55
Since you're here, could you also move the method
dominickn
2016/10/24 08:32:53
Done.
|
| + |
| PermissionInfoBarDelegate::PermissionInfoBarDelegate( |
| const GURL& requesting_origin, |
| content::PermissionType permission_type, |
| @@ -37,17 +93,6 @@ PermissionInfoBarDelegate::PermissionInfoBarDelegate( |
| user_gesture_(user_gesture), |
| persist_(true) {} |
| -std::vector<int> PermissionInfoBarDelegate::content_settings() const { |
| - return std::vector<int>{content_settings_type_}; |
| -} |
| - |
| -bool PermissionInfoBarDelegate::ShouldShowPersistenceToggle() const { |
| - return (permission_type_ == content::PermissionType::GEOLOCATION || |
| - permission_type_ == content::PermissionType::AUDIO_CAPTURE || |
| - permission_type_ == content::PermissionType::VIDEO_CAPTURE) && |
| - PermissionUtil::ShouldShowPersistenceToggle(); |
| -} |
| - |
| base::string16 PermissionInfoBarDelegate::GetMessageText() const { |
| return l10n_util::GetStringFUTF16( |
| GetMessageResourceId(), |