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

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

Issue 1337903002: permissions: remove PermissionQueueController and introduce PermissionInfoBarManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@callbacks-delegates
Patch Set: Attempt to fix test 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_REQUEST_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_REQUEST_H_
7
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "components/content_settings/core/common/content_settings.h"
11 #include "url/gurl.h"
12
13 class InfoBarService;
14 class Profile;
15
16 namespace content {
17 class WebContents;
18 } // namespace content
19
20 namespace infobars {
21 class InfoBar;
22 } // namespace infobars
23
24 // Represents a permission request which will be displayed using an InfoBar.
25 class PermissionInfoBarRequest {
26 public:
27 PermissionInfoBarRequest(
28 int request_id,
29 const GURL& requesting_origin,
30 const GURL& embedding_origin,
31 const base::Closure& callback);
32 ~PermissionInfoBarRequest();
33
34 // Adds a permisison type which should be associated with this request.
35 void AddPermission(
36 const ContentSettingsType type,
37 const base::Callback<void(bool, ContentSetting)>& response_callback);
38
39 // Shows the relavent infobar for this request in the specified web contents.
mlamouri (slow - plz ping) 2015/10/02 11:49:39 I think you should add comments regarding the rela
Lalit Maganti 2015/10/02 13:37:45 Done.
40 bool ShowInfobar(content::WebContents* web_contents);
41
42 // Used to manually accept the request.
mlamouri (slow - plz ping) 2015/10/02 11:49:40 Here and below. What do you mean by "manually"?
Lalit Maganti 2015/10/02 13:37:45 Done.
43 void Accept();
44
45 // Used to manually dismiss the request.
46 void Closing();
47
48 // Used to manually cancel the request.
49 void Cancel();
50
51 int request_id() const { return request_id_; }
52
53 private:
54 using PermissionDecidedCallback = base::Callback<void(bool, ContentSetting)>;
55 class PermissionRequest {
56 public:
57 PermissionRequest(ContentSettingsType type,
58 const PermissionDecidedCallback& response_callback);
59 ~PermissionRequest();
60
61 ContentSettingsType type() const { return type_; }
62 const PermissionDecidedCallback& response_callback() const {
63 return response_callback_;
64 }
65
66 private:
67 ContentSettingsType type_;
68 PermissionDecidedCallback response_callback_;
mlamouri (slow - plz ping) 2015/10/02 11:49:39 nit: rename |callback_|.
Lalit Maganti 2015/10/02 13:37:45 Done.
69 };
70
71 // Called when this request is dismissed manually.
72 void OnManualClose();
73
74 // Callback function used when single permission infobar is shown.
mlamouri (slow - plz ping) 2015/10/02 11:49:39 "Shown" for "OnPermissionSet"?
Lalit Maganti 2015/10/02 13:37:45 Done.
75 void OnPermissionSet(bool update_content_setting,
76 bool allowed);
77
78 // Callback function used when a coalesced infobar is shown.
mlamouri (slow - plz ping) 2015/10/02 11:49:39 ditto
Lalit Maganti 2015/10/02 13:37:45 Done.
79 void OnPermissionsSet(bool update_content_setting,
80 const std::vector<ContentSetting>& allowed);
81
82 // Removes any permissions from this request for which there is already
83 // a user specified ContentSetting.
mlamouri (slow - plz ping) 2015/10/02 11:49:39 nit: do not mention ContentSetting. Maybe: """ Rem
Lalit Maganti 2015/10/02 13:37:45 Done.
84 void PruneAnsweredPermissions(Profile* profile);
85
86 // Creates the single permission infobar for the PermissionRequest|
mlamouri (slow - plz ping) 2015/10/02 11:49:40 nit: remove "|"
Lalit Maganti 2015/10/02 13:37:45 Done.
87 // specified.
88 void CreateInfoBar(InfoBarService* infobar_service,
89 const PermissionRequest& request,
90 const std::string& display_languages,
91 const base::Callback<void(bool, bool)>& callback);
92
93 // Owned by InfoBarService.
94 infobars::InfoBar* infobar_;
95
96 int request_id_;
97 GURL requesting_origin_;
98 GURL embedding_origin_;
99 base::Closure callback_;
100 std::vector<PermissionRequest> requests_;
101
102 base::WeakPtrFactory<PermissionInfoBarRequest> weak_factory_;
103
104 DISALLOW_COPY_AND_ASSIGN(PermissionInfoBarRequest);
105 };
106
107 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698