| 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/grit/generated_resources.h" | 6 #include "chrome/grit/generated_resources.h" |
| 7 #include "components/url_formatter/elide_url.h" | 7 #include "components/url_formatter/elide_url.h" |
| 8 #include "grit/theme_resources.h" | 8 #include "grit/theme_resources.h" |
| 9 #include "ui/base/l10n/l10n_util.h" | 9 #include "ui/base/l10n/l10n_util.h" |
| 10 | 10 |
| 11 GroupedPermissionInfoBarDelegate::GroupedPermissionInfoBarDelegate( | 11 GroupedPermissionInfoBarDelegate::GroupedPermissionInfoBarDelegate( |
| 12 const GURL& requesting_origin, | 12 const GURL& requesting_origin, |
| 13 const std::vector<ContentSettingsType>& types) | 13 const std::vector<ContentSettingsType>& types) |
| 14 : requesting_origin_(requesting_origin), | 14 : PermissionInfoBarDelegate(requesting_origin), |
| 15 types_(types), | 15 types_(types), |
| 16 accept_states_(types_.size(), true) {} | 16 accept_states_(types_.size(), true) {} |
| 17 | 17 |
| 18 GroupedPermissionInfoBarDelegate::~GroupedPermissionInfoBarDelegate() {} | 18 GroupedPermissionInfoBarDelegate::~GroupedPermissionInfoBarDelegate() {} |
| 19 | 19 |
| 20 infobars::InfoBarDelegate::Type | 20 infobars::InfoBarDelegate::Type |
| 21 GroupedPermissionInfoBarDelegate::GetInfoBarType() const { | 21 GroupedPermissionInfoBarDelegate::GetInfoBarType() const { |
| 22 return PAGE_ACTION_TYPE; | 22 return PAGE_ACTION_TYPE; |
| 23 } | 23 } |
| 24 | 24 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 35 return ConfirmInfoBarDelegate::GetButtonLabel(button); | 35 return ConfirmInfoBarDelegate::GetButtonLabel(button); |
| 36 } else { | 36 } else { |
| 37 return l10n_util::GetStringUTF16( | 37 return l10n_util::GetStringUTF16( |
| 38 (button == BUTTON_OK) ? IDS_PERMISSION_ALLOW : IDS_PERMISSION_DENY); | 38 (button == BUTTON_OK) ? IDS_PERMISSION_ALLOW : IDS_PERMISSION_DENY); |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 base::string16 GroupedPermissionInfoBarDelegate::GetMessageText() const { | 42 base::string16 GroupedPermissionInfoBarDelegate::GetMessageText() const { |
| 43 return l10n_util::GetStringFUTF16( | 43 return l10n_util::GetStringFUTF16( |
| 44 IDS_PERMISSIONS_BUBBLE_PROMPT, | 44 IDS_PERMISSIONS_BUBBLE_PROMPT, |
| 45 url_formatter::FormatUrlForSecurityDisplay(requesting_origin_)); | 45 url_formatter::FormatUrlForSecurityDisplay(requesting_origin())); |
| 46 } | 46 } |
| 47 | 47 |
| 48 int GroupedPermissionInfoBarDelegate::GetPermissionCount() const { | 48 int GroupedPermissionInfoBarDelegate::GetPermissionCount() const { |
| 49 return types_.size(); | 49 return types_.size(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 ContentSettingsType GroupedPermissionInfoBarDelegate::GetContentSettingType( | 52 ContentSettingsType GroupedPermissionInfoBarDelegate::GetContentSettingType( |
| 53 int index) const { | 53 int index) const { |
| 54 DCHECK(index >= 0 && index < static_cast<int>(types_.size())); | 54 DCHECK(index >= 0 && index < static_cast<int>(types_.size())); |
| 55 return types_[index]; | 55 return types_[index]; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 85 void GroupedPermissionInfoBarDelegate::ToggleAccept(int position, | 85 void GroupedPermissionInfoBarDelegate::ToggleAccept(int position, |
| 86 bool new_value) { | 86 bool new_value) { |
| 87 DCHECK(position >= 0 && position < static_cast<int>(types_.size())); | 87 DCHECK(position >= 0 && position < static_cast<int>(types_.size())); |
| 88 accept_states_[position] = new_value; | 88 accept_states_[position] = new_value; |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool GroupedPermissionInfoBarDelegate::GetAcceptState(int position) { | 91 bool GroupedPermissionInfoBarDelegate::GetAcceptState(int position) { |
| 92 DCHECK(position >= 0 && position < static_cast<int>(types_.size())); | 92 DCHECK(position >= 0 && position < static_cast<int>(types_.size())); |
| 93 return accept_states_[position]; | 93 return accept_states_[position]; |
| 94 } | 94 } |
| OLD | NEW |