OLD | NEW |
---|---|
(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)>& response_callback); | |
37 | |
38 // Cancels a specific infobar request. | |
39 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.
| |
40 | |
41 private: | |
42 friend class PermissionContextBaseTests; | |
43 friend class content::WebContentsUserData<PermissionInfoBarManager>; | |
44 using PermissionDecidedCallback = base::Callback<void(bool, ContentSetting)>; | |
45 | |
46 explicit PermissionInfoBarManager(content::WebContents* web_contents); | |
47 | |
48 void Accept(); | |
49 void Closing(); | |
mlamouri (slow - plz ping)
2015/09/29 14:02:18
Add comments.
Lalit Maganti
2015/10/01 17:05:14
Done.
| |
50 | |
51 void TriggerShowNextQueuedRequest(); | |
52 void ShowNextQueuedRequest(); | |
53 void OnInfoBarClosed(); | |
mlamouri (slow - plz ping)
2015/09/29 14:02:18
ditto
Lalit Maganti
2015/10/01 17:05:14
Done.
| |
54 | |
55 void ClearCurrentRequest(); | |
56 bool ShouldIgnoreQueuedRequests(); | |
mlamouri (slow - plz ping)
2015/09/29 14:02:18
ditto
Lalit Maganti
2015/10/01 17:05:14
Done.
| |
57 | |
58 scoped_ptr<PermissionInfoBarRequest> current_request_; | |
59 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.
| |
60 | |
61 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.
| |
62 | |
63 base::ScopedPtrHashMap<int, | |
64 scoped_ptr<PermissionInfoBarRequest>> queued_requests_; | |
65 | |
66 base::WeakPtrFactory<PermissionInfoBarManager> weak_factory_; | |
67 | |
68 DISALLOW_COPY_AND_ASSIGN(PermissionInfoBarManager); | |
69 }; | |
70 | |
71 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_MANAGER_H_ | |
OLD | NEW |