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/permissions/permission_infobar_delegate.h" | 5 #include "chrome/browser/permissions/permission_infobar_delegate.h" |
6 | 6 |
7 #include "chrome/browser/permissions/permission_uma_util.h" | 7 #include "chrome/browser/permissions/permission_uma_util.h" |
8 #include "chrome/grit/generated_resources.h" | 8 #include "chrome/grit/generated_resources.h" |
9 #include "components/infobars/core/infobar.h" | 9 #include "components/infobars/core/infobar.h" |
10 #include "components/url_formatter/elide_url.h" | 10 #include "components/url_formatter/elide_url.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 // TODO(stefanocs): Pass in a non null profile. | |
16 PermissionUmaUtil::PermissionIgnored(permission_type_, requesting_origin_, | 15 PermissionUmaUtil::PermissionIgnored(permission_type_, requesting_origin_, |
17 nullptr); | 16 profile_); |
18 } | 17 } |
19 | 18 |
20 PermissionInfobarDelegate::PermissionInfobarDelegate( | 19 PermissionInfobarDelegate::PermissionInfobarDelegate( |
21 const GURL& requesting_origin, | 20 const GURL& requesting_origin, |
22 content::PermissionType permission_type, | 21 content::PermissionType permission_type, |
23 ContentSettingsType content_settings_type, | 22 ContentSettingsType content_settings_type, |
| 23 Profile* profile, |
24 const base::Callback<void(bool, bool)>& callback) | 24 const base::Callback<void(bool, bool)>& callback) |
25 : requesting_origin_(requesting_origin), | 25 : requesting_origin_(requesting_origin), |
26 action_taken_(false), | 26 action_taken_(false), |
27 permission_type_(permission_type), | 27 permission_type_(permission_type), |
28 content_settings_type_(content_settings_type), | 28 content_settings_type_(content_settings_type), |
| 29 profile_(profile), |
29 callback_(callback) {} | 30 callback_(callback) {} |
30 | 31 |
31 base::string16 PermissionInfobarDelegate::GetMessageText() const { | 32 base::string16 PermissionInfobarDelegate::GetMessageText() const { |
32 return l10n_util::GetStringFUTF16( | 33 return l10n_util::GetStringFUTF16( |
33 GetMessageResourceId(), | 34 GetMessageResourceId(), |
34 url_formatter::FormatUrlForSecurityDisplay( | 35 url_formatter::FormatUrlForSecurityDisplay( |
35 requesting_origin_, | 36 requesting_origin_, |
36 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); | 37 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); |
37 } | 38 } |
38 | 39 |
(...skipping 25 matching lines...) Expand all Loading... |
64 bool PermissionInfobarDelegate::Cancel() { | 65 bool PermissionInfobarDelegate::Cancel() { |
65 SetPermission(true, false); | 66 SetPermission(true, false); |
66 return true; | 67 return true; |
67 } | 68 } |
68 | 69 |
69 void PermissionInfobarDelegate::SetPermission(bool update_content_setting, | 70 void PermissionInfobarDelegate::SetPermission(bool update_content_setting, |
70 bool allowed) { | 71 bool allowed) { |
71 action_taken_ = true; | 72 action_taken_ = true; |
72 callback_.Run(update_content_setting, allowed); | 73 callback_.Run(update_content_setting, allowed); |
73 } | 74 } |
OLD | NEW |