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 CreateInfoBarRequest( | |
mlamouri (slow - plz ping)
2015/09/28 13:30:15
nit: CreateRequest()
Lalit Maganti
2015/09/28 15:32:38
Done.
| |
32 const ContentSettingsType type, | |
33 const PermissionRequestID& request, | |
34 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.
| |
35 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.
| |
36 const base::Callback<void(bool, ContentSetting)>& user_callback, | |
37 const base::Callback<void(bool, ContentSetting)>& non_user_callback); | |
38 | |
39 // Cancels a specific infobar request. | |
40 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.
| |
41 | |
42 private: | |
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 void TriggerShowNextQueuedRequest(); | |
50 void ShowNextQueuedRequest(); | |
51 void OnInfoBarClosed(bool cancelled); | |
52 | |
53 void ClearCurrentRequest(); | |
54 bool ShouldIgnoreQueuedRequests(); | |
55 | |
56 scoped_ptr<PermissionInfoBarRequest> current_request_; | |
57 int current_request_id_; | |
58 | |
59 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
| |
60 | |
61 base::ScopedPtrHashMap<int, | |
62 scoped_ptr<PermissionInfoBarRequest>> queued_requests_; | |
63 | |
64 base::WeakPtrFactory<PermissionInfoBarManager> weak_factory_; | |
65 | |
66 DISALLOW_COPY_AND_ASSIGN(PermissionInfoBarManager); | |
67 }; | |
68 | |
69 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_MANAGER_H_ | |
OLD | NEW |