OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/page_info/page_info.h" | 5 #include "chrome/browser/ui/page_info/page_info.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 namespace { | 85 namespace { |
86 | 86 |
87 // Events for UMA. Do not reorder or change! | 87 // Events for UMA. Do not reorder or change! |
88 enum SSLCertificateDecisionsDidRevoke { | 88 enum SSLCertificateDecisionsDidRevoke { |
89 USER_CERT_DECISIONS_NOT_REVOKED = 0, | 89 USER_CERT_DECISIONS_NOT_REVOKED = 0, |
90 USER_CERT_DECISIONS_REVOKED, | 90 USER_CERT_DECISIONS_REVOKED, |
91 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM | 91 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM |
92 }; | 92 }; |
93 | 93 |
94 // The list of content settings types to display on the Page Info UI. THE | 94 // The list of content settings types to display on the Page Info UI. THE |
95 // ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, email | 95 // ORDER OF THESE ITEMS IS IMPORTANT and comes from https://crbug.com/610358. To |
96 // security-dev@chromium.org. | 96 // propose changing it, email security-dev@chromium.org. |
97 ContentSettingsType kPermissionType[] = { | 97 ContentSettingsType kPermissionType[] = { |
98 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 98 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
99 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | 99 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
100 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | 100 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
101 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 101 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
102 CONTENT_SETTINGS_TYPE_JAVASCRIPT, | 102 CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
103 #if !defined(OS_ANDROID) | 103 #if !defined(OS_ANDROID) |
104 CONTENT_SETTINGS_TYPE_PLUGINS, | 104 CONTENT_SETTINGS_TYPE_PLUGINS, |
105 CONTENT_SETTINGS_TYPE_IMAGES, | 105 CONTENT_SETTINGS_TYPE_IMAGES, |
106 #endif | 106 #endif |
107 CONTENT_SETTINGS_TYPE_POPUPS, | 107 CONTENT_SETTINGS_TYPE_POPUPS, |
| 108 CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER, |
108 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, | 109 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, |
109 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, | 110 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, |
110 CONTENT_SETTINGS_TYPE_AUTOPLAY, | 111 CONTENT_SETTINGS_TYPE_AUTOPLAY, |
111 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, | 112 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, |
112 CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER, | |
113 }; | 113 }; |
114 | 114 |
115 // Determines whether to show permission |type| in the Page Info UI. Only | 115 // Determines whether to show permission |type| in the Page Info UI. Only |
116 // applies to permissions listed in |kPermissionType|. | 116 // applies to permissions listed in |kPermissionType|. |
117 bool ShouldShowPermission(ContentSettingsType type) { | 117 bool ShouldShowPermission(ContentSettingsType type, |
| 118 const GURL& site_url, |
| 119 HostContentSettingsMap* content_settings) { |
118 #if !defined(OS_ANDROID) | 120 #if !defined(OS_ANDROID) |
119 // Autoplay is Android-only at the moment. | 121 // Autoplay is Android-only at the moment. |
120 if (type == CONTENT_SETTINGS_TYPE_AUTOPLAY) | 122 if (type == CONTENT_SETTINGS_TYPE_AUTOPLAY) |
121 return false; | 123 return false; |
122 #endif | 124 #endif |
123 | 125 |
124 if (type == CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER) { | 126 if (type == CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER) { |
125 return base::FeatureList::IsEnabled( | 127 if (!base::FeatureList::IsEnabled( |
126 subresource_filter::kSafeBrowsingSubresourceFilterExperimentalUI); | 128 subresource_filter::kSafeBrowsingSubresourceFilterExperimentalUI)) { |
| 129 return false; |
| 130 } |
| 131 |
| 132 // The setting for subresource filtering should not show up if the site is |
| 133 // not activated, both on android and desktop platforms. |
| 134 return content_settings->GetWebsiteSetting( |
| 135 site_url, GURL(), CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER_DATA, |
| 136 std::string(), nullptr) != nullptr; |
127 } | 137 } |
128 | 138 |
129 return true; | 139 return true; |
130 } | 140 } |
131 | 141 |
132 void CheckContentStatus(security_state::ContentStatus content_status, | 142 void CheckContentStatus(security_state::ContentStatus content_status, |
133 bool* displayed, | 143 bool* displayed, |
134 bool* ran) { | 144 bool* ran) { |
135 switch (content_status) { | 145 switch (content_status) { |
136 case security_state::CONTENT_STATUS_DISPLAYED: | 146 case security_state::CONTENT_STATUS_DISPLAYED: |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 } | 668 } |
659 | 669 |
660 void PageInfo::PresentSitePermissions() { | 670 void PageInfo::PresentSitePermissions() { |
661 PermissionInfoList permission_info_list; | 671 PermissionInfoList permission_info_list; |
662 ChosenObjectInfoList chosen_object_info_list; | 672 ChosenObjectInfoList chosen_object_info_list; |
663 | 673 |
664 PageInfoUI::PermissionInfo permission_info; | 674 PageInfoUI::PermissionInfo permission_info; |
665 for (size_t i = 0; i < arraysize(kPermissionType); ++i) { | 675 for (size_t i = 0; i < arraysize(kPermissionType); ++i) { |
666 permission_info.type = kPermissionType[i]; | 676 permission_info.type = kPermissionType[i]; |
667 | 677 |
668 if (!ShouldShowPermission(permission_info.type)) | 678 if (!ShouldShowPermission(permission_info.type, site_url_, |
| 679 content_settings_)) { |
669 continue; | 680 continue; |
| 681 } |
670 | 682 |
671 content_settings::SettingInfo info; | 683 content_settings::SettingInfo info; |
672 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting( | 684 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting( |
673 site_url_, site_url_, permission_info.type, std::string(), &info); | 685 site_url_, site_url_, permission_info.type, std::string(), &info); |
674 DCHECK(value.get()); | 686 DCHECK(value.get()); |
675 if (value->GetType() == base::Value::Type::INTEGER) { | 687 if (value->GetType() == base::Value::Type::INTEGER) { |
676 permission_info.setting = | 688 permission_info.setting = |
677 content_settings::ValueToContentSetting(value.get()); | 689 content_settings::ValueToContentSetting(value.get()); |
678 } else { | 690 } else { |
679 NOTREACHED(); | 691 NOTREACHED(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_)); | 779 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_)); |
768 | 780 |
769 info.connection_status = site_connection_status_; | 781 info.connection_status = site_connection_status_; |
770 info.connection_status_description = UTF16ToUTF8(site_connection_details_); | 782 info.connection_status_description = UTF16ToUTF8(site_connection_details_); |
771 info.identity_status = site_identity_status_; | 783 info.identity_status = site_identity_status_; |
772 info.identity_status_description = UTF16ToUTF8(site_identity_details_); | 784 info.identity_status_description = UTF16ToUTF8(site_identity_details_); |
773 info.certificate = certificate_; | 785 info.certificate = certificate_; |
774 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; | 786 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; |
775 ui_->SetIdentityInfo(info); | 787 ui_->SetIdentityInfo(info); |
776 } | 788 } |
OLD | NEW |