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 "components/url_formatter/elide_url.h" | 8 #include "components/url_formatter/elide_url.h" |
8 #include "grit/theme_resources.h" | 9 #include "grit/theme_resources.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 if (GetPermissionCount() >= 2) |
| 29 return false; |
| 30 return PermissionUtil::ShouldShowPersistenceToggle(); |
| 31 } |
| 32 |
25 int GroupedPermissionInfoBarDelegate::GetButtons() const { | 33 int GroupedPermissionInfoBarDelegate::GetButtons() const { |
26 if (GetPermissionCount() >= 2) | 34 if (GetPermissionCount() >= 2) |
27 return ConfirmInfoBarDelegate::InfoBarButton::BUTTON_OK; | 35 return ConfirmInfoBarDelegate::InfoBarButton::BUTTON_OK; |
28 else | 36 else |
29 return ConfirmInfoBarDelegate::GetButtons(); | 37 return ConfirmInfoBarDelegate::GetButtons(); |
30 } | 38 } |
31 | 39 |
32 base::string16 GroupedPermissionInfoBarDelegate::GetButtonLabel( | 40 base::string16 GroupedPermissionInfoBarDelegate::GetButtonLabel( |
33 InfoBarButton button) const { | 41 InfoBarButton button) const { |
34 if (GetPermissionCount() >= 2) { | 42 if (GetPermissionCount() >= 2) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 void GroupedPermissionInfoBarDelegate::ToggleAccept(int position, | 93 void GroupedPermissionInfoBarDelegate::ToggleAccept(int position, |
86 bool new_value) { | 94 bool new_value) { |
87 DCHECK(position >= 0 && position < static_cast<int>(types_.size())); | 95 DCHECK(position >= 0 && position < static_cast<int>(types_.size())); |
88 accept_states_[position] = new_value; | 96 accept_states_[position] = new_value; |
89 } | 97 } |
90 | 98 |
91 bool GroupedPermissionInfoBarDelegate::GetAcceptState(int position) { | 99 bool GroupedPermissionInfoBarDelegate::GetAcceptState(int position) { |
92 DCHECK(position >= 0 && position < static_cast<int>(types_.size())); | 100 DCHECK(position >= 0 && position < static_cast<int>(types_.size())); |
93 return accept_states_[position]; | 101 return accept_states_[position]; |
94 } | 102 } |
OLD | NEW |