| 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_android
.h" | 5 #include "chrome/browser/permissions/grouped_permission_infobar_delegate_android
.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/android/android_theme_resources.h" | 8 #include "chrome/browser/android/android_theme_resources.h" |
| 9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
| 10 #include "chrome/browser/permissions/permission_prompt_android.h" | 10 #include "chrome/browser/permissions/permission_prompt_android.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 bool GroupedPermissionInfoBarDelegate::ShouldShowPersistenceToggle() const { | 36 bool GroupedPermissionInfoBarDelegate::ShouldShowPersistenceToggle() const { |
| 37 return permission_prompt_->ShouldShowPersistenceToggle(); | 37 return permission_prompt_->ShouldShowPersistenceToggle(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 ContentSettingsType GroupedPermissionInfoBarDelegate::GetContentSettingType( | 40 ContentSettingsType GroupedPermissionInfoBarDelegate::GetContentSettingType( |
| 41 size_t position) const { | 41 size_t position) const { |
| 42 return permission_prompt_->GetContentSettingType(position); | 42 return permission_prompt_->GetContentSettingType(position); |
| 43 } | 43 } |
| 44 | 44 |
| 45 int GroupedPermissionInfoBarDelegate::GetIconIdForPermission( | 45 int GroupedPermissionInfoBarDelegate::GetIconId() const { |
| 46 size_t position) const { | 46 return permission_prompt_->GetIconId(); |
| 47 return permission_prompt_->GetIconIdForPermission(position); | |
| 48 } | |
| 49 | |
| 50 base::string16 GroupedPermissionInfoBarDelegate::GetMessageTextFragment( | |
| 51 size_t position) const { | |
| 52 return permission_prompt_->GetMessageTextFragment(position); | |
| 53 } | 47 } |
| 54 | 48 |
| 55 base::string16 GroupedPermissionInfoBarDelegate::GetMessageText() const { | 49 base::string16 GroupedPermissionInfoBarDelegate::GetMessageText() const { |
| 56 return l10n_util::GetStringFUTF16( | 50 return permission_prompt_->GetMessageText(); |
| 57 IDS_PERMISSIONS_BUBBLE_PROMPT, | |
| 58 url_formatter::FormatUrlForSecurityDisplay(requesting_origin_)); | |
| 59 } | 51 } |
| 60 | 52 |
| 61 bool GroupedPermissionInfoBarDelegate::Accept() { | 53 bool GroupedPermissionInfoBarDelegate::Accept() { |
| 62 if (permission_prompt_) { | 54 if (permission_prompt_) { |
| 63 if (permission_prompt_->ShouldShowPersistenceToggle()) | 55 if (permission_prompt_->ShouldShowPersistenceToggle()) |
| 64 permission_prompt_->TogglePersist(persist_); | 56 permission_prompt_->TogglePersist(persist_); |
| 65 permission_prompt_->Accept(); | 57 permission_prompt_->Accept(); |
| 66 } | 58 } |
| 67 return true; | 59 return true; |
| 68 } | 60 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 98 GroupedPermissionInfoBarDelegate::GetIdentifier() const { | 90 GroupedPermissionInfoBarDelegate::GetIdentifier() const { |
| 99 return GROUPED_PERMISSION_INFOBAR_DELEGATE_ANDROID; | 91 return GROUPED_PERMISSION_INFOBAR_DELEGATE_ANDROID; |
| 100 } | 92 } |
| 101 | 93 |
| 102 infobars::InfoBarDelegate::Type | 94 infobars::InfoBarDelegate::Type |
| 103 GroupedPermissionInfoBarDelegate::GetInfoBarType() const { | 95 GroupedPermissionInfoBarDelegate::GetInfoBarType() const { |
| 104 return PAGE_ACTION_TYPE; | 96 return PAGE_ACTION_TYPE; |
| 105 } | 97 } |
| 106 | 98 |
| 107 int GroupedPermissionInfoBarDelegate::GetButtons() const { | 99 int GroupedPermissionInfoBarDelegate::GetButtons() const { |
| 108 // If there is only one permission in the infobar, we show both OK and CANCEL | 100 return BUTTON_OK | BUTTON_CANCEL; |
| 109 // button to allow/deny it. If there are multiple, we only show OK button | |
| 110 // which means making decision for all permissions according to each accept | |
| 111 // toggle. | |
| 112 return (PermissionCount() > 1) ? BUTTON_OK : (BUTTON_OK | BUTTON_CANCEL); | |
| 113 } | 101 } |
| 114 | 102 |
| 115 base::string16 GroupedPermissionInfoBarDelegate::GetButtonLabel( | 103 base::string16 GroupedPermissionInfoBarDelegate::GetButtonLabel( |
| 116 InfoBarButton button) const { | 104 InfoBarButton button) const { |
| 117 if (PermissionCount() > 1) { | |
| 118 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_APP_OK | |
| 119 : IDS_APP_CANCEL); | |
| 120 } | |
| 121 | |
| 122 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_PERMISSION_ALLOW | 105 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_PERMISSION_ALLOW |
| 123 : IDS_PERMISSION_DENY); | 106 : IDS_PERMISSION_DENY); |
| 124 } | 107 } |
| 125 | 108 |
| 126 GURL GroupedPermissionInfoBarDelegate::GetLinkURL() const { | 109 GURL GroupedPermissionInfoBarDelegate::GetLinkURL() const { |
| 127 return permission_prompt_->GetLinkURL(); | 110 return permission_prompt_->GetLinkURL(); |
| 128 } | 111 } |
| 129 | 112 |
| 130 bool GroupedPermissionInfoBarDelegate::EqualsDelegate( | 113 bool GroupedPermissionInfoBarDelegate::EqualsDelegate( |
| 131 infobars::InfoBarDelegate* delegate) const { | 114 infobars::InfoBarDelegate* delegate) const { |
| 132 // The PermissionRequestManager doesn't create duplicate infobars so a pointer | 115 // The PermissionRequestManager doesn't create duplicate infobars so a pointer |
| 133 // equality check is sufficient. | 116 // equality check is sufficient. |
| 134 return this == delegate; | 117 return this == delegate; |
| 135 } | 118 } |
| OLD | NEW |