Index: chrome/browser/permissions/permission_infobar_manager.h |
diff --git a/chrome/browser/permissions/permission_infobar_manager.h b/chrome/browser/permissions/permission_infobar_manager.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c7bdbea9f5d0d08135d0e23222de1e6c9dbd92b5 |
--- /dev/null |
+++ b/chrome/browser/permissions/permission_infobar_manager.h |
@@ -0,0 +1,68 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_MANAGER_H_ |
+#define CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_MANAGER_H_ |
+ |
+#include "base/callback_forward.h" |
+#include "base/containers/scoped_ptr_hash_map.h" |
+#include "base/memory/weak_ptr.h" |
+#include "chrome/browser/permissions/permission_request_id.h" |
+#include "components/content_settings/core/common/content_settings.h" |
+#include "components/content_settings/core/common/content_settings_types.h" |
+#include "content/public/browser/web_contents_observer.h" |
+#include "content/public/browser/web_contents_user_data.h" |
+ |
+class GURL; |
+class PermissionInfoBarRequest; |
+ |
+// Manages permsision requests using InfoBars. Requests are coalesced by |
+// request_id. If multiple requests occur with overlapping permissions, both |
+// will be shown and the last to have a response will be persisted. |
+class PermissionInfoBarManager |
+ : public content::WebContentsObserver, |
+ public content::WebContentsUserData<PermissionInfoBarManager> { |
+ public: |
+ ~PermissionInfoBarManager() override; |
+ |
+ // Queues an infobar request to be shown at some point. Requests with |
+ // the same |request_id| are coalesced. |
+ void CreateInfoBarRequest( |
+ const ContentSettingsType type, |
+ const PermissionRequestID& request, |
+ const GURL& requesting_frame, |
+ const GURL& embedder, |
+ const base::Callback<void(bool, ContentSetting)>& user_callback, |
+ const base::Callback<void(bool, ContentSetting)>& non_user_callback); |
mlamouri (slow - plz ping)
2015/09/16 16:21:01
Why having these two callbacks? It makes things a
Lalit Maganti
2015/09/16 17:28:38
It's necessary to correctly bypass the UMA and con
|
+ |
+ // Cancels a specific infobar request. |
+ void CancelInfoBarRequest(const PermissionRequestID& request); |
+ |
+ private: |
+ friend class content::WebContentsUserData<PermissionInfoBarManager>; |
+ using PermissionDecidedCallback = base::Callback<void(bool, ContentSetting)>; |
+ |
+ explicit PermissionInfoBarManager(content::WebContents* web_contents); |
+ |
+ void TriggerShowQueuedInfoBars(); |
+ void ShowQueuedInfoBars(); |
+ void OnInfoBarRequestCompleted(); |
+ |
+ void ClearCurrentRequest(); |
+ bool ShouldIgnoreQueuedRequests(); |
+ |
+ scoped_ptr<PermissionInfoBarRequest> current_request_; |
+ int current_request_id_; |
+ |
+ bool is_show_queued_pending_; |
+ |
+ base::ScopedPtrHashMap<int, |
+ scoped_ptr<PermissionInfoBarRequest>> queued_requests_; |
+ |
+ base::WeakPtrFactory<PermissionInfoBarManager> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PermissionInfoBarManager); |
+}; |
+ |
+#endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_MANAGER_H_ |