blob: 6c9f3c75a56e39e2587b7ba149157b371a4c5dbd [file] [log] [blame]
[email protected]03ef4b2a2012-03-06 15:04:201// 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
3// found in the LICENSE file.
4
lgarron617a30f32017-03-24 21:42:075#include "chrome/browser/ui/page_info/page_info.h"
[email protected]03ef4b2a2012-03-06 15:04:206
avi655876a2015-12-25 07:18:157#include <stddef.h>
8#include <stdint.h>
9
[email protected]03ef4b2a2012-03-06 15:04:2010#include <string>
11#include <vector>
12
[email protected]eb2140c2013-07-29 12:37:3413#include "base/command_line.h"
[email protected]15b092542012-05-16 13:08:1414#include "base/i18n/time_formatting.h"
avi655876a2015-12-25 07:18:1515#include "base/macros.h"
avi09dd4d02016-10-14 20:40:0916#include "base/memory/ptr_util.h"
[email protected]71cd5ef2014-08-13 21:22:0417#include "base/metrics/field_trial.h"
asvitkine75036032016-09-01 20:49:3418#include "base/metrics/histogram_macros.h"
[email protected]3ea1b182013-02-08 22:38:4119#include "base/strings/string_number_conversions.h"
[email protected]774cc3c2013-06-07 20:26:4520#include "base/strings/utf_string_conversions.h"
[email protected]0b9fdd72012-04-04 10:00:3321#include "base/values.h"
jialiul02aad2d2015-04-01 18:56:0322#include "chrome/browser/browser_process.h"
[email protected]6b8a3c742014-07-25 00:25:3523#include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h"
[email protected]b0cb5e82012-07-19 19:22:4724#include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
25#include "chrome/browser/browsing_data/browsing_data_database_helper.h"
26#include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
27#include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
28#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
peconn5100d432015-09-16 12:03:0829#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
vabrbab3ffcb2016-10-04 10:08:1030#include "chrome/browser/content_settings/local_shared_objects_container.h"
[email protected]77a91c72012-08-13 16:19:3431#include "chrome/browser/history/history_service_factory.h"
palmerf2cba0d2015-08-27 23:15:0632#include "chrome/browser/infobars/infobar_service.h"
reillyg85f57db2016-01-12 23:14:3833#include "chrome/browser/permissions/chooser_context_base.h"
patricialor7131c1fe2017-04-07 01:25:5234#include "chrome/browser/permissions/permission_decision_auto_blocker.h"
patricialor2a4f41a2017-03-08 02:52:5635#include "chrome/browser/permissions/permission_manager.h"
36#include "chrome/browser/permissions/permission_result.h"
tsergeantf1e89352016-01-15 20:34:5437#include "chrome/browser/permissions/permission_uma_util.h"
38#include "chrome/browser/permissions/permission_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2039#include "chrome/browser/profiles/profile.h"
Jialiu Lin11e18542017-08-14 18:16:2640#include "chrome/browser/safe_browsing/safe_browsing_service.h"
[email protected]71cd5ef2014-08-13 21:22:0441#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
42#include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
lgarron617a30f32017-03-24 21:42:0743#include "chrome/browser/ui/page_info/page_info_ui.h"
reillyg85f57db2016-01-12 23:14:3844#include "chrome/browser/usb/usb_chooser_context.h"
45#include "chrome/browser/usb/usb_chooser_context_factory.h"
Patricia Lora21a04cf2017-06-05 02:53:2946#include "chrome/common/chrome_features.h"
[email protected]71cd5ef2014-08-13 21:22:0447#include "chrome/common/chrome_switches.h"
jsbellddb849e2015-08-27 00:12:5648#include "chrome/common/url_constants.h"
reillyg85f57db2016-01-12 23:14:3849#include "chrome/grit/theme_resources.h"
mukai8eaec822014-10-25 17:53:1650#include "components/content_settings/core/browser/content_settings_utils.h"
51#include "components/content_settings/core/browser/host_content_settings_map.h"
palmer0da10b32015-02-11 00:42:1952#include "components/content_settings/core/common/content_settings.h"
vasiliif62dbf92014-09-05 10:23:1353#include "components/content_settings/core/common/content_settings_pattern.h"
tbansal08a0e3e2017-06-30 21:30:0854#include "components/content_settings/core/common/content_settings_utils.h"
nzolghadrd87a308d2016-12-07 15:45:5655#include "components/rappor/public/rappor_utils.h"
56#include "components/rappor/rappor_service_impl.h"
felt2493b4452015-09-17 20:33:5957#include "components/ssl_errors/error_info.h"
thestig4a2e88e2016-08-27 23:23:5158#include "components/strings/grit/components_chromium_strings.h"
59#include "components/strings/grit/components_strings.h"
melandory7be36d312017-03-29 15:51:1260#include "components/subresource_filter/core/browser/subresource_filter_features.h"
palmer153af982015-09-15 02:04:1961#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3362#include "content/public/browser/browser_thread.h"
[email protected]eb2140c2013-07-29 12:37:3463#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2064#include "content/public/common/url_constants.h"
[email protected]6e7845ae2013-03-29 21:48:1165#include "net/cert/cert_status_flags.h"
66#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5767#include "net/ssl/ssl_cipher_suite_names.h"
68#include "net/ssl/ssl_connection_status_flags.h"
tfarina29a3a1742016-10-28 18:47:3369#include "third_party/boringssl/src/include/openssl/ssl.h"
[email protected]03ef4b2a2012-03-06 15:04:2070#include "ui/base/l10n/l10n_util.h"
Patricia Lora21a04cf2017-06-05 02:53:2971#include "url/origin.h"
[email protected]03ef4b2a2012-03-06 15:04:2072
[email protected]24a9f1c92013-11-13 12:33:3773#if defined(OS_CHROMEOS)
74#include "chrome/browser/chromeos/policy/policy_cert_service.h"
75#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
76#endif
77
estade3feb83f2015-09-01 23:00:4978#if !defined(OS_ANDROID)
mgiucaa319f212016-01-14 03:30:1179#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
lgarron617a30f32017-03-24 21:42:0780#include "chrome/browser/ui/page_info/page_info_infobar_delegate.h"
estade3feb83f2015-09-01 23:00:4981#endif
82
Jialiu Lin11e18542017-08-14 18:16:2683#if defined(SAFE_BROWSING_DB_LOCAL)
84#include "components/safe_browsing/password_protection/password_protection_service.h"
85#endif
86
[email protected]ab6df3b12013-12-24 23:32:2687using base::ASCIIToUTF16;
88using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5689using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3390using content::BrowserThread;
91
92namespace {
93
jww1ed8ea72014-09-02 20:43:2594// Events for UMA. Do not reorder or change!
95enum SSLCertificateDecisionsDidRevoke {
96 USER_CERT_DECISIONS_NOT_REVOKED = 0,
97 USER_CERT_DECISIONS_REVOKED,
98 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM
99};
100
lgarron617a30f32017-03-24 21:42:07101// The list of content settings types to display on the Page Info UI. THE
csharrisonad1eaa6c2017-05-11 17:14:38102// ORDER OF THESE ITEMS IS IMPORTANT and comes from https://crbug.com/610358. To
103// propose changing it, email [email protected].
[email protected]0b9fdd72012-04-04 10:00:33104ContentSettingsType kPermissionType[] = {
sashab2b2a314f2015-01-17 06:42:21105 CONTENT_SETTINGS_TYPE_GEOLOCATION,
sashab2b2a314f2015-01-17 06:42:21106 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
107 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
palmer0da10b32015-02-11 00:42:19108 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
palmer7715e332016-05-27 00:41:19109 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
lshange085f202016-06-14 01:25:08110#if !defined(OS_ANDROID)
palmer7715e332016-05-27 00:41:19111 CONTENT_SETTINGS_TYPE_PLUGINS,
112 CONTENT_SETTINGS_TYPE_IMAGES,
lshange085f202016-06-14 01:25:08113#endif
palmer7715e332016-05-27 00:41:19114 CONTENT_SETTINGS_TYPE_POPUPS,
Charles Harrison239d47982017-06-13 02:42:31115 CONTENT_SETTINGS_TYPE_ADS,
nsatragno670fe922016-04-08 14:10:50116 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
palmer7715e332016-05-27 00:41:19117 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
finnur46cafd42016-09-22 10:27:17118 CONTENT_SETTINGS_TYPE_AUTOPLAY,
palmer7715e332016-05-27 00:41:19119 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
[email protected]0b9fdd72012-04-04 10:00:33120};
121
lgarron617a30f32017-03-24 21:42:07122// Determines whether to show permission |type| in the Page Info UI. Only
mgiucaa319f212016-01-14 03:30:11123// applies to permissions listed in |kPermissionType|.
csharrisonad1eaa6c2017-05-11 17:14:38124bool ShouldShowPermission(ContentSettingsType type,
125 const GURL& site_url,
126 HostContentSettingsMap* content_settings) {
mgiucaa319f212016-01-14 03:30:11127#if !defined(OS_ANDROID)
finnur46cafd42016-09-22 10:27:17128 // Autoplay is Android-only at the moment.
mgiuca273b9672016-11-11 02:22:20129 if (type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
mgiuca0f3e1f72016-05-13 01:56:27130 return false;
mgiucaa319f212016-01-14 03:30:11131#endif
132
Charles Harrison239d47982017-06-13 02:42:31133 if (type == CONTENT_SETTINGS_TYPE_ADS) {
csharrisonad1eaa6c2017-05-11 17:14:38134 if (!base::FeatureList::IsEnabled(
135 subresource_filter::kSafeBrowsingSubresourceFilterExperimentalUI)) {
136 return false;
137 }
138
139 // The setting for subresource filtering should not show up if the site is
140 // not activated, both on android and desktop platforms.
141 return content_settings->GetWebsiteSetting(
Charles Harrison239d47982017-06-13 02:42:31142 site_url, GURL(), CONTENT_SETTINGS_TYPE_ADS_DATA, std::string(),
143 nullptr) != nullptr;
melandory7be36d312017-03-29 15:51:12144 }
145
mgiucaa319f212016-01-14 03:30:11146 return true;
147}
148
esecklercac56b62016-11-16 13:49:44149void CheckContentStatus(security_state::ContentStatus content_status,
estark00e83f12016-08-19 18:24:04150 bool* displayed,
151 bool* ran) {
152 switch (content_status) {
esecklercac56b62016-11-16 13:49:44153 case security_state::CONTENT_STATUS_DISPLAYED:
estark00e83f12016-08-19 18:24:04154 *displayed = true;
155 break;
esecklercac56b62016-11-16 13:49:44156 case security_state::CONTENT_STATUS_RAN:
estark00e83f12016-08-19 18:24:04157 *ran = true;
158 break;
esecklercac56b62016-11-16 13:49:44159 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
estark00e83f12016-08-19 18:24:04160 *displayed = true;
161 *ran = true;
162 break;
esecklercac56b62016-11-16 13:49:44163 case security_state::CONTENT_STATUS_UNKNOWN:
164 case security_state::CONTENT_STATUS_NONE:
estark00e83f12016-08-19 18:24:04165 break;
166 }
167}
168
elawrenceb2ac2a232017-03-27 21:46:25169// If the |security_info| indicates that mixed content or certificate errors
170// were present, update |connection_status| and |connection_details|.
171void ReportAnyInsecureContent(const security_state::SecurityInfo& security_info,
thestig4427f13b2017-06-20 20:42:47172 PageInfo::SiteConnectionStatus* connection_status,
173 base::string16* connection_details) {
elawrenceb2ac2a232017-03-27 21:46:25174 bool displayed_insecure_content = false;
175 bool ran_insecure_content = false;
176 CheckContentStatus(security_info.mixed_content_status,
177 &displayed_insecure_content, &ran_insecure_content);
178 // Only note subresources with certificate errors if the main resource was
179 // loaded without major certificate errors. If the main resource had a
180 // certificate error, then it would not be that useful (and could
181 // potentially be confusing) to warn about subresources that had certificate
182 // errors too.
183 if (!net::IsCertStatusError(security_info.cert_status) ||
184 net::IsCertStatusMinorError(security_info.cert_status)) {
185 CheckContentStatus(security_info.content_with_cert_errors_status,
186 &displayed_insecure_content, &ran_insecure_content);
187 }
188
189 // Only one insecure content warning is displayed; show the most severe.
190 if (ran_insecure_content) {
thestig4427f13b2017-06-20 20:42:47191 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25192 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47193 connection_details->assign(l10n_util::GetStringFUTF16(
194 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25195 l10n_util::GetStringUTF16(
196 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR)));
estark00e83f12016-08-19 18:24:04197 return;
198 }
elawrenceb2ac2a232017-03-27 21:46:25199 if (security_info.contained_mixed_form) {
thestig4427f13b2017-06-20 20:42:47200 *connection_status = PageInfo::SITE_CONNECTION_STATUS_INSECURE_FORM_ACTION;
201 connection_details->assign(l10n_util::GetStringFUTF16(
202 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25203 l10n_util::GetStringUTF16(
204 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_FORM_WARNING)));
205 return;
206 }
207 if (displayed_insecure_content) {
thestig4427f13b2017-06-20 20:42:47208 *connection_status =
elawrenceb2ac2a232017-03-27 21:46:25209 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
thestig4427f13b2017-06-20 20:42:47210 connection_details->assign(l10n_util::GetStringFUTF16(
211 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, *connection_details,
elawrenceb2ac2a232017-03-27 21:46:25212 l10n_util::GetStringUTF16(
213 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
214 }
estark00e83f12016-08-19 18:24:04215}
216
estarkfcfccdb82016-11-14 02:17:29217void GetSiteIdentityByMaliciousContentStatus(
esecklercac56b62016-11-16 13:49:44218 security_state::MaliciousContentStatus malicious_content_status,
lgarron617a30f32017-03-24 21:42:07219 PageInfo::SiteIdentityStatus* status,
estarkfcfccdb82016-11-14 02:17:29220 base::string16* details) {
221 switch (malicious_content_status) {
esecklercac56b62016-11-16 13:49:44222 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
estarkfcfccdb82016-11-14 02:17:29223 NOTREACHED();
224 break;
esecklercac56b62016-11-16 13:49:44225 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
lgarron617a30f32017-03-24 21:42:07226 *status = PageInfo::SITE_IDENTITY_STATUS_MALWARE;
lgarronfc1d5e52017-05-03 23:15:21227 *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MALWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29228 break;
esecklercac56b62016-11-16 13:49:44229 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
lgarron617a30f32017-03-24 21:42:07230 *status = PageInfo::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
lgarron1a6300d2017-03-18 03:33:04231 *details =
lgarronfc1d5e52017-05-03 23:15:21232 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SOCIAL_ENGINEERING_DETAILS);
estarkfcfccdb82016-11-14 02:17:29233 break;
esecklercac56b62016-11-16 13:49:44234 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
lgarron617a30f32017-03-24 21:42:07235 *status = PageInfo::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
lgarron1a6300d2017-03-18 03:33:04236 *details =
lgarronfc1d5e52017-05-03 23:15:21237 l10n_util::GetStringUTF16(IDS_PAGE_INFO_UNWANTED_SOFTWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29238 break;
Jialiu Lin11e18542017-08-14 18:16:26239 case security_state::MALICIOUS_CONTENT_STATUS_PASSWORD_REUSE:
240#if defined(SAFE_BROWSING_DB_LOCAL) && !defined(OS_MACOSX)
241 *status = PageInfo::SITE_IDENTITY_STATUS_PASSWORD_REUSE;
242 *details =
243 l10n_util::GetStringUTF16(IDS_PAGE_INFO_CHANGE_PASSWORD_DETAILS);
244#endif
245 break;
estarkfcfccdb82016-11-14 02:17:29246 }
247}
248
jshin1fb76462016-04-05 22:13:03249base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53250 return url_formatter::FormatUrlForSecurityDisplay(
251 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19252}
253
reillyg85f57db2016-01-12 23:14:38254ChooserContextBase* GetUsbChooserContext(Profile* profile) {
255 return UsbChooserContextFactory::GetForProfile(profile);
256}
257
258// The list of chooser types that need to display entries in the Website
259// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
260// email [email protected].
Andrew Grieved1978b0e2017-07-28 15:53:41261const PageInfo::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52262 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
lgarron617a30f32017-03-24 21:42:07263 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_PAGE_INFO_USB_DEVICE_LABEL,
264 IDS_PAGE_INFO_DELETE_USB_DEVICE, "name"},
reillyg85f57db2016-01-12 23:14:38265};
266
[email protected]0b9fdd72012-04-04 10:00:33267} // namespace
268
lgarron617a30f32017-03-24 21:42:07269PageInfo::PageInfo(PageInfoUI* ui,
270 Profile* profile,
271 TabSpecificContentSettings* tab_specific_content_settings,
272 content::WebContents* web_contents,
273 const GURL& url,
274 const security_state::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50275 : TabSpecificContentSettings::SiteDataObserver(
276 tab_specific_content_settings),
dominicknbdd53b5f2016-09-28 01:08:13277 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50278 ui_(ui),
[email protected]66f157312012-08-01 13:50:26279 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33280 site_url_(url),
281 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20282 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
alshabalin5e894c12016-10-25 06:47:46283 show_ssl_decision_revoke_button_(false),
peconn5100d432015-09-16 12:03:08284 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04285 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25286 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19287 did_revoke_user_ssl_decisions_(false),
estark8d67cd7a2016-10-24 05:06:41288 profile_(profile),
Jialiu Lin11e18542017-08-14 18:16:26289 security_level_(security_state::NONE),
290#if defined(SAFE_BROWSING_DB_LOCAL) && !defined(OS_MACOSX)
291 password_protection_service_(nullptr),
292#endif
293 show_change_password_buttons_(false) {
294#if defined(SAFE_BROWSING_DB_LOCAL) && !defined(OS_MACOSX)
295 safe_browsing::SafeBrowsingService* sb_service =
296 g_browser_process->safe_browsing_service();
297 if (sb_service && sb_service->enabled_by_prefs()) {
298 password_protection_service_ =
299 sb_service->GetPasswordProtectionService(profile_);
300 }
301#endif
302
estarka3121f6b2015-09-18 21:15:59303 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33304
305 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50306 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41307 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23308
lgarron617a30f32017-03-24 21:42:07309 // Every time the Page Info UI is opened a |PageInfo| object is
310 // created. So this counts how ofter the Page Info UI is opened.
311 RecordPageInfoAction(PAGE_INFO_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20312}
313
lgarron617a30f32017-03-24 21:42:07314PageInfo::~PageInfo() {}
[email protected]03ef4b2a2012-03-06 15:04:20315
lgarron617a30f32017-03-24 21:42:07316void PageInfo::RecordPageInfoAction(PageInfoAction action) {
317 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04318
estark8d67cd7a2016-10-24 05:06:41319 std::string histogram_name;
palmeree0e5af2015-06-05 03:10:40320
estark8d67cd7a2016-10-24 05:06:41321 if (site_url_.SchemeIsCryptographic()) {
esecklercac56b62016-11-16 13:49:44322 if (security_level_ == security_state::SECURE ||
323 security_level_ == security_state::EV_SECURE) {
estark8d67cd7a2016-10-24 05:06:41324 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Valid",
lgarron617a30f32017-03-24 21:42:07325 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44326 } else if (security_level_ == security_state::NONE) {
estark8d67cd7a2016-10-24 05:06:41327 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
lgarron617a30f32017-03-24 21:42:07328 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44329 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41330 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07331 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41332 }
333 return;
334 }
335
esecklercac56b62016-11-16 13:49:44336 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
estark8d67cd7a2016-10-24 05:06:41337 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
lgarron617a30f32017-03-24 21:42:07338 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44339 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41340 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07341 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41342 } else {
343 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
lgarron617a30f32017-03-24 21:42:07344 action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04345 }
346}
347
lgarron617a30f32017-03-24 21:42:07348void PageInfo::OnSitePermissionChanged(ContentSettingsType type,
349 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23350 // Count how often a permission for a specific content type is changed using
lgarron617a30f32017-03-24 21:42:07351 // the Page Info UI.
raymes4a13d432015-09-08 00:44:07352 size_t num_values;
353 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
dchengf6f4e4942017-03-30 23:55:57354 UMA_HISTOGRAM_EXACT_LINEAR("WebsiteSettings.OriginInfo.PermissionChanged",
355 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56356
357 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
dchengf6f4e4942017-03-30 23:55:57358 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56359 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07360 num_values);
tommycli34cf29bf2016-09-08 05:46:25361
362 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
363 rappor::SampleDomainAndRegistryFromGURL(
364 g_browser_process->rappor_service(),
365 "ContentSettings.Plugins.AddedAllowException", site_url_);
366 }
sashab9debecd2014-12-18 04:15:56367 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
dchengf6f4e4942017-03-30 23:55:57368 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56369 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07370 num_values);
sashab9debecd2014-12-18 04:15:56371 }
[email protected]e22d64f2012-09-10 09:03:23372
lgarron04a93502014-11-04 22:25:04373 // This is technically redundant given the histogram above, but putting the
374 // total count of permission changes in another histogram makes it easier to
lgarron026e9c42017-04-07 20:09:31375 // compare it against other kinds of actions in Page Info.
lgarron617a30f32017-03-24 21:42:07376 RecordPageInfoAction(PAGE_INFO_CHANGED_PERMISSION);
lgarron04a93502014-11-04 22:25:04377
stefanocs8b3490cc2016-07-28 05:32:52378 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
patricialor7131c1fe2017-04-07 01:25:52379 profile_, site_url_, site_url_, type, PermissionSourceUI::OIB);
stefanocs8b3490cc2016-07-28 05:32:52380
patricialor7131c1fe2017-04-07 01:25:52381 // The permission may have been blocked due to being under embargo, so if it
382 // was changed away from BLOCK, clear embargo status if it exists.
383 if (setting != CONTENT_SETTING_BLOCK) {
384 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveEmbargoByUrl(
385 site_url_, type);
386 }
raymesfbaaaaa2015-11-10 02:20:40387 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
388 setting);
[email protected]df818272012-04-20 13:10:50389
[email protected]66f157312012-08-01 13:50:26390 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24391
392 // Refresh the UI to reflect the new setting.
393 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50394}
395
lgarron617a30f32017-03-24 21:42:07396void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info,
397 const base::DictionaryValue& object) {
reillyg85f57db2016-01-12 23:14:38398 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
399 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10400 const GURL origin = site_url_.GetOrigin();
401 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38402
403 show_info_bar_ = true;
404
405 // Refresh the UI to reflect the changed settings.
406 PresentSitePermissions();
407}
408
lgarron617a30f32017-03-24 21:42:07409void PageInfo::OnSiteDataAccessed() {
[email protected]df818272012-04-20 13:10:50410 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33411}
412
lgarron617a30f32017-03-24 21:42:07413void PageInfo::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49414#if defined(OS_ANDROID)
415 NOTREACHED();
416#else
dominicknbdd53b5f2016-09-28 01:08:13417 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06418 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13419 InfoBarService::FromWebContents(web_contents());
palmerf2cba0d2015-08-27 23:15:06420 if (infobar_service)
lgarron617a30f32017-03-24 21:42:07421 PageInfoInfoBarDelegate::Create(infobar_service);
palmerf2cba0d2015-08-27 23:15:06422 }
jww1ed8ea72014-09-02 20:43:25423
424 SSLCertificateDecisionsDidRevoke user_decision =
425 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
426 : USER_CERT_DECISIONS_NOT_REVOKED;
427
428 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
429 user_decision,
430 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49431#endif
jww1ed8ea72014-09-02 20:43:25432}
433
lgarron617a30f32017-03-24 21:42:07434void PageInfo::OnRevokeSSLErrorBypassButtonPressed() {
jww1ed8ea72014-09-02 20:43:25435 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29436 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
437 site_url().host());
jww1ed8ea72014-09-02 20:43:25438 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26439}
440
Patricia Lora21a04cf2017-06-05 02:53:29441void PageInfo::OpenSiteSettingsView() {
442 // By default, this opens the general Content Settings pane. If the
443 // |kSiteSettings| and/or |kSiteDetails| flags are enabled this opens a
444 // settings page specific to the current origin of the page. crbug.com/655876
445 url::Origin site_origin = url::Origin(site_url());
446 std::string link_destination(chrome::kChromeUIContentSettingsURL);
447 if ((base::CommandLine::ForCurrentProcess()->HasSwitch(
448 switches::kEnableSiteSettings) ||
449 base::FeatureList::IsEnabled(features::kSiteDetails)) &&
450 !site_origin.unique()) {
451 std::string origin_string = site_origin.Serialize();
452 url::RawCanonOutputT<char> percent_encoded_origin;
453 url::EncodeURIComponent(origin_string.c_str(), origin_string.length(),
454 &percent_encoded_origin);
455 link_destination = chrome::kChromeUISiteDetailsPrefixURL +
456 std::string(percent_encoded_origin.data(),
457 percent_encoded_origin.length());
458 }
459 web_contents()->OpenURL(
460 content::OpenURLParams(GURL(link_destination), content::Referrer(),
461 WindowOpenDisposition::NEW_FOREGROUND_TAB,
462 ui::PAGE_TRANSITION_LINK, false));
463 RecordPageInfoAction(PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED);
464}
465
Jialiu Lin11e18542017-08-14 18:16:26466void PageInfo::OnChangePasswordButtonPressed(
467 content::WebContents* web_contents) {
468#if defined(SAFE_BROWSING_DB_LOCAL) && !defined(OS_MACOSX)
469 DCHECK(password_protection_service_);
470 password_protection_service_->OnWarningDone(
471 web_contents, safe_browsing::PasswordProtectionService::PAGE_INFO,
472 safe_browsing::PasswordProtectionService::CHANGE_PASSWORD);
473#endif
474}
475
476void PageInfo::OnWhitelistPasswordReuseButtonPressed(
477 content::WebContents* web_contents) {
478#if defined(SAFE_BROWSING_DB_LOCAL) && !defined(OS_MACOSX)
479 DCHECK(password_protection_service_);
480 password_protection_service_->OnWarningDone(
481 web_contents, safe_browsing::PasswordProtectionService::PAGE_INFO,
482 safe_browsing::PasswordProtectionService::MARK_AS_LEGITIMATE);
483#endif
484}
485
lgarron617a30f32017-03-24 21:42:07486void PageInfo::Init(const GURL& url,
487 const security_state::SecurityInfo& security_info) {
thestig0c55ee32017-06-20 22:17:51488#if !defined(OS_ANDROID)
meacerde53fcff2016-10-12 19:21:57489 // On desktop, internal URLs aren't handled by this class. Instead, a
lgarron026e9c42017-04-07 20:09:31490 // custom and simpler bubble is shown.
meacerde53fcff2016-10-12 19:21:57491 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
492 !url.SchemeIs(content::kChromeDevToolsScheme) &&
493 !url.SchemeIs(content::kViewSourceScheme) &&
494 !url.SchemeIs(content_settings::kExtensionScheme));
495#endif
496
thestig0c55ee32017-06-20 22:17:51497 bool is_chrome_ui_native_scheme = false;
zpengdb4a58e2017-01-10 17:40:32498#if defined(OS_ANDROID)
thestig0c55ee32017-06-20 22:17:51499 is_chrome_ui_native_scheme = url.SchemeIs(chrome::kChromeUINativeScheme);
sashab97894ce2014-10-22 10:08:33500#endif
501
estark8d67cd7a2016-10-24 05:06:41502 security_level_ = security_info.security_level;
503
upendrag.gowda60886a6e2015-10-31 05:51:09504 if (url.SchemeIs(url::kAboutScheme)) {
505 // All about: URLs except about:blank are redirected.
506 DCHECK_EQ(url::kAboutBlankURL, url.spec());
507 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
508 site_identity_details_ =
509 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
510 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
511 site_connection_details_ = l10n_util::GetStringFUTF16(
512 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
513 UTF8ToUTF16(url.spec()));
514 return;
515 }
516
thestig0c55ee32017-06-20 22:17:51517 if (url.SchemeIs(content::kChromeUIScheme) || is_chrome_ui_native_scheme) {
[email protected]03ef4b2a2012-03-06 15:04:20518 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
519 site_identity_details_ =
520 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
521 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
522 return;
523 }
524
[email protected]03ef4b2a2012-03-06 15:04:20525 // Identity section.
jam8ae7cad2016-09-08 23:55:21526 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11527
estarkfcfccdb82016-11-14 02:17:29528 if (security_info.malicious_content_status !=
esecklercac56b62016-11-16 13:49:44529 security_state::MALICIOUS_CONTENT_STATUS_NONE) {
estarkfcfccdb82016-11-14 02:17:29530 // The site has been flagged by Safe Browsing as dangerous.
531 GetSiteIdentityByMaliciousContentStatus(
532 security_info.malicious_content_status, &site_identity_status_,
533 &site_identity_details_);
Jialiu Lin11e18542017-08-14 18:16:26534 show_change_password_buttons_ =
535 security_info.malicious_content_status ==
536 security_state::MALICIOUS_CONTENT_STATUS_PASSWORD_REUSE;
estarkfcfccdb82016-11-14 02:17:29537 } else if (certificate_ &&
538 (!net::IsCertStatusError(security_info.cert_status) ||
539 net::IsCertStatusMinorError(security_info.cert_status))) {
540 // HTTPS with no or minor errors.
estarka3121f6b2015-09-18 21:15:59541 if (security_info.security_level ==
esecklercac56b62016-11-16 13:49:44542 security_state::SECURE_WITH_POLICY_INSTALLED_CERT) {
[email protected]eaf3f322013-04-25 21:53:59543 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37544 site_identity_details_ = l10n_util::GetStringFUTF16(
545 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59546 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20547 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21548 base::string16 issuer_name(
549 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20550 if (issuer_name.empty()) {
551 issuer_name.assign(l10n_util::GetStringUTF16(
552 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
553 }
[email protected]94c74b42013-12-02 15:19:49554
[email protected]03ef4b2a2012-03-06 15:04:20555 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39556 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20557
558 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59559 if (security_info.cert_status &
560 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20561 site_identity_details_ += l10n_util::GetStringUTF16(
562 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59563 } else if (security_info.cert_status &
564 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20565 site_identity_details_ += l10n_util::GetStringUTF16(
566 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
567 } else {
568 NOTREACHED() << "Need to specify string for this warning";
569 }
[email protected]03ef4b2a2012-03-06 15:04:20570 } else {
estarkcf305562016-11-15 03:45:39571 // No major or minor errors.
estarka3121f6b2015-09-18 21:15:59572 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01573 // EV HTTPS page.
estarkcf305562016-11-15 03:45:39574 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
jam8ae7cad2016-09-08 23:55:21575 DCHECK(!certificate_->subject().organization_names.empty());
576 organization_name_ =
577 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01578 // An EV Cert is required to have a city (localityName) and country but
579 // state is "if any".
jam8ae7cad2016-09-08 23:55:21580 DCHECK(!certificate_->subject().locality_name.empty());
581 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01582 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21583 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01584 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21585 IDS_PAGE_INFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21586 UTF8ToUTF16(certificate_->subject().locality_name),
587 UTF8ToUTF16(certificate_->subject().state_or_province_name),
588 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01589 } else {
590 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21591 IDS_PAGE_INFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21592 UTF8ToUTF16(certificate_->subject().locality_name),
593 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01594 }
jam8ae7cad2016-09-08 23:55:21595 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01596 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39597 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED,
jam8ae7cad2016-09-08 23:55:21598 UTF8ToUTF16(certificate_->subject().organization_names[0]),
estarkcf305562016-11-15 03:45:39599 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01600 } else {
601 // Non-EV OK HTTPS page.
estarkcf305562016-11-15 03:45:39602 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
rsleevi4f8012722014-09-30 01:28:01603 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21604 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01605 if (issuer_name.empty()) {
606 issuer_name.assign(l10n_util::GetStringUTF16(
607 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
608 }
[email protected]94c74b42013-12-02 15:19:49609
rsleevi4f8012722014-09-30 01:28:01610 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39611 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
rsleevi4f8012722014-09-30 01:28:01612 }
elawrencebe87bd62017-01-10 16:08:59613 if (security_info.sha1_in_chain) {
614 site_identity_status_ =
615 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
616 site_identity_details_ +=
617 UTF8ToUTF16("\n\n") +
618 l10n_util::GetStringUTF16(
619 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
rsleevi4f8012722014-09-30 01:28:01620 }
[email protected]03ef4b2a2012-03-06 15:04:20621 }
622 } else {
623 // HTTP or HTTPS with errors (not warnings).
624 site_identity_details_.assign(l10n_util::GetStringUTF16(
625 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21626 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20627 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
628 else
629 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
630
[email protected]a04db822013-12-11 19:14:40631 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59632 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59633 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21634 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20635 for (size_t i = 0; i < errors.size(); ++i) {
636 site_identity_details_ += bullet;
637 site_identity_details_ += errors[i].short_description();
638 }
639
estarka3121f6b2015-09-18 21:15:59640 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20641 site_identity_details_ += ASCIIToUTF16("\n\n");
lgarron1a6300d2017-03-18 03:33:04642 site_identity_details_ +=
643 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
[email protected]03ef4b2a2012-03-06 15:04:20644 }
645 }
646
647 // Site Connection
648 // We consider anything less than 80 bits encryption to be weak encryption.
649 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
650 // weakly encrypted connections.
651 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
652
jshin1fb76462016-04-05 22:13:03653 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19654 if (subject_name.empty()) {
655 subject_name.assign(
656 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
657 }
658
jam8ae7cad2016-09-08 23:55:21659 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59660 // Page is still loading (so SSL status is not yet available) or
661 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58662 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
663
664 site_connection_details_.assign(l10n_util::GetStringFUTF16(
665 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
666 subject_name));
estarka3121f6b2015-09-18 21:15:59667 } else if (security_info.security_bits < 0) {
668 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20669 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59670 } else if (security_info.security_bits == 0) {
esecklercac56b62016-11-16 13:49:44671 DCHECK_NE(security_info.security_level, security_state::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20672 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
673 site_connection_details_.assign(l10n_util::GetStringFUTF16(
674 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
675 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20676 } else {
677 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22678
lgarron3e2c33e2016-08-25 06:33:43679 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22680 site_connection_details_.assign(l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04681 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name));
Adam Langley71c2b59b2014-11-13 00:34:22682 } else {
683 site_connection_details_.assign(l10n_util::GetStringFUTF16(
684 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
685 subject_name));
686 }
687
thestig4427f13b2017-06-20 20:42:47688 ReportAnyInsecureContent(security_info, &site_connection_status_,
689 &site_connection_details_);
[email protected]03ef4b2a2012-03-06 15:04:20690 }
691
avi655876a2015-12-25 07:18:15692 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59693 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
694 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20695 int ssl_version =
estarka3121f6b2015-09-18 21:15:59696 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20697 const char* ssl_version_str;
698 net::SSLVersionToString(&ssl_version_str, ssl_version);
699 site_connection_details_ += ASCIIToUTF16("\n\n");
700 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04701 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, ASCIIToUTF16(ssl_version_str));
[email protected]03ef4b2a2012-03-06 15:04:20702
[email protected]03ef4b2a2012-03-06 15:04:20703 const char *key_exchange, *cipher, *mac;
davidben56a8aece2016-10-14 18:20:56704 bool is_aead, is_tls13;
705 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
706 &is_tls13, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20707
708 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57709 if (is_aead) {
davidben56a8aece2016-10-14 18:20:56710 if (is_tls13) {
711 // For TLS 1.3 ciphers, report the group (historically, curve) as the
712 // key exchange.
713 key_exchange = SSL_get_curve_name(security_info.key_exchange_group);
714 if (!key_exchange) {
715 NOTREACHED();
716 key_exchange = "";
717 }
718 }
[email protected]b6c1d9e82013-06-12 17:26:57719 site_connection_details_ += l10n_util::GetStringFUTF16(
720 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
721 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
722 } else {
723 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04724 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, ASCIIToUTF16(cipher),
725 ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
[email protected]b6c1d9e82013-06-12 17:26:57726 }
[email protected]03ef4b2a2012-03-06 15:04:20727 }
[email protected]e583f752012-08-30 13:26:21728
[email protected]71cd5ef2014-08-13 21:22:04729 // Check if a user decision has been made to allow or deny certificates with
730 // errors on this site.
731 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50732 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04733 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40734 // Only show an SSL decision revoke button if the user has chosen to bypass
735 // SSL host errors for this host in the past.
736 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]03ef4b2a2012-03-06 15:04:20737}
[email protected]0b9fdd72012-04-04 10:00:33738
lgarron617a30f32017-03-24 21:42:07739void PageInfo::PresentSitePermissions() {
[email protected]df818272012-04-20 13:10:50740 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38741 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50742
lgarron617a30f32017-03-24 21:42:07743 PageInfoUI::PermissionInfo permission_info;
[email protected]df818272012-04-20 13:10:50744 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
745 permission_info.type = kPermissionType[i];
746
csharrisonad1eaa6c2017-05-11 17:14:38747 if (!ShouldShowPermission(permission_info.type, site_url_,
748 content_settings_)) {
mgiucaa319f212016-01-14 03:30:11749 continue;
csharrisonad1eaa6c2017-05-11 17:14:38750 }
mgiucaa319f212016-01-14 03:30:11751
[email protected]df818272012-04-20 13:10:50752 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32753 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
754 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21755 DCHECK(value.get());
jdoerriedc72ee942016-12-07 15:43:28756 if (value->GetType() == base::Value::Type::INTEGER) {
sashab2b2a314f2015-01-17 06:42:21757 permission_info.setting =
758 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26759 } else {
sashab2b2a314f2015-01-17 06:42:21760 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26761 }
762
[email protected]8bdf45c32012-08-04 00:12:55763 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28764 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50765
[email protected]b1d113d2012-06-27 21:27:34766 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21767 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34768 permission_info.default_setting = permission_info.setting;
769 permission_info.setting = CONTENT_SETTING_DEFAULT;
770 } else {
771 permission_info.default_setting =
772 content_settings_->GetDefaultContentSetting(permission_info.type,
773 NULL);
[email protected]df818272012-04-20 13:10:50774 }
palmer0da10b32015-02-11 00:42:19775
patricialor2a4f41a2017-03-08 02:52:56776 // For permissions that are still prompting the user and haven't been
777 // explicitly set by another source, check its embargo status.
778 if (PermissionUtil::IsPermission(permission_info.type) &&
779 permission_info.setting == CONTENT_SETTING_DEFAULT &&
780 permission_info.source ==
781 content_settings::SettingSource::SETTING_SOURCE_USER) {
782 // TODO(raymes): Use GetPermissionStatus() to retrieve information
783 // about *all* permissions once it has default behaviour implemented for
784 // ContentSettingTypes that aren't permissions.
785 PermissionResult permission_result =
786 PermissionManager::Get(profile_)->GetPermissionStatus(
787 permission_info.type, site_url_, site_url_);
788
789 // If under embargo, update |permission_info| to reflect that.
790 if (permission_result.content_setting == CONTENT_SETTING_BLOCK &&
791 (permission_result.source ==
792 PermissionStatusSource::MULTIPLE_DISMISSALS ||
793 permission_result.source ==
794 PermissionStatusSource::SAFE_BROWSING_BLACKLIST))
795 permission_info.setting = permission_result.content_setting;
796 }
797
palmer64a099982016-03-09 21:26:11798 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50799 }
800
reillyg85f57db2016-01-12 23:14:38801 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
802 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10803 const GURL origin = site_url_.GetOrigin();
804 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32805 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38806 chosen_object_info_list.push_back(
lgarron617a30f32017-03-24 21:42:07807 base::MakeUnique<PageInfoUI::ChosenObjectInfo>(ui_info,
808 std::move(object)));
reillyg85f57db2016-01-12 23:14:38809 }
810 }
811
avi09dd4d02016-10-14 20:40:09812 ui_->SetPermissionInfo(permission_info_list,
813 std::move(chosen_object_info_list));
[email protected]0b9fdd72012-04-04 10:00:33814}
815
lgarron617a30f32017-03-24 21:42:07816void PageInfo::PresentSiteData() {
[email protected]df818272012-04-20 13:10:50817 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10818 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34819 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10820 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34821 tab_specific_content_settings()->blocked_local_shared_objects();
822
823 // Add first party cookie and site data counts.
lgarron617a30f32017-03-24 21:42:07824 PageInfoUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34825 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
826 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15827 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34828 cookie_info_list.push_back(cookie_info);
829
830 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34831 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
832 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15833 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50834 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33835
[email protected]df818272012-04-20 13:10:50836 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33837}
[email protected]16de6de2012-04-04 12:24:14838
lgarron617a30f32017-03-24 21:42:07839void PageInfo::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04840 // After initialization the status about the site's connection and its
841 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41842 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
843 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
lgarron617a30f32017-03-24 21:42:07844 PageInfoUI::IdentityInfo info;
[email protected]24c8818c2012-04-25 09:57:41845 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
846 info.site_identity = UTF16ToUTF8(organization_name());
847 else
jshin1fb76462016-04-05 22:13:03848 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41849
850 info.connection_status = site_connection_status_;
lgarron1a6300d2017-03-18 03:33:04851 info.connection_status_description = UTF16ToUTF8(site_connection_details_);
[email protected]24c8818c2012-04-25 09:57:41852 info.identity_status = site_identity_status_;
lgarron1a6300d2017-03-18 03:33:04853 info.identity_status_description = UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21854 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04855 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
Jialiu Lin11e18542017-08-14 18:16:26856 info.show_change_password_buttons = show_change_password_buttons_;
[email protected]24c8818c2012-04-25 09:57:41857 ui_->SetIdentityInfo(info);
Jialiu Lin11e18542017-08-14 18:16:26858#if defined(SAFE_BROWSING_DB_LOCAL) && !defined(OS_MACOSX)
859 if (password_protection_service_ && show_change_password_buttons_) {
860 password_protection_service_->OnWarningShown(
861 web_contents(), safe_browsing::PasswordProtectionService::PAGE_INFO);
862 }
863#endif
[email protected]24c8818c2012-04-25 09:57:41864}