1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/permissions/permission_infobar_delegate.h"
7 #include "chrome/browser/permissions/permission_context_uma_util.h"
8 #include "chrome/grit/generated_resources.h"
9 #include "components/infobars/core/infobar.h"
10 #include "ui/base/l10n/l10n_util.h"
12 PermissionInfobarDelegate::~PermissionInfobarDelegate() {
14 PermissionContextUmaUtil::PermissionIgnored(type_
, requesting_origin_
);
17 PermissionInfobarDelegate::PermissionInfobarDelegate(
18 const GURL
& requesting_origin
,
19 ContentSettingsType type
,
20 const base::Callback
<void(bool, bool)>& callback
)
21 : requesting_origin_(requesting_origin
),
27 infobars::InfoBarDelegate::Type
28 PermissionInfobarDelegate::GetInfoBarType() const {
29 return PAGE_ACTION_TYPE
;
32 void PermissionInfobarDelegate::InfoBarDismissed() {
33 SetPermission(false, false);
36 PermissionInfobarDelegate
*
37 PermissionInfobarDelegate::AsPermissionInfobarDelegate() {
41 base::string16
PermissionInfobarDelegate::GetButtonLabel(
42 InfoBarButton button
) const {
43 return l10n_util::GetStringUTF16((button
== BUTTON_OK
) ?
44 IDS_PERMISSION_ALLOW
: IDS_PERMISSION_DENY
);
47 bool PermissionInfobarDelegate::Accept() {
48 SetPermission(true, true);
52 bool PermissionInfobarDelegate::Cancel() {
53 SetPermission(true, false);
57 void PermissionInfobarDelegate::SetPermission(bool update_content_setting
,
60 callback_
.Run(update_content_setting
, allowed
);