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

Side by Side Diff: chrome/browser/permissions/permission_infobar_request.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_REQUEST_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_REQUEST_H_
7
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h"
11 #include "components/content_settings/core/common/content_settings.h"
12 #include "url/gurl.h"
13
14 class InfoBarService;
15 class Profile;
16
17 namespace content {
18 class WebContents;
19 } // namespace content
20
21 namespace infobars {
22 class InfoBar;
23 } // namespace infobars
24
25 // Represents a permission request which will be displayed using an InfoBar.
26 class PermissionInfoBarRequest {
27 public:
28 PermissionInfoBarRequest(
29 int request_id,
30 const GURL& requesting_origin,
31 const GURL& embedding_origin,
32 const base::Closure& callback);
33 ~PermissionInfoBarRequest();
34
35 // Adds a permisison type which should be associated with this request.
36 /// This function can be called as many times as the caller wants until
37 // |ShowInfobar| is called. After this point this function should NOT be
38 // called.
39 void AddPermission(
40 const ContentSettingsType type,
41 const base::Callback<void(bool, ContentSetting)>& callback);
42
43 // Shows the relavent infobar for this request in the specified web contents.
44 // Called after all permissions have been added to the request with
45 // |AddPermission|.
46 bool ShowInfobar(content::WebContents* web_contents);
47
48 // Used to cancel the request without user action.
49 void Cancel();
50
51 int request_id() const { return request_id_; }
52
53 private:
54 friend class PermissionContextBaseTests;
55 using PermissionDecidedCallback = base::Callback<void(bool, ContentSetting)>;
56 class PermissionRequest {
57 public:
58 PermissionRequest(ContentSettingsType type,
59 const PermissionDecidedCallback& callback);
60 ~PermissionRequest();
61
62 ContentSettingsType type() const { return type_; }
63 const PermissionDecidedCallback& callback() const {
64 return callback_;
65 }
66
67 private:
68 ContentSettingsType type_;
69 PermissionDecidedCallback callback_;
70 };
71
72 // Used to accept or dismiss the request in tests.
73 void AcceptForTests();
74 void ClosingForTests();
75
76 // Called when this request is dismissed without user action.
77 void OnCancel();
78
79 // Callback function which is called when the user responds to a single
80 // permission infobar.
81 void OnPermissionSet(bool update_content_setting,
82 bool allowed);
83
84 // Callback function which is called when the user responds to a coalesced
85 // permission infobar.
86 void OnPermissionsSet(bool update_content_setting,
87 const std::vector<ContentSetting>& allowed);
88
89 // Removes any permissions from this request for which there is no need to
90 // prompt the user.
91 void PruneAnsweredPermissions(Profile* profile);
92
93 // Creates the single permission infobar for the PermissionRequest
94 // specified.
95 void CreateInfoBar(InfoBarService* infobar_service,
96 const PermissionRequest& request,
97 const std::string& display_languages,
98 const base::Callback<void(bool, bool)>& callback);
99
100 // Owned by InfoBarService.
101 infobars::InfoBar* infobar_;
102
103 int request_id_;
104 GURL requesting_origin_;
105 GURL embedding_origin_;
106 base::Closure callback_;
107 std::vector<PermissionRequest> requests_;
108
109 base::WeakPtrFactory<PermissionInfoBarRequest> weak_factory_;
110
111 DISALLOW_COPY_AND_ASSIGN(PermissionInfoBarRequest);
112 };
113
114 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_REQUEST_H_
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_infobar_manager.cc ('k') | chrome/browser/permissions/permission_infobar_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698