Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2502)

Unified Diff: chrome/browser/permissions/permission_infobar_manager.h

Issue 1337903002: permissions: remove PermissionQueueController and introduce PermissionInfoBarManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@callbacks-delegates
Patch Set: Just a rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b4b497b6c988c9bf1cc3683a6fdfbf848fccc6e8
--- /dev/null
+++ b/chrome/browser/permissions/permission_infobar_manager.h
@@ -0,0 +1,69 @@
+// 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(
mlamouri (slow - plz ping) 2015/09/28 13:30:15 nit: CreateRequest()
Lalit Maganti 2015/09/28 15:32:38 Done.
+ const ContentSettingsType type,
+ const PermissionRequestID& request,
+ const GURL& requesting_frame,
mlamouri (slow - plz ping) 2015/09/28 13:30:15 nit: requesting_origin
Lalit Maganti 2015/09/28 15:32:38 Done.
+ const GURL& embedder,
mlamouri (slow - plz ping) 2015/09/28 13:30:15 nit: embedding_origin
Lalit Maganti 2015/09/28 15:32:38 Done.
+ const base::Callback<void(bool, ContentSetting)>& user_callback,
+ const base::Callback<void(bool, ContentSetting)>& non_user_callback);
+
+ // Cancels a specific infobar request.
+ void CancelInfoBarRequest(const PermissionRequestID& request);
mlamouri (slow - plz ping) 2015/09/28 13:30:15 nit: CancelRequest()
Lalit Maganti 2015/09/28 15:32:38 Done.
+
+ private:
+ friend class PermissionContextBaseTests;
+ friend class content::WebContentsUserData<PermissionInfoBarManager>;
+ using PermissionDecidedCallback = base::Callback<void(bool, ContentSetting)>;
+
+ explicit PermissionInfoBarManager(content::WebContents* web_contents);
+
+ void TriggerShowNextQueuedRequest();
+ void ShowNextQueuedRequest();
+ void OnInfoBarClosed(bool cancelled);
+
+ void ClearCurrentRequest();
+ bool ShouldIgnoreQueuedRequests();
+
+ scoped_ptr<PermissionInfoBarRequest> current_request_;
+ int current_request_id_;
+
+ bool is_show_queued_pending_;
mlamouri (slow - plz ping) 2015/09/28 13:30:15 I can't understand what you mean. Is this member c
Lalit Maganti 2015/09/28 15:32:38 It means whether ShowNextQueuedRequest has been pl
+
+ 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_

Powered by Google App Engine
This is Rietveld 408576698