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

Side by Side 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: Fix compile failures Created 5 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_MANAGER_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_MANAGER_H_
7
8 #include "base/callback_forward.h"
9 #include "base/containers/scoped_ptr_hash_map.h"
10 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/permissions/permission_request_id.h"
12 #include "components/content_settings/core/common/content_settings.h"
13 #include "components/content_settings/core/common/content_settings_types.h"
14 #include "content/public/browser/web_contents_observer.h"
15 #include "content/public/browser/web_contents_user_data.h"
16
17 class GURL;
18 class PermissionInfoBarRequest;
19
20 // Manages permsision requests using InfoBars. Requests are coalesced by
21 // request_id. If multiple requests occur with overlapping permissions, both
22 // will be shown and the last to have a response will be persisted.
23 class PermissionInfoBarManager
24 : public content::WebContentsObserver,
25 public content::WebContentsUserData<PermissionInfoBarManager> {
26 public:
27 ~PermissionInfoBarManager() override;
28
29 // Queues an infobar request to be shown at some point. Requests with
30 // the same |request_id| are coalesced.
31 void CreateRequest(
32 const ContentSettingsType type,
33 const PermissionRequestID& request,
34 const GURL& requesting_origin,
35 const GURL& embedding_origin,
36 const base::Callback<void(bool, ContentSetting)>& callback);
37
38 // Cancels a specific infobar request.
39 void CancelRequest(const PermissionRequestID& request);
40
41 private:
42 friend class GeolocationPermissionContextTests;
43 friend class PermissionContextBaseTests;
44 friend class content::WebContentsUserData<PermissionInfoBarManager>;
45 using PermissionDecidedCallback = base::Callback<void(bool, ContentSetting)>;
46
47 explicit PermissionInfoBarManager(content::WebContents* web_contents);
48
49 // Posts a call to |ShowNextQueuedRequest| if there is no current request
50 // and |queued_requests_| is not empty.
51 void TriggerShowNextQueuedRequest();
52
53 // Shows the next request in |queued_requests_| if there is no current
54 // request and if |queued_requests_| is not empty
55 void ShowNextQueuedRequest();
56
57 // Callback function used when the infobar is dismissed, accepted or denied.
58 void OnInfoBarClosed();
59
60 // Removes the current request and shows a next queued request if available.
61 void ClearCurrentRequest();
62
63 // Returns whether the queue should be ignored when considering to show
64 // a new request.
65 bool ShouldIgnoreQueuedRequests();
66
67 // Pointer to the current request which is displayed to the user.
68 scoped_ptr<PermissionInfoBarRequest> current_request_;
69
70 // Indicates whether there is a currently pending call to
71 // |ShowNextQueuedRequest| in the UI thread even loop.
72 bool is_show_pending_;
73
74 // The mapping of request_id to queued requests. Note that |current_request_|
75 // will not be present in this map.
76 base::ScopedPtrHashMap<int,
77 scoped_ptr<PermissionInfoBarRequest>> queued_requests_;
78
79 base::WeakPtrFactory<PermissionInfoBarManager> weak_factory_;
80
81 DISALLOW_COPY_AND_ASSIGN(PermissionInfoBarManager);
82 };
83
84 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698