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() { |
29 RegisterActionTaken(); | |
23 SetPermission(false, false); | 30 SetPermission(false, false); |
24 } | 31 } |
25 | 32 |
26 infobars::InfoBarDelegate::Type | 33 infobars::InfoBarDelegate::Type |
27 PermissionInfobarDelegate::GetInfoBarType() const { | 34 PermissionInfobarDelegate::GetInfoBarType() const { |
28 return PAGE_ACTION_TYPE; | 35 return PAGE_ACTION_TYPE; |
29 } | 36 } |
30 | 37 |
31 base::string16 PermissionInfobarDelegate::GetButtonLabel( | 38 base::string16 PermissionInfobarDelegate::GetButtonLabel( |
32 InfoBarButton button) const { | 39 InfoBarButton button) const { |
33 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 40 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
34 IDS_PERMISSION_ALLOW : IDS_PERMISSION_DENY); | 41 IDS_PERMISSION_ALLOW : IDS_PERMISSION_DENY); |
35 } | 42 } |
36 | 43 |
37 bool PermissionInfobarDelegate::Accept() { | 44 bool PermissionInfobarDelegate::Accept() { |
45 RegisterActionTaken(); | |
Bernhard Bauer
2014/07/14 15:22:15
You could probably move this into SetPermission().
Miguel Garcia
2014/07/14 16:57:50
I have actually removed the RegisterActionTaken ca
| |
38 SetPermission(true, true); | 46 SetPermission(true, true); |
39 return true; | 47 return true; |
40 } | 48 } |
41 | 49 |
42 bool PermissionInfobarDelegate::Cancel() { | 50 bool PermissionInfobarDelegate::Cancel() { |
51 RegisterActionTaken(); | |
43 SetPermission(true, false); | 52 SetPermission(true, false); |
44 return true; | 53 return true; |
45 } | 54 } |
46 | 55 |
47 void PermissionInfobarDelegate::SetPermission(bool update_content_setting, | 56 void PermissionInfobarDelegate::SetPermission(bool update_content_setting, |
48 bool allowed) { | 57 bool allowed) { |
49 controller_->OnPermissionSet( | 58 controller_->OnPermissionSet( |
50 id_, requesting_origin_, | 59 id_, requesting_origin_, |
51 InfoBarService::WebContentsFromInfoBar( | 60 InfoBarService::WebContentsFromInfoBar( |
52 infobar())->GetLastCommittedURL().GetOrigin(), | 61 infobar())->GetLastCommittedURL().GetOrigin(), |
53 update_content_setting, allowed); | 62 update_content_setting, allowed); |
54 } | 63 } |
OLD | NEW |