| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_GROUPED_PERMISSION_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "components/content_settings/core/common/content_settings_types.h" | 11 #include "components/content_settings/core/common/content_settings_types.h" |
| 12 #include "components/infobars/core/confirm_infobar_delegate.h" | 12 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 13 | 13 |
| 14 class GURL; | 14 class GURL; |
| 15 class InfoBarService; | 15 class InfoBarService; |
| 16 class PermissionRequest; |
| 16 | 17 |
| 17 namespace infobars { | 18 namespace infobars { |
| 18 class InfoBarManager; | 19 class InfoBarManager; |
| 19 } | 20 } |
| 20 | 21 |
| 21 // Configures an InfoBar to display a group of permission requests, each of | 22 // Configures an InfoBar to display a group of permission requests, each of |
| 22 // which can be allowed or blocked independently. | 23 // which can be allowed or blocked independently. |
| 23 // TODO(tsergeant): Expand this class so it can be used without subclassing. | 24 // TODO(tsergeant): Expand this class so it can be used without subclassing. |
| 24 class GroupedPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { | 25 class GroupedPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 25 public: | 26 public: |
| 26 // Implementation is in platform-specific infobar file. | 27 // Implementation is in platform-specific infobar file. |
| 27 static std::unique_ptr<infobars::InfoBar> CreateInfoBar( | 28 static std::unique_ptr<infobars::InfoBar> CreateInfoBar( |
| 28 infobars::InfoBarManager* infobar_manager, | 29 infobars::InfoBarManager* infobar_manager, |
| 29 std::unique_ptr<GroupedPermissionInfoBarDelegate> delegate); | 30 std::unique_ptr<GroupedPermissionInfoBarDelegate> delegate); |
| 30 | 31 |
| 31 GroupedPermissionInfoBarDelegate( | 32 GroupedPermissionInfoBarDelegate( |
| 32 const GURL& requesting_origin, | 33 const GURL& requesting_origin, |
| 33 const std::vector<ContentSettingsType>& types); | 34 const std::vector<PermissionRequest*>& requests); |
| 34 ~GroupedPermissionInfoBarDelegate() override; | 35 ~GroupedPermissionInfoBarDelegate() override; |
| 35 | 36 |
| 36 bool ShouldShowPersistenceToggle() const; | 37 bool ShouldShowPersistenceToggle() const; |
| 37 bool persist() const { return persist_; } | 38 bool persist() const { return persist_; } |
| 38 void set_persist(bool persist) { persist_ = persist; } | 39 void set_persist(bool persist) { persist_ = persist; } |
| 39 | 40 |
| 40 base::string16 GetMessageText() const override; | 41 base::string16 GetMessageText() const override; |
| 41 | 42 |
| 42 int GetPermissionCount() const; | 43 int GetPermissionCount() const; |
| 43 ContentSettingsType GetContentSettingType(int index) const; | 44 ContentSettingsType GetContentSettingType(int index) const; |
| 44 int GetIconIdForPermission(int index) const; | 45 int GetIconIdForPermission(int index) const; |
| 45 // Message text to display for an individual permission at |index|. | 46 // Message text to display for an individual permission at |index|. |
| 46 base::string16 GetMessageTextFragment(int index) const; | 47 base::string16 GetMessageTextFragment(int index) const; |
| 47 | 48 |
| 48 void ToggleAccept(int position, bool new_value); | 49 void ToggleAccept(int position, bool new_value); |
| 49 | 50 |
| 50 protected: | 51 protected: |
| 51 bool GetAcceptState(int position); | 52 bool GetAcceptState(int position); |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 // ConfirmInfoBarDelegate: | 55 // ConfirmInfoBarDelegate: |
| 55 base::string16 GetButtonLabel(InfoBarButton button) const override; | 56 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 56 int GetButtons() const override; | 57 int GetButtons() const override; |
| 57 | 58 |
| 58 // InfoBarDelegate: | 59 // InfoBarDelegate: |
| 59 Type GetInfoBarType() const override; | 60 Type GetInfoBarType() const override; |
| 60 | 61 |
| 61 const GURL requesting_origin_; | 62 const GURL requesting_origin_; |
| 62 const std::vector<ContentSettingsType> types_; | 63 const std::vector<PermissionRequest*> requests_; |
| 63 std::vector<bool> accept_states_; | 64 std::vector<bool> accept_states_; |
| 64 bool persist_; | 65 bool persist_; |
| 65 | 66 |
| 66 DISALLOW_COPY_AND_ASSIGN(GroupedPermissionInfoBarDelegate); | 67 DISALLOW_COPY_AND_ASSIGN(GroupedPermissionInfoBarDelegate); |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 #endif // CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_H_ | 70 #endif // CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_H_ |
| OLD | NEW |