| OLD | NEW |
| 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 "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
| 10 #include "components/content_settings/core/common/content_settings_types.h" | 10 #include "components/content_settings/core/common/content_settings_types.h" |
| 11 #include "components/infobars/core/confirm_infobar_delegate.h" | 11 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 12 #include "content/public/browser/permission_type.h" | 12 #include "content/public/browser/permission_type.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 | 14 |
| 15 class NavigationDetails; | 15 class NavigationDetails; |
| 16 class Profile; |
| 16 | 17 |
| 17 // Base class for permission infobars, it implements the default behavior | 18 // Base class for permission infobars, it implements the default behavior |
| 18 // so that the accept/deny buttons grant/deny the relevant permission. | 19 // so that the accept/deny buttons grant/deny the relevant permission. |
| 19 // A basic implementor only needs to implement the methods that | 20 // A basic implementor only needs to implement the methods that |
| 20 // provide an icon and a message text to the infobar. | 21 // provide an icon and a message text to the infobar. |
| 21 class PermissionInfobarDelegate : public ConfirmInfoBarDelegate { | 22 class PermissionInfobarDelegate : public ConfirmInfoBarDelegate { |
| 22 | 23 |
| 23 public: | 24 public: |
| 24 using PermissionSetCallback = base::Callback<void(bool, bool)>; | 25 using PermissionSetCallback = base::Callback<void(bool, bool)>; |
| 25 ContentSettingsType content_setting() const { return content_settings_type_; } | 26 ContentSettingsType content_setting() const { return content_settings_type_; } |
| 26 | 27 |
| 27 protected: | 28 protected: |
| 28 PermissionInfobarDelegate(const GURL& requesting_origin, | 29 PermissionInfobarDelegate(const GURL& requesting_origin, |
| 29 content::PermissionType permission_type, | 30 content::PermissionType permission_type, |
| 30 ContentSettingsType content_settings_type, | 31 ContentSettingsType content_settings_type, |
| 32 Profile* profile, |
| 31 const PermissionSetCallback& callback); | 33 const PermissionSetCallback& callback); |
| 32 ~PermissionInfobarDelegate() override; | 34 ~PermissionInfobarDelegate() override; |
| 33 | 35 |
| 34 virtual int GetMessageResourceId() const = 0; | 36 virtual int GetMessageResourceId() const = 0; |
| 35 | 37 |
| 36 private: | 38 private: |
| 37 // ConfirmInfoBarDelegate: | 39 // ConfirmInfoBarDelegate: |
| 38 Type GetInfoBarType() const override; | 40 Type GetInfoBarType() const override; |
| 39 void InfoBarDismissed() override; | 41 void InfoBarDismissed() override; |
| 40 PermissionInfobarDelegate* AsPermissionInfobarDelegate() override; | 42 PermissionInfobarDelegate* AsPermissionInfobarDelegate() override; |
| 41 base::string16 GetButtonLabel(InfoBarButton button) const override; | 43 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 42 base::string16 GetMessageText() const override; | 44 base::string16 GetMessageText() const override; |
| 43 bool Accept() override; | 45 bool Accept() override; |
| 44 bool Cancel() override; | 46 bool Cancel() override; |
| 45 | 47 |
| 46 void SetPermission(bool update_content_setting, bool allowed); | 48 void SetPermission(bool update_content_setting, bool allowed); |
| 47 | 49 |
| 48 GURL requesting_origin_; | 50 GURL requesting_origin_; |
| 49 bool action_taken_; | 51 bool action_taken_; |
| 50 content::PermissionType permission_type_; | 52 content::PermissionType permission_type_; |
| 51 ContentSettingsType content_settings_type_; | 53 ContentSettingsType content_settings_type_; |
| 54 Profile* const profile_; |
| 52 const PermissionSetCallback callback_; | 55 const PermissionSetCallback callback_; |
| 53 | 56 |
| 54 DISALLOW_COPY_AND_ASSIGN(PermissionInfobarDelegate); | 57 DISALLOW_COPY_AND_ASSIGN(PermissionInfobarDelegate); |
| 55 }; | 58 }; |
| 56 | 59 |
| 57 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_ | 60 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_ |
| OLD | NEW |