Chromium Code Reviews| Index: chrome/browser/permissions/single_permission_infobar_delegate.cc |
| diff --git a/chrome/browser/permissions/permission_infobar_delegate.cc b/chrome/browser/permissions/single_permission_infobar_delegate.cc |
| similarity index 62% |
| copy from chrome/browser/permissions/permission_infobar_delegate.cc |
| copy to chrome/browser/permissions/single_permission_infobar_delegate.cc |
| index 71854695f3a512e5bc49cf7cd5922aac0c7e76ee..07eb185313b565272cf58a5ea76e4c75d828333a 100644 |
| --- a/chrome/browser/permissions/permission_infobar_delegate.cc |
| +++ b/chrome/browser/permissions/single_permission_infobar_delegate.cc |
| @@ -2,47 +2,53 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/permissions/permission_infobar_delegate.h" |
| +#include "chrome/browser/permissions/single_permission_infobar_delegate.h" |
| #include "base/feature_list.h" |
| #include "chrome/browser/permissions/permission_decision_auto_blocker.h" |
| #include "chrome/browser/permissions/permission_request.h" |
| #include "chrome/browser/permissions/permission_uma_util.h" |
| +#include "chrome/browser/profiles/profile.h" |
| #include "chrome/common/chrome_features.h" |
| #include "chrome/grit/generated_resources.h" |
| #include "components/url_formatter/elide_url.h" |
| #include "ui/base/l10n/l10n_util.h" |
| -PermissionInfobarDelegate::~PermissionInfobarDelegate() { |
| +SinglePermissionInfoBarDelegate::~SinglePermissionInfoBarDelegate() { |
| if (!action_taken_) { |
| - PermissionDecisionAutoBlocker(profile_).RecordIgnore(requesting_origin_, |
| + PermissionDecisionAutoBlocker(profile_).RecordIgnore(requesting_origin(), |
| permission_type_); |
| PermissionUmaUtil::PermissionIgnored( |
| permission_type_, |
| user_gesture_ ? PermissionRequestGestureType::GESTURE |
| : PermissionRequestGestureType::NO_GESTURE, |
| - requesting_origin_, profile_); |
| + requesting_origin(), profile_); |
| } |
| } |
| -PermissionInfobarDelegate::PermissionInfobarDelegate( |
| +SinglePermissionInfoBarDelegate::SinglePermissionInfoBarDelegate( |
| const GURL& requesting_origin, |
| content::PermissionType permission_type, |
| ContentSettingsType content_settings_type, |
| bool user_gesture, |
| Profile* profile, |
| const PermissionSetCallback& callback) |
| - : requesting_origin_(requesting_origin), |
| + : PermissionInfoBarDelegate(requesting_origin), |
| permission_type_(permission_type), |
| content_settings_type_(content_settings_type), |
| profile_(profile), |
| callback_(callback), |
| action_taken_(false), |
| - user_gesture_(user_gesture), |
| - persist_(true) {} |
| + user_gesture_(user_gesture) {} |
| -bool PermissionInfobarDelegate::ShouldShowPersistenceToggle() const { |
| +ContentSettingsType SinglePermissionInfoBarDelegate::GetContentSettingType( |
| + int index) const { |
| + DCHECK_EQ(0, index); |
| + return content_settings_type_; |
| +} |
| + |
| +bool SinglePermissionInfoBarDelegate::ShouldShowPersistenceToggle() const { |
| // Only show the persistence toggle for geolocation. |
| if (permission_type_ == content::PermissionType::GEOLOCATION) { |
| return base::FeatureList::IsEnabled( |
| @@ -51,60 +57,44 @@ bool PermissionInfobarDelegate::ShouldShowPersistenceToggle() const { |
| return false; |
| } |
| -base::string16 PermissionInfobarDelegate::GetMessageText() const { |
| +base::string16 SinglePermissionInfoBarDelegate::GetMessageText() const { |
| return l10n_util::GetStringFUTF16( |
| GetMessageResourceId(), |
| url_formatter::FormatUrlForSecurityDisplay( |
| - requesting_origin_, |
| + requesting_origin(), |
| url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); |
| } |
| -infobars::InfoBarDelegate::Type PermissionInfobarDelegate::GetInfoBarType() |
| - const { |
| - return PAGE_ACTION_TYPE; |
| -} |
| - |
| -void PermissionInfobarDelegate::InfoBarDismissed() { |
| - SetPermission(false, DISMISSED); |
| -} |
| - |
| -PermissionInfobarDelegate* |
| -PermissionInfobarDelegate::AsPermissionInfobarDelegate() { |
| - return this; |
| +void SinglePermissionInfoBarDelegate::SetPermission(bool update_content_setting, |
| + PermissionAction decision) { |
|
raymes
2016/08/17 03:36:40
nit: indentation. git cl format should catch this?
|
| + action_taken_ = true; |
| + callback_.Run(update_content_setting, decision); |
| } |
| -base::string16 PermissionInfobarDelegate::GetButtonLabel( |
| +base::string16 SinglePermissionInfoBarDelegate::GetButtonLabel( |
| InfoBarButton button) const { |
| return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| IDS_PERMISSION_ALLOW : IDS_PERMISSION_DENY); |
| } |
| -bool PermissionInfobarDelegate::Accept() { |
| +bool SinglePermissionInfoBarDelegate::Accept() { |
| bool update_content_setting = true; |
| - if (ShouldShowPersistenceToggle()) { |
| - update_content_setting = persist_; |
| - PermissionUmaUtil::PermissionPromptAcceptedWithPersistenceToggle( |
|
raymes
2016/08/17 03:36:40
We're not calling this from anywhere anymore?
|
| - permission_type_, persist_); |
| - } |
| + if (ShouldShowPersistenceToggle()) |
| + update_content_setting = persist(); |
| SetPermission(update_content_setting, GRANTED); |
| return true; |
| } |
| -bool PermissionInfobarDelegate::Cancel() { |
| +bool SinglePermissionInfoBarDelegate::Cancel() { |
| bool update_content_setting = true; |
| - if (ShouldShowPersistenceToggle()) { |
| - update_content_setting = persist_; |
| - PermissionUmaUtil::PermissionPromptDeniedWithPersistenceToggle( |
| - permission_type_, persist_); |
| - } |
| + if (ShouldShowPersistenceToggle()) |
| + update_content_setting = persist(); |
| SetPermission(update_content_setting, DENIED); |
| return true; |
| } |
| -void PermissionInfobarDelegate::SetPermission(bool update_content_setting, |
| - PermissionAction decision) { |
| - action_taken_ = true; |
| - callback_.Run(update_content_setting, decision); |
| +void SinglePermissionInfoBarDelegate::InfoBarDismissed() { |
| + SetPermission(false, DISMISSED); |
| } |