| 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_ANDROID_H
_ | 5 #ifndef CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_ANDROID_H
_ |
| 6 #define CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_ANDROID_H
_ | 6 #define CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_ANDROID_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 | 16 |
| 17 namespace content { |
| 18 enum class PermissionType; |
| 19 } // namespace content |
| 20 |
| 17 // An InfoBar that displays a group of permission requests, each of which can be | 21 // An InfoBar that displays a group of permission requests, each of which can be |
| 18 // allowed or blocked independently. | 22 // allowed or blocked independently. |
| 19 // TODO(tsergeant): Expand this class so it can be used without subclassing. | 23 // TODO(tsergeant): Expand this class so it can be used without subclassing. |
| 20 class GroupedPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { | 24 class GroupedPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 21 public: | 25 public: |
| 22 // Public so we can have std::unique_ptr<GroupedPermissionInfoBarDelegate>. | 26 // Public so we can have std::unique_ptr<GroupedPermissionInfoBarDelegate>. |
| 23 ~GroupedPermissionInfoBarDelegate() override; | 27 ~GroupedPermissionInfoBarDelegate() override; |
| 24 | 28 |
| 25 static infobars::InfoBar* Create( | 29 static infobars::InfoBar* Create( |
| 26 InfoBarService* infobar_service, | 30 InfoBarService* infobar_service, |
| 27 const GURL& requesting_origin, | 31 const GURL& requesting_origin, |
| 28 const std::vector<ContentSettingsType>& types); | 32 const std::vector<ContentSettingsType>& types); |
| 29 | 33 |
| 30 bool persist() const { return persist_; } | 34 bool persist() const { return persist_; } |
| 31 void set_persist(bool persist) { persist_ = persist; } | 35 void set_persist(bool persist) { persist_ = persist; } |
| 32 size_t permission_count() const { return types_.size(); } | 36 size_t permission_count() const { return types_.size(); } |
| 33 | 37 |
| 34 // Returns true if the infobar should display a toggle to allow users to | 38 // Returns true if the infobar should display a toggle to allow users to |
| 35 // opt-out of persisting their accept/deny decision. | 39 // opt-out of persisting their accept/deny decision. |
| 36 bool ShouldShowPersistenceToggle() const; | 40 bool ShouldShowPersistenceToggle() const; |
| 37 | 41 |
| 38 ContentSettingsType GetContentSettingType(size_t position) const; | 42 content::PermissionType GetPermissionType(size_t position) const; |
| 39 int GetIconIdForPermission(size_t position) const; | 43 int GetIconIdForPermission(size_t position) const; |
| 40 | 44 |
| 41 // Message text to display for an individual permission at |position|. | 45 // Message text to display for an individual permission at |position|. |
| 42 base::string16 GetMessageTextFragment(size_t position) const; | 46 base::string16 GetMessageTextFragment(size_t position) const; |
| 43 | 47 |
| 44 // Toggle accept value for an individual permission at |position|. | 48 // Toggle accept value for an individual permission at |position|. |
| 45 void ToggleAccept(size_t position, bool new_value); | 49 void ToggleAccept(size_t position, bool new_value); |
| 46 | 50 |
| 47 // ConfirmInfoBarDelegate: | 51 // ConfirmInfoBarDelegate: |
| 48 base::string16 GetMessageText() const override; | 52 base::string16 GetMessageText() const override; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 64 const GURL requesting_origin_; | 68 const GURL requesting_origin_; |
| 65 const std::vector<ContentSettingsType> types_; | 69 const std::vector<ContentSettingsType> types_; |
| 66 std::vector<bool> accept_states_; | 70 std::vector<bool> accept_states_; |
| 67 // Whether the accept/deny decision is persisted. | 71 // Whether the accept/deny decision is persisted. |
| 68 bool persist_; | 72 bool persist_; |
| 69 | 73 |
| 70 DISALLOW_COPY_AND_ASSIGN(GroupedPermissionInfoBarDelegate); | 74 DISALLOW_COPY_AND_ASSIGN(GroupedPermissionInfoBarDelegate); |
| 71 }; | 75 }; |
| 72 | 76 |
| 73 #endif // CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_ANDROI
D_H_ | 77 #endif // CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_ANDROI
D_H_ |
| OLD | NEW |