Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / permissions / permission_infobar_delegate.h
blob35fc49f13ff25cc88d4038f4ca4f4fcc3d1485ec
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_
8 #include "chrome/browser/infobars/infobar_service.h"
9 #include "components/content_settings/core/common/content_settings_types.h"
10 #include "components/infobars/core/confirm_infobar_delegate.h"
11 #include "content/public/browser/web_contents.h"
13 class NavigationDetails;
15 // Base class for permission infobars, it implements the default behavior
16 // so that the accept/deny buttons grant/deny the relevant permission.
17 // A basic implementor only needs to implement the methods that
18 // provide an icon and a message text to the infobar.
19 class PermissionInfobarDelegate : public ConfirmInfoBarDelegate {
21 public:
22 using PermissionSetCallback = base::Callback<void(bool, bool)>;
23 ContentSettingsType content_setting() const { return type_; }
25 protected:
26 PermissionInfobarDelegate(const GURL& requesting_origin,
27 ContentSettingsType type,
28 const PermissionSetCallback& callback);
29 ~PermissionInfobarDelegate() override;
31 private:
32 // ConfirmInfoBarDelegate:
33 Type GetInfoBarType() const override;
34 void InfoBarDismissed() override;
35 PermissionInfobarDelegate* AsPermissionInfobarDelegate() override;
36 base::string16 GetButtonLabel(InfoBarButton button) const override;
37 bool Accept() override;
38 bool Cancel() override;
40 void SetPermission(bool update_content_setting, bool allowed);
42 GURL requesting_origin_;
43 bool action_taken_;
44 ContentSettingsType type_;
45 const PermissionSetCallback callback_;
47 DISALLOW_COPY_AND_ASSIGN(PermissionInfobarDelegate);
50 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_