| 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_CONTENT_SETTINGS_PERMISSION_QUEUE_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_QUEUE_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_QUEUE_CONTROLLER_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_QUEUE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "components/content_settings/core/common/content_settings.h" |
| 9 #include "components/content_settings/core/common/content_settings_types.h" | 10 #include "components/content_settings/core/common/content_settings_types.h" |
| 10 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
| 11 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
| 12 | 13 |
| 13 class GURL; | 14 class GURL; |
| 14 class PermissionRequestID; | 15 class PermissionRequestID; |
| 15 class InfoBarService; | 16 class InfoBarService; |
| 16 class Profile; | 17 class Profile; |
| 17 | 18 |
| 18 // This class controls an infobar queue per profile, and it's used by | 19 // This class controls an infobar queue per profile, and it's used by |
| 19 // GeolocationPermissionContext, and so on. | 20 // GeolocationPermissionContext, and so on. |
| 20 // An alternate approach would be to have this queue per tab, and use | 21 // An alternate approach would be to have this queue per tab, and use |
| 21 // notifications to broadcast when permission is set / listen to notification to | 22 // notifications to broadcast when permission is set / listen to notification to |
| 22 // cancel pending requests. This may be specially useful if there are other | 23 // cancel pending requests. This may be specially useful if there are other |
| 23 // things listening for such notifications. | 24 // things listening for such notifications. |
| 24 // For the time being this class is self-contained and it doesn't seem pulling | 25 // For the time being this class is self-contained and it doesn't seem pulling |
| 25 // the notification infrastructure would simplify. | 26 // the notification infrastructure would simplify. |
| 26 class PermissionQueueController : public content::NotificationObserver { | 27 class PermissionQueueController : public content::NotificationObserver { |
| 27 public: | 28 public: |
| 28 typedef base::Callback<void(bool /* allowed */)> PermissionDecidedCallback; | 29 using PermissionDecidedCallback = base::Callback<void(ContentSetting)>; |
| 29 | 30 |
| 30 PermissionQueueController(Profile* profile, ContentSettingsType type); | 31 PermissionQueueController(Profile* profile, ContentSettingsType type); |
| 31 ~PermissionQueueController() override; | 32 ~PermissionQueueController() override; |
| 32 | 33 |
| 33 // The InfoBar will be displayed immediately if the tab is not already | 34 // The InfoBar will be displayed immediately if the tab is not already |
| 34 // displaying one, otherwise it'll be queued. | 35 // displaying one, otherwise it'll be queued. |
| 35 void CreateInfoBarRequest(const PermissionRequestID& id, | 36 void CreateInfoBarRequest(const PermissionRequestID& id, |
| 36 const GURL& requesting_frame, | 37 const GURL& requesting_frame, |
| 37 const GURL& embedder, | 38 const GURL& embedder, |
| 38 PermissionDecidedCallback callback); | 39 PermissionDecidedCallback callback); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 87 |
| 87 Profile* const profile_; | 88 Profile* const profile_; |
| 88 ContentSettingsType type_; | 89 ContentSettingsType type_; |
| 89 PendingInfobarRequests pending_infobar_requests_; | 90 PendingInfobarRequests pending_infobar_requests_; |
| 90 bool in_shutdown_; | 91 bool in_shutdown_; |
| 91 | 92 |
| 92 DISALLOW_COPY_AND_ASSIGN(PermissionQueueController); | 93 DISALLOW_COPY_AND_ASSIGN(PermissionQueueController); |
| 93 }; | 94 }; |
| 94 | 95 |
| 95 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_QUEUE_CONTROLLER_H_ | 96 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_QUEUE_CONTROLLER_H_ |
| OLD | NEW |