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 #include "chrome/browser/permissions/grouped_permission_infobar_delegate.h" | 5 #include "chrome/browser/permissions/grouped_permission_infobar_delegate.h" |
| 6 #include "chrome/browser/permissions/permission_util.h" |
6 #include "chrome/grit/generated_resources.h" | 7 #include "chrome/grit/generated_resources.h" |
7 #include "chrome/grit/theme_resources.h" | 8 #include "chrome/grit/theme_resources.h" |
8 #include "components/url_formatter/elide_url.h" | 9 #include "components/url_formatter/elide_url.h" |
9 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
10 | 11 |
11 GroupedPermissionInfoBarDelegate::GroupedPermissionInfoBarDelegate( | 12 GroupedPermissionInfoBarDelegate::GroupedPermissionInfoBarDelegate( |
12 const GURL& requesting_origin, | 13 const GURL& requesting_origin, |
13 const std::vector<ContentSettingsType>& types) | 14 const std::vector<ContentSettingsType>& types) |
14 : requesting_origin_(requesting_origin), | 15 : requesting_origin_(requesting_origin), |
15 types_(types), | 16 types_(types), |
16 accept_states_(types_.size(), true) {} | 17 accept_states_(types_.size(), true), |
| 18 persist_(true) {} |
17 | 19 |
18 GroupedPermissionInfoBarDelegate::~GroupedPermissionInfoBarDelegate() {} | 20 GroupedPermissionInfoBarDelegate::~GroupedPermissionInfoBarDelegate() {} |
19 | 21 |
20 infobars::InfoBarDelegate::Type | 22 infobars::InfoBarDelegate::Type |
21 GroupedPermissionInfoBarDelegate::GetInfoBarType() const { | 23 GroupedPermissionInfoBarDelegate::GetInfoBarType() const { |
22 return PAGE_ACTION_TYPE; | 24 return PAGE_ACTION_TYPE; |
23 } | 25 } |
24 | 26 |
| 27 bool GroupedPermissionInfoBarDelegate::ShouldShowPersistenceToggle() const { |
| 28 return PermissionUtil::ShouldShowPersistenceToggle(); |
| 29 } |
| 30 |
25 int GroupedPermissionInfoBarDelegate::GetButtons() const { | 31 int GroupedPermissionInfoBarDelegate::GetButtons() const { |
26 if (GetPermissionCount() >= 2) | 32 if (GetPermissionCount() >= 2) |
27 return ConfirmInfoBarDelegate::InfoBarButton::BUTTON_OK; | 33 return ConfirmInfoBarDelegate::InfoBarButton::BUTTON_OK; |
28 else | 34 else |
29 return ConfirmInfoBarDelegate::GetButtons(); | 35 return ConfirmInfoBarDelegate::GetButtons(); |
30 } | 36 } |
31 | 37 |
32 base::string16 GroupedPermissionInfoBarDelegate::GetButtonLabel( | 38 base::string16 GroupedPermissionInfoBarDelegate::GetButtonLabel( |
33 InfoBarButton button) const { | 39 InfoBarButton button) const { |
34 if (GetPermissionCount() >= 2) { | 40 if (GetPermissionCount() >= 2) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 void GroupedPermissionInfoBarDelegate::ToggleAccept(int position, | 91 void GroupedPermissionInfoBarDelegate::ToggleAccept(int position, |
86 bool new_value) { | 92 bool new_value) { |
87 DCHECK(position >= 0 && position < static_cast<int>(types_.size())); | 93 DCHECK(position >= 0 && position < static_cast<int>(types_.size())); |
88 accept_states_[position] = new_value; | 94 accept_states_[position] = new_value; |
89 } | 95 } |
90 | 96 |
91 bool GroupedPermissionInfoBarDelegate::GetAcceptState(int position) { | 97 bool GroupedPermissionInfoBarDelegate::GetAcceptState(int position) { |
92 DCHECK(position >= 0 && position < static_cast<int>(types_.size())); | 98 DCHECK(position >= 0 && position < static_cast<int>(types_.size())); |
93 return accept_states_[position]; | 99 return accept_states_[position]; |
94 } | 100 } |
OLD | NEW |