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..fd3a908915c25cef9bea3f32845e9890765b0798 |
--- /dev/null |
+++ b/chrome/browser/permissions/permission_infobar_manager.h |
@@ -0,0 +1,71 @@ |
+// 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 CreateRequest( |
+ const ContentSettingsType type, |
+ const PermissionRequestID& request, |
+ const GURL& requesting_origin, |
+ const GURL& embedding_origin, |
+ const base::Callback<void(bool, ContentSetting)>& response_callback); |
+ |
+ // Cancels a specific infobar request. |
+ void CancelInfoBarRequest(const PermissionRequestID& request); |
mlamouri (slow - plz ping)
2015/09/29 14:02:18
Hmm, CancelRequest().
Lalit Maganti
2015/10/01 17:05:13
Done.
|
+ |
+ private: |
+ friend class PermissionContextBaseTests; |
+ friend class content::WebContentsUserData<PermissionInfoBarManager>; |
+ using PermissionDecidedCallback = base::Callback<void(bool, ContentSetting)>; |
+ |
+ explicit PermissionInfoBarManager(content::WebContents* web_contents); |
+ |
+ void Accept(); |
+ void Closing(); |
mlamouri (slow - plz ping)
2015/09/29 14:02:18
Add comments.
Lalit Maganti
2015/10/01 17:05:14
Done.
|
+ |
+ void TriggerShowNextQueuedRequest(); |
+ void ShowNextQueuedRequest(); |
+ void OnInfoBarClosed(); |
mlamouri (slow - plz ping)
2015/09/29 14:02:18
ditto
Lalit Maganti
2015/10/01 17:05:14
Done.
|
+ |
+ void ClearCurrentRequest(); |
+ bool ShouldIgnoreQueuedRequests(); |
mlamouri (slow - plz ping)
2015/09/29 14:02:18
ditto
Lalit Maganti
2015/10/01 17:05:14
Done.
|
+ |
+ scoped_ptr<PermissionInfoBarRequest> current_request_; |
+ int current_request_id_; |
mlamouri (slow - plz ping)
2015/09/29 14:02:18
Why can't you do:
current_request_->request_id?
Lalit Maganti
2015/10/01 17:05:14
Done.
|
+ |
+ bool is_show_queued_pending_; |
mlamouri (slow - plz ping)
2015/09/29 14:02:18
I think my confusion is that "queued" and "pending
Lalit Maganti
2015/10/01 17:05:14
Done.
|
+ |
+ 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_ |