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" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 infobars::InfoBarDelegate::Type | 28 infobars::InfoBarDelegate::Type |
29 PermissionInfobarDelegate::GetInfoBarType() const { | 29 PermissionInfobarDelegate::GetInfoBarType() const { |
30 return PAGE_ACTION_TYPE; | 30 return PAGE_ACTION_TYPE; |
31 } | 31 } |
32 | 32 |
33 void PermissionInfobarDelegate::InfoBarDismissed() { | 33 void PermissionInfobarDelegate::InfoBarDismissed() { |
34 SetPermission(false, false); | 34 SetPermission(false, false); |
35 } | 35 } |
36 | 36 |
| 37 PermissionInfobarDelegate* |
| 38 PermissionInfobarDelegate::AsPermissionInfobarDelegate() { |
| 39 return this; |
| 40 } |
| 41 |
37 base::string16 PermissionInfobarDelegate::GetButtonLabel( | 42 base::string16 PermissionInfobarDelegate::GetButtonLabel( |
38 InfoBarButton button) const { | 43 InfoBarButton button) const { |
39 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 44 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
40 IDS_PERMISSION_ALLOW : IDS_PERMISSION_DENY); | 45 IDS_PERMISSION_ALLOW : IDS_PERMISSION_DENY); |
41 } | 46 } |
42 | 47 |
43 bool PermissionInfobarDelegate::Accept() { | 48 bool PermissionInfobarDelegate::Accept() { |
44 SetPermission(true, true); | 49 SetPermission(true, true); |
45 return true; | 50 return true; |
46 } | 51 } |
47 | 52 |
48 bool PermissionInfobarDelegate::Cancel() { | 53 bool PermissionInfobarDelegate::Cancel() { |
49 SetPermission(true, false); | 54 SetPermission(true, false); |
50 return true; | 55 return true; |
51 } | 56 } |
52 | 57 |
53 void PermissionInfobarDelegate::SetPermission(bool update_content_setting, | 58 void PermissionInfobarDelegate::SetPermission(bool update_content_setting, |
54 bool allowed) { | 59 bool allowed) { |
55 action_taken_ = true; | 60 action_taken_ = true; |
56 controller_->OnPermissionSet( | 61 controller_->OnPermissionSet( |
57 id_, requesting_origin_, | 62 id_, requesting_origin_, |
58 InfoBarService::WebContentsFromInfoBar( | 63 InfoBarService::WebContentsFromInfoBar( |
59 infobar())->GetLastCommittedURL().GetOrigin(), | 64 infobar())->GetLastCommittedURL().GetOrigin(), |
60 update_content_setting, allowed); | 65 update_content_setting, allowed); |
61 } | 66 } |
OLD | NEW |