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