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

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

Issue 1332293002: permissions: switch from explicitly passing queue controller to callbacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_ 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_
7 7
8 #include "chrome/browser/infobars/infobar_service.h" 8 #include "chrome/browser/infobars/infobar_service.h"
9 #include "chrome/browser/permissions/permission_request_id.h"
10 #include "components/content_settings/core/common/content_settings_types.h" 9 #include "components/content_settings/core/common/content_settings_types.h"
11 #include "components/infobars/core/confirm_infobar_delegate.h" 10 #include "components/infobars/core/confirm_infobar_delegate.h"
12 #include "content/public/browser/web_contents.h" 11 #include "content/public/browser/web_contents.h"
13 12
14 class NavigationDetails; 13 class NavigationDetails;
15 class PermissionQueueController;
16 14
17 // Base class for permission infobars, it implements the default behavior 15 // Base class for permission infobars, it implements the default behavior
18 // so that the accept/deny buttons grant/deny the relevant permission. 16 // so that the accept/deny buttons grant/deny the relevant permission.
19 // A basic implementor only needs to implement the methods that 17 // A basic implementor only needs to implement the methods that
20 // provide an icon and a message text to the infobar. 18 // provide an icon and a message text to the infobar.
21 class PermissionInfobarDelegate : public ConfirmInfoBarDelegate { 19 class PermissionInfobarDelegate : public ConfirmInfoBarDelegate {
22 20
23 public: 21 public:
22 using PermissionSetCallback = base::Callback<void(bool, bool)>;
24 ContentSettingsType content_setting() const { return type_; } 23 ContentSettingsType content_setting() const { return type_; }
25 24
26 protected: 25 protected:
27 PermissionInfobarDelegate(PermissionQueueController* controller, 26 PermissionInfobarDelegate(const GURL& requesting_origin,
28 const PermissionRequestID& id, 27 ContentSettingsType type,
29 const GURL& requesting_origin, 28 const PermissionSetCallback& callback);
30 ContentSettingsType type);
31 ~PermissionInfobarDelegate() override; 29 ~PermissionInfobarDelegate() override;
32 30
33 private: 31 private:
34 // ConfirmInfoBarDelegate: 32 // ConfirmInfoBarDelegate:
35 Type GetInfoBarType() const override; 33 Type GetInfoBarType() const override;
36 void InfoBarDismissed() override; 34 void InfoBarDismissed() override;
37 PermissionInfobarDelegate* AsPermissionInfobarDelegate() override; 35 PermissionInfobarDelegate* AsPermissionInfobarDelegate() override;
38 base::string16 GetButtonLabel(InfoBarButton button) const override; 36 base::string16 GetButtonLabel(InfoBarButton button) const override;
39 bool Accept() override; 37 bool Accept() override;
40 bool Cancel() override; 38 bool Cancel() override;
41 39
42 void SetPermission(bool update_content_setting, bool allowed); 40 void SetPermission(bool update_content_setting, bool allowed);
43 41
44 PermissionQueueController* controller_; // not owned by us
45 const PermissionRequestID id_;
46 GURL requesting_origin_; 42 GURL requesting_origin_;
47 bool action_taken_; 43 bool action_taken_;
48 ContentSettingsType type_; 44 ContentSettingsType type_;
45 const PermissionSetCallback callback_;
49 46
50 DISALLOW_COPY_AND_ASSIGN(PermissionInfobarDelegate); 47 DISALLOW_COPY_AND_ASSIGN(PermissionInfobarDelegate);
51 }; 48 };
52 49
53 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_ 50 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698