OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/content_settings/permission_infobar_delegate.h" | 5 #include "chrome/browser/content_settings/permission_infobar_delegate.h" |
6 | 6 |
| 7 #include "chrome/browser/content_settings/permission_context_uma_util.h" |
7 #include "chrome/browser/content_settings/permission_queue_controller.h" | 8 #include "chrome/browser/content_settings/permission_queue_controller.h" |
8 #include "components/infobars/core/infobar.h" | 9 #include "components/infobars/core/infobar.h" |
9 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
10 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
11 | 12 |
12 PermissionInfobarDelegate::~PermissionInfobarDelegate() { | 13 PermissionInfobarDelegate::~PermissionInfobarDelegate() { |
| 14 if (!action_taken_) |
| 15 PermissionContextUmaUtil::PermissionIgnored(type_); |
13 } | 16 } |
14 | 17 |
15 PermissionInfobarDelegate::PermissionInfobarDelegate( | 18 PermissionInfobarDelegate::PermissionInfobarDelegate( |
16 PermissionQueueController* controller, | 19 PermissionQueueController* controller, |
17 const PermissionRequestID& id, | 20 const PermissionRequestID& id, |
18 const GURL& requesting_origin) | 21 const GURL& requesting_origin, |
19 : controller_(controller), id_(id), requesting_origin_(requesting_origin) { | 22 ContentSettingsType type) |
| 23 : controller_(controller), id_(id), requesting_origin_(requesting_origin), |
| 24 action_taken_(false), |
| 25 type_(type) { |
20 } | 26 } |
21 | 27 |
22 void PermissionInfobarDelegate::InfoBarDismissed() { | 28 void PermissionInfobarDelegate::InfoBarDismissed() { |
23 SetPermission(false, false); | 29 SetPermission(false, false); |
24 } | 30 } |
25 | 31 |
26 infobars::InfoBarDelegate::Type | 32 infobars::InfoBarDelegate::Type |
27 PermissionInfobarDelegate::GetInfoBarType() const { | 33 PermissionInfobarDelegate::GetInfoBarType() const { |
28 return PAGE_ACTION_TYPE; | 34 return PAGE_ACTION_TYPE; |
29 } | 35 } |
30 | 36 |
31 base::string16 PermissionInfobarDelegate::GetButtonLabel( | 37 base::string16 PermissionInfobarDelegate::GetButtonLabel( |
32 InfoBarButton button) const { | 38 InfoBarButton button) const { |
33 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 39 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
34 IDS_PERMISSION_ALLOW : IDS_PERMISSION_DENY); | 40 IDS_PERMISSION_ALLOW : IDS_PERMISSION_DENY); |
35 } | 41 } |
36 | 42 |
37 bool PermissionInfobarDelegate::Accept() { | 43 bool PermissionInfobarDelegate::Accept() { |
38 SetPermission(true, true); | 44 SetPermission(true, true); |
39 return true; | 45 return true; |
40 } | 46 } |
41 | 47 |
42 bool PermissionInfobarDelegate::Cancel() { | 48 bool PermissionInfobarDelegate::Cancel() { |
43 SetPermission(true, false); | 49 SetPermission(true, false); |
44 return true; | 50 return true; |
45 } | 51 } |
46 | 52 |
47 void PermissionInfobarDelegate::SetPermission(bool update_content_setting, | 53 void PermissionInfobarDelegate::SetPermission(bool update_content_setting, |
48 bool allowed) { | 54 bool allowed) { |
| 55 action_taken_ = true; |
49 controller_->OnPermissionSet( | 56 controller_->OnPermissionSet( |
50 id_, requesting_origin_, | 57 id_, requesting_origin_, |
51 InfoBarService::WebContentsFromInfoBar( | 58 InfoBarService::WebContentsFromInfoBar( |
52 infobar())->GetLastCommittedURL().GetOrigin(), | 59 infobar())->GetLastCommittedURL().GetOrigin(), |
53 update_content_setting, allowed); | 60 update_content_setting, allowed); |
54 } | 61 } |
OLD | NEW |