| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_QUEUE_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_QUEUE_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_QUEUE_CONTROLLER_H_ | 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_QUEUE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "chrome/browser/permissions/permission_util.h" | 10 #include "chrome/browser/permissions/permission_util.h" |
| 11 #include "components/content_settings/core/common/content_settings.h" | 11 #include "components/content_settings/core/common/content_settings.h" |
| 12 #include "components/content_settings/core/common/content_settings_types.h" | 12 #include "components/content_settings/core/common/content_settings_types.h" |
| 13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "content/public/browser/permission_type.h" | |
| 16 | 15 |
| 17 class GURL; | 16 class GURL; |
| 18 class PermissionRequestID; | 17 class PermissionRequestID; |
| 19 class InfoBarService; | 18 class InfoBarService; |
| 20 class Profile; | 19 class Profile; |
| 21 | 20 |
| 22 // This class controls an infobar queue per profile, and it's used by | 21 // This class controls an infobar queue per profile, and it's used by |
| 23 // GeolocationPermissionContext, and so on. It is only used on Android. | 22 // GeolocationPermissionContext, and so on. It is only used on Android. |
| 24 // An alternate approach would be to have this queue per tab, and use | 23 // An alternate approach would be to have this queue per tab, and use |
| 25 // notifications to broadcast when permission is set / listen to notification to | 24 // notifications to broadcast when permission is set / listen to notification to |
| 26 // cancel pending requests. This may be specially useful if there are other | 25 // cancel pending requests. This may be specially useful if there are other |
| 27 // things listening for such notifications. | 26 // things listening for such notifications. |
| 28 // For the time being this class is self-contained and it doesn't seem pulling | 27 // For the time being this class is self-contained and it doesn't seem pulling |
| 29 // the notification infrastructure would simplify. | 28 // the notification infrastructure would simplify. |
| 30 class PermissionQueueController : public content::NotificationObserver { | 29 class PermissionQueueController : public content::NotificationObserver { |
| 31 public: | 30 public: |
| 32 using PermissionDecidedCallback = base::Callback<void(ContentSetting)>; | 31 using PermissionDecidedCallback = base::Callback<void(ContentSetting)>; |
| 33 | 32 |
| 34 PermissionQueueController(Profile* profile, | 33 PermissionQueueController(Profile* profile, |
| 35 content::PermissionType permission_type, | |
| 36 ContentSettingsType content_settings_type); | 34 ContentSettingsType content_settings_type); |
| 37 ~PermissionQueueController() override; | 35 ~PermissionQueueController() override; |
| 38 | 36 |
| 39 // The InfoBar will be displayed immediately if the tab is not already | 37 // The InfoBar will be displayed immediately if the tab is not already |
| 40 // displaying one, otherwise it'll be queued. | 38 // displaying one, otherwise it'll be queued. |
| 41 void CreateInfoBarRequest(const PermissionRequestID& id, | 39 void CreateInfoBarRequest(const PermissionRequestID& id, |
| 42 const GURL& requesting_frame, | 40 const GURL& requesting_frame, |
| 43 const GURL& embedder, | 41 const GURL& embedder, |
| 44 bool user_gesture, | 42 bool user_gesture, |
| 45 const PermissionDecidedCallback& callback); | 43 const PermissionDecidedCallback& callback); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 void ShowQueuedInfoBarForTab(const PermissionRequestID& id); | 85 void ShowQueuedInfoBarForTab(const PermissionRequestID& id); |
| 88 | 86 |
| 89 void ClearPendingInfobarRequestsForTab(const PermissionRequestID& id); | 87 void ClearPendingInfobarRequestsForTab(const PermissionRequestID& id); |
| 90 | 88 |
| 91 void RegisterForInfoBarNotifications(InfoBarService* infobar_service); | 89 void RegisterForInfoBarNotifications(InfoBarService* infobar_service); |
| 92 void UnregisterForInfoBarNotifications(InfoBarService* infobar_service); | 90 void UnregisterForInfoBarNotifications(InfoBarService* infobar_service); |
| 93 | 91 |
| 94 content::NotificationRegistrar registrar_; | 92 content::NotificationRegistrar registrar_; |
| 95 | 93 |
| 96 Profile* const profile_; | 94 Profile* const profile_; |
| 97 content::PermissionType permission_type_; | |
| 98 ContentSettingsType content_settings_type_; | 95 ContentSettingsType content_settings_type_; |
| 99 PendingInfobarRequests pending_infobar_requests_; | 96 PendingInfobarRequests pending_infobar_requests_; |
| 100 bool in_shutdown_; | 97 bool in_shutdown_; |
| 101 | 98 |
| 102 DISALLOW_COPY_AND_ASSIGN(PermissionQueueController); | 99 DISALLOW_COPY_AND_ASSIGN(PermissionQueueController); |
| 103 }; | 100 }; |
| 104 | 101 |
| 105 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_QUEUE_CONTROLLER_H_ | 102 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_QUEUE_CONTROLLER_H_ |
| OLD | NEW |