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..f02ad991b4ed1f3b537b81d8fe33f92ef73079a6 100644 |
--- a/chrome/browser/permissions/permission_infobar_delegate.cc |
+++ b/chrome/browser/permissions/permission_infobar_delegate.cc |
@@ -4,13 +4,57 @@ |
#include "chrome/browser/permissions/permission_infobar_delegate.h" |
-#include "chrome/browser/permissions/permission_decision_auto_blocker.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_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,22 +65,6 @@ PermissionInfoBarDelegate::~PermissionInfoBarDelegate() { |
} |
} |
-PermissionInfoBarDelegate::PermissionInfoBarDelegate( |
- const GURL& requesting_origin, |
- content::PermissionType permission_type, |
- ContentSettingsType content_settings_type, |
- bool user_gesture, |
- Profile* profile, |
- const PermissionSetCallback& callback) |
- : requesting_origin_(requesting_origin), |
- permission_type_(permission_type), |
- content_settings_type_(content_settings_type), |
- profile_(profile), |
- callback_(callback), |
- action_taken_(false), |
- user_gesture_(user_gesture), |
- persist_(true) {} |
- |
std::vector<int> PermissionInfoBarDelegate::content_settings() const { |
return std::vector<int>{content_settings_type_}; |
} |
@@ -56,6 +84,22 @@ base::string16 PermissionInfoBarDelegate::GetMessageText() const { |
url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); |
} |
+PermissionInfoBarDelegate::PermissionInfoBarDelegate( |
+ const GURL& requesting_origin, |
+ content::PermissionType permission_type, |
+ ContentSettingsType content_settings_type, |
+ bool user_gesture, |
+ Profile* profile, |
+ const PermissionSetCallback& callback) |
+ : requesting_origin_(requesting_origin), |
+ permission_type_(permission_type), |
+ content_settings_type_(content_settings_type), |
+ profile_(profile), |
+ callback_(callback), |
+ action_taken_(false), |
+ user_gesture_(user_gesture), |
+ persist_(true) {} |
+ |
infobars::InfoBarDelegate::Type PermissionInfoBarDelegate::GetInfoBarType() |
const { |
return PAGE_ACTION_TYPE; |