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)) |
raymes
2017/05/10 23:53:51
nit: {}
Charlie Harrison
2017/05/11 14:10:47
Done.
| |
129 return false; | |
130 | |
131 // The setting for subresource filtering should not show up if the site is | |
132 // not activated, both on android and desktop platforms. | |
133 return content_settings->GetWebsiteSetting( | |
134 site_url, GURL(), CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER_DATA, | |
135 std::string(), nullptr) != nullptr; | |
127 } | 136 } |
128 | 137 |
129 return true; | 138 return true; |
130 } | 139 } |
131 | 140 |
132 void CheckContentStatus(security_state::ContentStatus content_status, | 141 void CheckContentStatus(security_state::ContentStatus content_status, |
133 bool* displayed, | 142 bool* displayed, |
134 bool* ran) { | 143 bool* ran) { |
135 switch (content_status) { | 144 switch (content_status) { |
136 case security_state::CONTENT_STATUS_DISPLAYED: | 145 case security_state::CONTENT_STATUS_DISPLAYED: |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
658 } | 667 } |
659 | 668 |
660 void PageInfo::PresentSitePermissions() { | 669 void PageInfo::PresentSitePermissions() { |
661 PermissionInfoList permission_info_list; | 670 PermissionInfoList permission_info_list; |
662 ChosenObjectInfoList chosen_object_info_list; | 671 ChosenObjectInfoList chosen_object_info_list; |
663 | 672 |
664 PageInfoUI::PermissionInfo permission_info; | 673 PageInfoUI::PermissionInfo permission_info; |
665 for (size_t i = 0; i < arraysize(kPermissionType); ++i) { | 674 for (size_t i = 0; i < arraysize(kPermissionType); ++i) { |
666 permission_info.type = kPermissionType[i]; | 675 permission_info.type = kPermissionType[i]; |
667 | 676 |
668 if (!ShouldShowPermission(permission_info.type)) | 677 if (!ShouldShowPermission(permission_info.type, site_url_, |
678 content_settings_)) { | |
669 continue; | 679 continue; |
680 } | |
670 | 681 |
671 content_settings::SettingInfo info; | 682 content_settings::SettingInfo info; |
672 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting( | 683 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting( |
673 site_url_, site_url_, permission_info.type, std::string(), &info); | 684 site_url_, site_url_, permission_info.type, std::string(), &info); |
674 DCHECK(value.get()); | 685 DCHECK(value.get()); |
675 if (value->GetType() == base::Value::Type::INTEGER) { | 686 if (value->GetType() == base::Value::Type::INTEGER) { |
676 permission_info.setting = | 687 permission_info.setting = |
677 content_settings::ValueToContentSetting(value.get()); | 688 content_settings::ValueToContentSetting(value.get()); |
678 } else { | 689 } else { |
679 NOTREACHED(); | 690 NOTREACHED(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
767 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_)); | 778 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_)); |
768 | 779 |
769 info.connection_status = site_connection_status_; | 780 info.connection_status = site_connection_status_; |
770 info.connection_status_description = UTF16ToUTF8(site_connection_details_); | 781 info.connection_status_description = UTF16ToUTF8(site_connection_details_); |
771 info.identity_status = site_identity_status_; | 782 info.identity_status = site_identity_status_; |
772 info.identity_status_description = UTF16ToUTF8(site_identity_details_); | 783 info.identity_status_description = UTF16ToUTF8(site_identity_details_); |
773 info.certificate = certificate_; | 784 info.certificate = certificate_; |
774 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; | 785 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; |
775 ui_->SetIdentityInfo(info); | 786 ui_->SetIdentityInfo(info); |
776 } | 787 } |
OLD | NEW |