Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / permissions / permission_infobar_delegate.cc
blob418f03c62f55c8715c05dc1e0da4de1840be917b
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/browser/permissions/permission_queue_controller.h"
9 #include "chrome/grit/generated_resources.h"
10 #include "components/infobars/core/infobar.h"
11 #include "ui/base/l10n/l10n_util.h"
13 PermissionInfobarDelegate::~PermissionInfobarDelegate() {
14 if (!action_taken_)
15 PermissionContextUmaUtil::PermissionIgnored(type_, requesting_origin_);
18 PermissionInfobarDelegate::PermissionInfobarDelegate(
19 PermissionQueueController* controller,
20 const PermissionRequestID& id,
21 const GURL& requesting_origin,
22 ContentSettingsType type)
23 : controller_(controller), id_(id), requesting_origin_(requesting_origin),
24 action_taken_(false),
25 type_(type) {
28 infobars::InfoBarDelegate::Type
29 PermissionInfobarDelegate::GetInfoBarType() const {
30 return PAGE_ACTION_TYPE;
33 void PermissionInfobarDelegate::InfoBarDismissed() {
34 SetPermission(false, false);
37 PermissionInfobarDelegate*
38 PermissionInfobarDelegate::AsPermissionInfobarDelegate() {
39 return this;
42 base::string16 PermissionInfobarDelegate::GetButtonLabel(
43 InfoBarButton button) const {
44 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
45 IDS_PERMISSION_ALLOW : IDS_PERMISSION_DENY);
48 bool PermissionInfobarDelegate::Accept() {
49 SetPermission(true, true);
50 return true;
53 bool PermissionInfobarDelegate::Cancel() {
54 SetPermission(true, false);
55 return true;
58 void PermissionInfobarDelegate::SetPermission(bool update_content_setting,
59 bool allowed) {
60 action_taken_ = true;
61 controller_->OnPermissionSet(
62 id_, requesting_origin_,
63 InfoBarService::WebContentsFromInfoBar(
64 infobar())->GetLastCommittedURL().GetOrigin(),
65 update_content_setting, allowed);