| 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 PermissionsBubbleViewAndroid; |
| 17 class PermissionRequest; |
| 16 | 18 |
| 17 // Base class for permission infobars, it implements the default behavior | 19 // Base class for permission infobars, it implements the default behavior |
| 18 // so that the accept/deny buttons grant/deny the relevant permission. | 20 // so that the accept/deny buttons grant/deny the relevant permission. |
| 19 // A basic implementor only needs to implement the methods that | 21 // A basic implementor only needs to implement the methods that |
| 20 // provide an icon and a message text to the infobar. | 22 // provide an icon and a message text to the infobar. |
| 21 class PermissionInfobarDelegate : public ConfirmInfoBarDelegate { | 23 class PermissionInfobarDelegate : public ConfirmInfoBarDelegate { |
| 22 | |
| 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: |
| 29 friend PermissionsBubbleViewAndroid; |
| 30 explicit PermissionInfobarDelegate(PermissionRequest* request); |
| 28 PermissionInfobarDelegate(const GURL& requesting_origin, | 31 PermissionInfobarDelegate(const GURL& requesting_origin, |
| 29 content::PermissionType permission_type, | 32 content::PermissionType permission_type, |
| 30 ContentSettingsType content_settings_type, | 33 ContentSettingsType content_settings_type, |
| 31 const PermissionSetCallback& callback); | 34 const PermissionSetCallback& callback); |
| 32 ~PermissionInfobarDelegate() override; | 35 ~PermissionInfobarDelegate() override; |
| 33 | 36 |
| 34 virtual int GetMessageResourceId() const = 0; | 37 virtual int GetMessageResourceId() const; |
| 35 | 38 |
| 36 private: | 39 private: |
| 37 // ConfirmInfoBarDelegate: | 40 // ConfirmInfoBarDelegate: |
| 38 Type GetInfoBarType() const override; | 41 Type GetInfoBarType() const override; |
| 39 void InfoBarDismissed() override; | 42 void InfoBarDismissed() override; |
| 40 PermissionInfobarDelegate* AsPermissionInfobarDelegate() override; | 43 PermissionInfobarDelegate* AsPermissionInfobarDelegate() override; |
| 41 base::string16 GetButtonLabel(InfoBarButton button) const override; | 44 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 42 base::string16 GetMessageText() const override; | 45 base::string16 GetMessageText() const override; |
| 43 bool Accept() override; | 46 bool Accept() override; |
| 44 bool Cancel() override; | 47 bool Cancel() override; |
| 48 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
| 49 int GetIconId() const override; |
| 45 | 50 |
| 46 void SetPermission(bool update_content_setting, bool allowed); | 51 void SetPermission(bool update_content_setting, bool allowed); |
| 47 | 52 |
| 48 GURL requesting_origin_; | 53 GURL requesting_origin_; |
| 49 bool action_taken_; | 54 bool action_taken_; |
| 50 content::PermissionType permission_type_; | 55 content::PermissionType permission_type_; |
| 51 ContentSettingsType content_settings_type_; | 56 ContentSettingsType content_settings_type_; |
| 52 const PermissionSetCallback callback_; | 57 const PermissionSetCallback callback_; |
| 58 // TODO: probably not okay. |
| 59 PermissionRequest* request_; |
| 53 | 60 |
| 54 DISALLOW_COPY_AND_ASSIGN(PermissionInfobarDelegate); | 61 DISALLOW_COPY_AND_ASSIGN(PermissionInfobarDelegate); |
| 55 }; | 62 }; |
| 56 | 63 |
| 57 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_ | 64 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_ |
| OLD | NEW |