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

Side by Side Diff: chrome/browser/permissions/permission_infobar_manager.h

Issue 1422053004: permissions: remove PermissionQueueController and introduce PermissionInfoBarManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address small issues Created 5 years, 1 month 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/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/permissions/permission_request_id.h"
13 #include "components/content_settings/core/common/content_settings.h"
14 #include "components/content_settings/core/common/content_settings_types.h"
15 #include "content/public/browser/web_contents_observer.h"
16 #include "content/public/browser/web_contents_user_data.h"
17
18 class GURL;
19 class PermissionInfoBarRequest;
20
21 // Manages permsision requests using InfoBars. Requests are coalesced by
22 // request_id. If multiple requests occur with overlapping permissions, both
23 // will be shown and the last to have a response will be persisted.
24 class PermissionInfoBarManager
25 : public content::WebContentsObserver,
26 public content::WebContentsUserData<PermissionInfoBarManager> {
27 public:
28 ~PermissionInfoBarManager() override;
29
30 // Queues an infobar request to be shown at some point. Requests with
31 // the same |request_id| are coalesced.
32 void CreateRequest(
33 const ContentSettingsType type,
34 const PermissionRequestID& request,
35 const GURL& requesting_origin,
36 const GURL& embedding_origin,
37 const base::Callback<void(bool, ContentSetting)>& callback);
38
39 // Cancels a specific infobar request.
40 void CancelRequest(const PermissionRequestID& request);
41
42 private:
43 friend class GeolocationPermissionContextTests;
44 friend class PermissionContextBaseTests;
45 friend class content::WebContentsUserData<PermissionInfoBarManager>;
46 using PermissionDecidedCallback = base::Callback<void(bool, ContentSetting)>;
47
48 explicit PermissionInfoBarManager(content::WebContents* web_contents);
49
50 // Posts a call to |ShowNextQueuedRequest| if there is no current request
51 // and |queued_requests_| is not empty.
52 void TriggerShowNextQueuedRequest();
53
54 // Shows the next request in |queued_requests_| if there is no current
55 // request and if |queued_requests_| is not empty
56 void ShowNextQueuedRequest();
57
58 // Callback function used when the infobar is dismissed, accepted or denied.
59 void OnInfoBarClosed();
60
61 // Removes the current request and shows a next queued request if available.
62 void ClearCurrentRequest();
63
64 // Returns whether the queue should be ignored when considering to show
65 // a new request.
66 bool ShouldIgnoreQueuedRequests();
67
68 // Pointer to the current request which is displayed to the user.
69 scoped_ptr<PermissionInfoBarRequest> current_request_;
70
71 // Indicates whether there is a currently pending call to
72 // |ShowNextQueuedRequest| in the UI thread even loop.
73 bool is_show_pending_;
74
75 // The mapping of request_id to queued requests. Note that |current_request_|
76 // will not be present in this map.
77 base::ScopedPtrHashMap<int,
78 scoped_ptr<PermissionInfoBarRequest>> queued_requests_;
79
80 base::WeakPtrFactory<PermissionInfoBarManager> weak_factory_;
81
82 DISALLOW_COPY_AND_ASSIGN(PermissionInfoBarManager);
83 };
84
85 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698