blob: b5a07be5ce56da7f421b2ec0e497eed2301603db [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"
avi655876a2015-12-25 07:18:1522#include "build/build_config.h"
jialiul02aad2d2015-04-01 18:56:0323#include "chrome/browser/browser_process.h"
[email protected]6b8a3c742014-07-25 00:25:3524#include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h"
[email protected]b0cb5e82012-07-19 19:22:4725#include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
26#include "chrome/browser/browsing_data/browsing_data_database_helper.h"
27#include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
28#include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
29#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
peconn5100d432015-09-16 12:03:0830#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
vabrbab3ffcb2016-10-04 10:08:1031#include "chrome/browser/content_settings/local_shared_objects_container.h"
[email protected]77a91c72012-08-13 16:19:3432#include "chrome/browser/history/history_service_factory.h"
palmerf2cba0d2015-08-27 23:15:0633#include "chrome/browser/infobars/infobar_service.h"
reillyg85f57db2016-01-12 23:14:3834#include "chrome/browser/permissions/chooser_context_base.h"
patricialor7131c1fe2017-04-07 01:25:5235#include "chrome/browser/permissions/permission_decision_auto_blocker.h"
patricialor2a4f41a2017-03-08 02:52:5636#include "chrome/browser/permissions/permission_manager.h"
37#include "chrome/browser/permissions/permission_result.h"
tsergeantf1e89352016-01-15 20:34:5438#include "chrome/browser/permissions/permission_uma_util.h"
39#include "chrome/browser/permissions/permission_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2040#include "chrome/browser/profiles/profile.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"
[email protected]71cd5ef2014-08-13 21:22:0446#include "chrome/common/chrome_switches.h"
jsbellddb849e2015-08-27 00:12:5647#include "chrome/common/url_constants.h"
reillyg85f57db2016-01-12 23:14:3848#include "chrome/grit/theme_resources.h"
mukai8eaec822014-10-25 17:53:1649#include "components/content_settings/core/browser/content_settings_utils.h"
50#include "components/content_settings/core/browser/host_content_settings_map.h"
palmer0da10b32015-02-11 00:42:1951#include "components/content_settings/core/common/content_settings.h"
vasiliif62dbf92014-09-05 10:23:1352#include "components/content_settings/core/common/content_settings_pattern.h"
nzolghadrd87a308d2016-12-07 15:45:5653#include "components/rappor/public/rappor_utils.h"
54#include "components/rappor/rappor_service_impl.h"
felt2493b4452015-09-17 20:33:5955#include "components/ssl_errors/error_info.h"
thestig4a2e88e2016-08-27 23:23:5156#include "components/strings/grit/components_chromium_strings.h"
57#include "components/strings/grit/components_strings.h"
melandory7be36d312017-03-29 15:51:1258#include "components/subresource_filter/core/browser/subresource_filter_features.h"
palmer153af982015-09-15 02:04:1959#include "components/url_formatter/elide_url.h"
[email protected]0b9fdd72012-04-04 10:00:3360#include "content/public/browser/browser_thread.h"
[email protected]eb2140c2013-07-29 12:37:3461#include "content/public/common/content_switches.h"
[email protected]03ef4b2a2012-03-06 15:04:2062#include "content/public/common/url_constants.h"
[email protected]6e7845ae2013-03-29 21:48:1163#include "net/cert/cert_status_flags.h"
64#include "net/cert/x509_certificate.h"
[email protected]536fd0b2013-03-14 17:41:5765#include "net/ssl/ssl_cipher_suite_names.h"
66#include "net/ssl/ssl_connection_status_flags.h"
tfarina29a3a1742016-10-28 18:47:3367#include "third_party/boringssl/src/include/openssl/ssl.h"
[email protected]03ef4b2a2012-03-06 15:04:2068#include "ui/base/l10n/l10n_util.h"
[email protected]03ef4b2a2012-03-06 15:04:2069
[email protected]24a9f1c92013-11-13 12:33:3770#if defined(OS_CHROMEOS)
71#include "chrome/browser/chromeos/policy/policy_cert_service.h"
72#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
73#endif
74
estade3feb83f2015-09-01 23:00:4975#if !defined(OS_ANDROID)
mgiucaa319f212016-01-14 03:30:1176#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
lgarron617a30f32017-03-24 21:42:0777#include "chrome/browser/ui/page_info/page_info_infobar_delegate.h"
estade3feb83f2015-09-01 23:00:4978#endif
79
[email protected]ab6df3b12013-12-24 23:32:2680using base::ASCIIToUTF16;
81using base::UTF8ToUTF16;
[email protected]f729d7a2013-12-26 07:07:5682using base::UTF16ToUTF8;
[email protected]0b9fdd72012-04-04 10:00:3383using content::BrowserThread;
84
85namespace {
86
jww1ed8ea72014-09-02 20:43:2587// Events for UMA. Do not reorder or change!
88enum SSLCertificateDecisionsDidRevoke {
89 USER_CERT_DECISIONS_NOT_REVOKED = 0,
90 USER_CERT_DECISIONS_REVOKED,
91 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM
92};
93
lgarron617a30f32017-03-24 21:42:0794// The list of content settings types to display on the Page Info UI. THE
csharrisonad1eaa6c2017-05-11 17:14:3895// ORDER OF THESE ITEMS IS IMPORTANT and comes from https://crbug.com/610358. To
96// propose changing it, email [email protected].
[email protected]0b9fdd72012-04-04 10:00:3397ContentSettingsType kPermissionType[] = {
sashab2b2a314f2015-01-17 06:42:2198 CONTENT_SETTINGS_TYPE_GEOLOCATION,
sashab2b2a314f2015-01-17 06:42:2199 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
100 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
palmer0da10b32015-02-11 00:42:19101 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
palmer7715e332016-05-27 00:41:19102 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
lshange085f202016-06-14 01:25:08103#if !defined(OS_ANDROID)
palmer7715e332016-05-27 00:41:19104 CONTENT_SETTINGS_TYPE_PLUGINS,
105 CONTENT_SETTINGS_TYPE_IMAGES,
lshange085f202016-06-14 01:25:08106#endif
palmer7715e332016-05-27 00:41:19107 CONTENT_SETTINGS_TYPE_POPUPS,
csharrisonad1eaa6c2017-05-11 17:14:38108 CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER,
nsatragno670fe922016-04-08 14:10:50109 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
palmer7715e332016-05-27 00:41:19110 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
finnur46cafd42016-09-22 10:27:17111 CONTENT_SETTINGS_TYPE_AUTOPLAY,
palmer7715e332016-05-27 00:41:19112 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
[email protected]0b9fdd72012-04-04 10:00:33113};
114
lgarron617a30f32017-03-24 21:42:07115// Determines whether to show permission |type| in the Page Info UI. Only
mgiucaa319f212016-01-14 03:30:11116// applies to permissions listed in |kPermissionType|.
csharrisonad1eaa6c2017-05-11 17:14:38117bool ShouldShowPermission(ContentSettingsType type,
118 const GURL& site_url,
119 HostContentSettingsMap* content_settings) {
mgiucaa319f212016-01-14 03:30:11120#if !defined(OS_ANDROID)
finnur46cafd42016-09-22 10:27:17121 // Autoplay is Android-only at the moment.
mgiuca273b9672016-11-11 02:22:20122 if (type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
mgiuca0f3e1f72016-05-13 01:56:27123 return false;
mgiucaa319f212016-01-14 03:30:11124#endif
125
melandory7be36d312017-03-29 15:51:12126 if (type == CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER) {
csharrisonad1eaa6c2017-05-11 17:14:38127 if (!base::FeatureList::IsEnabled(
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;
melandory7be36d312017-03-29 15:51:12137 }
138
mgiucaa319f212016-01-14 03:30:11139 return true;
140}
141
esecklercac56b62016-11-16 13:49:44142void CheckContentStatus(security_state::ContentStatus content_status,
estark00e83f12016-08-19 18:24:04143 bool* displayed,
144 bool* ran) {
145 switch (content_status) {
esecklercac56b62016-11-16 13:49:44146 case security_state::CONTENT_STATUS_DISPLAYED:
estark00e83f12016-08-19 18:24:04147 *displayed = true;
148 break;
esecklercac56b62016-11-16 13:49:44149 case security_state::CONTENT_STATUS_RAN:
estark00e83f12016-08-19 18:24:04150 *ran = true;
151 break;
esecklercac56b62016-11-16 13:49:44152 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
estark00e83f12016-08-19 18:24:04153 *displayed = true;
154 *ran = true;
155 break;
esecklercac56b62016-11-16 13:49:44156 case security_state::CONTENT_STATUS_UNKNOWN:
157 case security_state::CONTENT_STATUS_NONE:
estark00e83f12016-08-19 18:24:04158 break;
159 }
160}
161
elawrenceb2ac2a232017-03-27 21:46:25162// If the |security_info| indicates that mixed content or certificate errors
163// were present, update |connection_status| and |connection_details|.
164void ReportAnyInsecureContent(const security_state::SecurityInfo& security_info,
165 PageInfo::SiteConnectionStatus& connection_status,
166 base::string16& connection_details) {
167 bool displayed_insecure_content = false;
168 bool ran_insecure_content = false;
169 CheckContentStatus(security_info.mixed_content_status,
170 &displayed_insecure_content, &ran_insecure_content);
171 // Only note subresources with certificate errors if the main resource was
172 // loaded without major certificate errors. If the main resource had a
173 // certificate error, then it would not be that useful (and could
174 // potentially be confusing) to warn about subresources that had certificate
175 // errors too.
176 if (!net::IsCertStatusError(security_info.cert_status) ||
177 net::IsCertStatusMinorError(security_info.cert_status)) {
178 CheckContentStatus(security_info.content_with_cert_errors_status,
179 &displayed_insecure_content, &ran_insecure_content);
180 }
181
182 // Only one insecure content warning is displayed; show the most severe.
183 if (ran_insecure_content) {
184 connection_status =
185 PageInfo::SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE;
186 connection_details.assign(l10n_util::GetStringFUTF16(
187 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, connection_details,
188 l10n_util::GetStringUTF16(
189 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR)));
estark00e83f12016-08-19 18:24:04190 return;
191 }
elawrenceb2ac2a232017-03-27 21:46:25192 if (security_info.contained_mixed_form) {
193 connection_status = PageInfo::SITE_CONNECTION_STATUS_INSECURE_FORM_ACTION;
194 connection_details.assign(l10n_util::GetStringFUTF16(
195 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, connection_details,
196 l10n_util::GetStringUTF16(
197 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_FORM_WARNING)));
198 return;
199 }
200 if (displayed_insecure_content) {
201 connection_status =
202 PageInfo::SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE;
203 connection_details.assign(l10n_util::GetStringFUTF16(
204 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, connection_details,
205 l10n_util::GetStringUTF16(
206 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING)));
207 }
estark00e83f12016-08-19 18:24:04208}
209
estarkfcfccdb82016-11-14 02:17:29210void GetSiteIdentityByMaliciousContentStatus(
esecklercac56b62016-11-16 13:49:44211 security_state::MaliciousContentStatus malicious_content_status,
lgarron617a30f32017-03-24 21:42:07212 PageInfo::SiteIdentityStatus* status,
estarkfcfccdb82016-11-14 02:17:29213 base::string16* details) {
214 switch (malicious_content_status) {
esecklercac56b62016-11-16 13:49:44215 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
estarkfcfccdb82016-11-14 02:17:29216 NOTREACHED();
217 break;
esecklercac56b62016-11-16 13:49:44218 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
lgarron617a30f32017-03-24 21:42:07219 *status = PageInfo::SITE_IDENTITY_STATUS_MALWARE;
lgarronfc1d5e52017-05-03 23:15:21220 *details = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MALWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29221 break;
esecklercac56b62016-11-16 13:49:44222 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
lgarron617a30f32017-03-24 21:42:07223 *status = PageInfo::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
lgarron1a6300d2017-03-18 03:33:04224 *details =
lgarronfc1d5e52017-05-03 23:15:21225 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SOCIAL_ENGINEERING_DETAILS);
estarkfcfccdb82016-11-14 02:17:29226 break;
esecklercac56b62016-11-16 13:49:44227 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
lgarron617a30f32017-03-24 21:42:07228 *status = PageInfo::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
lgarron1a6300d2017-03-18 03:33:04229 *details =
lgarronfc1d5e52017-05-03 23:15:21230 l10n_util::GetStringUTF16(IDS_PAGE_INFO_UNWANTED_SOFTWARE_DETAILS);
estarkfcfccdb82016-11-14 02:17:29231 break;
232 }
233}
234
jshin1fb76462016-04-05 22:13:03235base::string16 GetSimpleSiteName(const GURL& url) {
benwells2337b8102016-04-20 01:53:53236 return url_formatter::FormatUrlForSecurityDisplay(
237 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
palmer153af982015-09-15 02:04:19238}
239
reillyg85f57db2016-01-12 23:14:38240ChooserContextBase* GetUsbChooserContext(Profile* profile) {
241 return UsbChooserContextFactory::GetForProfile(profile);
242}
243
244// The list of chooser types that need to display entries in the Website
245// Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
246// email [email protected].
lgarron617a30f32017-03-24 21:42:07247PageInfo::ChooserUIInfo kChooserUIInfo[] = {
reillyg58f82ab2016-08-03 01:49:52248 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
lgarron617a30f32017-03-24 21:42:07249 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_PAGE_INFO_USB_DEVICE_LABEL,
250 IDS_PAGE_INFO_DELETE_USB_DEVICE, "name"},
reillyg85f57db2016-01-12 23:14:38251};
252
[email protected]0b9fdd72012-04-04 10:00:33253} // namespace
254
lgarron617a30f32017-03-24 21:42:07255PageInfo::PageInfo(PageInfoUI* ui,
256 Profile* profile,
257 TabSpecificContentSettings* tab_specific_content_settings,
258 content::WebContents* web_contents,
259 const GURL& url,
260 const security_state::SecurityInfo& security_info)
[email protected]df818272012-04-20 13:10:50261 : TabSpecificContentSettings::SiteDataObserver(
262 tab_specific_content_settings),
dominicknbdd53b5f2016-09-28 01:08:13263 content::WebContentsObserver(web_contents),
[email protected]df818272012-04-20 13:10:50264 ui_(ui),
[email protected]66f157312012-08-01 13:50:26265 show_info_bar_(false),
[email protected]0b9fdd72012-04-04 10:00:33266 site_url_(url),
267 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
[email protected]03ef4b2a2012-03-06 15:04:20268 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
alshabalin5e894c12016-10-25 06:47:46269 show_ssl_decision_revoke_button_(false),
peconn5100d432015-09-16 12:03:08270 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
[email protected]71cd5ef2014-08-13 21:22:04271 chrome_ssl_host_state_delegate_(
jww1ed8ea72014-09-02 20:43:25272 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
palmer153af982015-09-15 02:04:19273 did_revoke_user_ssl_decisions_(false),
estark8d67cd7a2016-10-24 05:06:41274 profile_(profile),
esecklercac56b62016-11-16 13:49:44275 security_level_(security_state::NONE) {
estarka3121f6b2015-09-18 21:15:59276 Init(url, security_info);
[email protected]0b9fdd72012-04-04 10:00:33277
278 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50279 PresentSiteData();
[email protected]24c8818c2012-04-25 09:57:41280 PresentSiteIdentity();
[email protected]e22d64f2012-09-10 09:03:23281
lgarron617a30f32017-03-24 21:42:07282 // Every time the Page Info UI is opened a |PageInfo| object is
283 // created. So this counts how ofter the Page Info UI is opened.
284 RecordPageInfoAction(PAGE_INFO_OPENED);
[email protected]03ef4b2a2012-03-06 15:04:20285}
286
lgarron617a30f32017-03-24 21:42:07287PageInfo::~PageInfo() {}
[email protected]03ef4b2a2012-03-06 15:04:20288
lgarron617a30f32017-03-24 21:42:07289void PageInfo::RecordPageInfoAction(PageInfoAction action) {
290 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04291
estark8d67cd7a2016-10-24 05:06:41292 std::string histogram_name;
palmeree0e5af2015-06-05 03:10:40293
estark8d67cd7a2016-10-24 05:06:41294 if (site_url_.SchemeIsCryptographic()) {
esecklercac56b62016-11-16 13:49:44295 if (security_level_ == security_state::SECURE ||
296 security_level_ == security_state::EV_SECURE) {
estark8d67cd7a2016-10-24 05:06:41297 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Valid",
lgarron617a30f32017-03-24 21:42:07298 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44299 } else if (security_level_ == security_state::NONE) {
estark8d67cd7a2016-10-24 05:06:41300 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
lgarron617a30f32017-03-24 21:42:07301 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44302 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41303 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07304 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41305 }
306 return;
307 }
308
esecklercac56b62016-11-16 13:49:44309 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
estark8d67cd7a2016-10-24 05:06:41310 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
lgarron617a30f32017-03-24 21:42:07311 action, PAGE_INFO_COUNT);
esecklercac56b62016-11-16 13:49:44312 } else if (security_level_ == security_state::DANGEROUS) {
estark8d67cd7a2016-10-24 05:06:41313 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
lgarron617a30f32017-03-24 21:42:07314 action, PAGE_INFO_COUNT);
estark8d67cd7a2016-10-24 05:06:41315 } else {
316 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
lgarron617a30f32017-03-24 21:42:07317 action, PAGE_INFO_COUNT);
lgarron04a93502014-11-04 22:25:04318 }
319}
320
lgarron617a30f32017-03-24 21:42:07321void PageInfo::OnSitePermissionChanged(ContentSettingsType type,
322 ContentSetting setting) {
[email protected]e22d64f2012-09-10 09:03:23323 // Count how often a permission for a specific content type is changed using
lgarron617a30f32017-03-24 21:42:07324 // the Page Info UI.
raymes4a13d432015-09-08 00:44:07325 size_t num_values;
326 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
dchengf6f4e4942017-03-30 23:55:57327 UMA_HISTOGRAM_EXACT_LINEAR("WebsiteSettings.OriginInfo.PermissionChanged",
328 histogram_value, num_values);
sashab9debecd2014-12-18 04:15:56329
330 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
dchengf6f4e4942017-03-30 23:55:57331 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56332 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
raymes4a13d432015-09-08 00:44:07333 num_values);
tommycli34cf29bf2016-09-08 05:46:25334
335 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
336 rappor::SampleDomainAndRegistryFromGURL(
337 g_browser_process->rappor_service(),
338 "ContentSettings.Plugins.AddedAllowException", site_url_);
339 }
sashab9debecd2014-12-18 04:15:56340 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
dchengf6f4e4942017-03-30 23:55:57341 UMA_HISTOGRAM_EXACT_LINEAR(
sashab9debecd2014-12-18 04:15:56342 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
raymes4a13d432015-09-08 00:44:07343 num_values);
sashab9debecd2014-12-18 04:15:56344 }
[email protected]e22d64f2012-09-10 09:03:23345
lgarron04a93502014-11-04 22:25:04346 // This is technically redundant given the histogram above, but putting the
347 // total count of permission changes in another histogram makes it easier to
lgarron026e9c42017-04-07 20:09:31348 // compare it against other kinds of actions in Page Info.
lgarron617a30f32017-03-24 21:42:07349 RecordPageInfoAction(PAGE_INFO_CHANGED_PERMISSION);
lgarron04a93502014-11-04 22:25:04350
stefanocs8b3490cc2016-07-28 05:32:52351 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
patricialor7131c1fe2017-04-07 01:25:52352 profile_, site_url_, site_url_, type, PermissionSourceUI::OIB);
stefanocs8b3490cc2016-07-28 05:32:52353
patricialor7131c1fe2017-04-07 01:25:52354 // The permission may have been blocked due to being under embargo, so if it
355 // was changed away from BLOCK, clear embargo status if it exists.
356 if (setting != CONTENT_SETTING_BLOCK) {
357 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveEmbargoByUrl(
358 site_url_, type);
359 }
raymesfbaaaaa2015-11-10 02:20:40360 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
361 setting);
[email protected]df818272012-04-20 13:10:50362
[email protected]66f157312012-08-01 13:50:26363 show_info_bar_ = true;
[email protected]2f45d542012-08-22 08:47:24364
365 // Refresh the UI to reflect the new setting.
366 PresentSitePermissions();
[email protected]df818272012-04-20 13:10:50367}
368
lgarron617a30f32017-03-24 21:42:07369void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info,
370 const base::DictionaryValue& object) {
reillyg85f57db2016-01-12 23:14:38371 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
372 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10373 const GURL origin = site_url_.GetOrigin();
374 context->RevokeObjectPermission(origin, origin, object);
reillyg85f57db2016-01-12 23:14:38375
376 show_info_bar_ = true;
377
378 // Refresh the UI to reflect the changed settings.
379 PresentSitePermissions();
380}
381
lgarron617a30f32017-03-24 21:42:07382void PageInfo::OnSiteDataAccessed() {
[email protected]df818272012-04-20 13:10:50383 PresentSiteData();
[email protected]0b9fdd72012-04-04 10:00:33384}
385
lgarron617a30f32017-03-24 21:42:07386void PageInfo::OnUIClosing() {
estade3feb83f2015-09-01 23:00:49387#if defined(OS_ANDROID)
388 NOTREACHED();
389#else
dominicknbdd53b5f2016-09-28 01:08:13390 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
palmerf2cba0d2015-08-27 23:15:06391 InfoBarService* infobar_service =
dominicknbdd53b5f2016-09-28 01:08:13392 InfoBarService::FromWebContents(web_contents());
palmerf2cba0d2015-08-27 23:15:06393 if (infobar_service)
lgarron617a30f32017-03-24 21:42:07394 PageInfoInfoBarDelegate::Create(infobar_service);
palmerf2cba0d2015-08-27 23:15:06395 }
jww1ed8ea72014-09-02 20:43:25396
397 SSLCertificateDecisionsDidRevoke user_decision =
398 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
399 : USER_CERT_DECISIONS_NOT_REVOKED;
400
401 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
402 user_decision,
403 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
estade3feb83f2015-09-01 23:00:49404#endif
jww1ed8ea72014-09-02 20:43:25405}
406
lgarron617a30f32017-03-24 21:42:07407void PageInfo::OnRevokeSSLErrorBypassButtonPressed() {
jww1ed8ea72014-09-02 20:43:25408 DCHECK(chrome_ssl_host_state_delegate_);
jww6a55df72014-09-05 19:59:29409 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
410 site_url().host());
jww1ed8ea72014-09-02 20:43:25411 did_revoke_user_ssl_decisions_ = true;
[email protected]66f157312012-08-01 13:50:26412}
413
lgarron617a30f32017-03-24 21:42:07414void PageInfo::Init(const GURL& url,
415 const security_state::SecurityInfo& security_info) {
meacerde53fcff2016-10-12 19:21:57416#if !defined(OS_ANDROID) && !defined(OS_IOS)
417 // On desktop, internal URLs aren't handled by this class. Instead, a
lgarron026e9c42017-04-07 20:09:31418 // custom and simpler bubble is shown.
meacerde53fcff2016-10-12 19:21:57419 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
420 !url.SchemeIs(content::kChromeDevToolsScheme) &&
421 !url.SchemeIs(content::kViewSourceScheme) &&
422 !url.SchemeIs(content_settings::kExtensionScheme));
423#endif
424
sashab97894ce2014-10-22 10:08:33425 bool isChromeUINativeScheme = false;
zpengdb4a58e2017-01-10 17:40:32426#if defined(OS_ANDROID)
sashab97894ce2014-10-22 10:08:33427 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme);
428#endif
429
estark8d67cd7a2016-10-24 05:06:41430 security_level_ = security_info.security_level;
431
upendrag.gowda60886a6e2015-10-31 05:51:09432 if (url.SchemeIs(url::kAboutScheme)) {
433 // All about: URLs except about:blank are redirected.
434 DCHECK_EQ(url::kAboutBlankURL, url.spec());
435 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
436 site_identity_details_ =
437 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY);
438 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
439 site_connection_details_ = l10n_util::GetStringFUTF16(
440 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
441 UTF8ToUTF16(url.spec()));
442 return;
443 }
444
445 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) {
[email protected]03ef4b2a2012-03-06 15:04:20446 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE;
447 site_identity_details_ =
448 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
449 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE;
450 return;
451 }
452
[email protected]03ef4b2a2012-03-06 15:04:20453 // Identity section.
jam8ae7cad2016-09-08 23:55:21454 certificate_ = security_info.certificate;
[email protected]f61c1ce2012-05-09 13:55:11455
estarkfcfccdb82016-11-14 02:17:29456 if (security_info.malicious_content_status !=
esecklercac56b62016-11-16 13:49:44457 security_state::MALICIOUS_CONTENT_STATUS_NONE) {
estarkfcfccdb82016-11-14 02:17:29458 // The site has been flagged by Safe Browsing as dangerous.
459 GetSiteIdentityByMaliciousContentStatus(
460 security_info.malicious_content_status, &site_identity_status_,
461 &site_identity_details_);
462 } else if (certificate_ &&
463 (!net::IsCertStatusError(security_info.cert_status) ||
464 net::IsCertStatusMinorError(security_info.cert_status))) {
465 // HTTPS with no or minor errors.
estarka3121f6b2015-09-18 21:15:59466 if (security_info.security_level ==
esecklercac56b62016-11-16 13:49:44467 security_state::SECURE_WITH_POLICY_INSTALLED_CERT) {
[email protected]eaf3f322013-04-25 21:53:59468 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT;
[email protected]24a9f1c92013-11-13 12:33:37469 site_identity_details_ = l10n_util::GetStringFUTF16(
470 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host()));
estarka3121f6b2015-09-18 21:15:59471 } else if (net::IsCertStatusMinorError(security_info.cert_status)) {
[email protected]03ef4b2a2012-03-06 15:04:20472 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN;
jam8ae7cad2016-09-08 23:55:21473 base::string16 issuer_name(
474 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
[email protected]03ef4b2a2012-03-06 15:04:20475 if (issuer_name.empty()) {
476 issuer_name.assign(l10n_util::GetStringUTF16(
477 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
478 }
[email protected]94c74b42013-12-02 15:19:49479
[email protected]03ef4b2a2012-03-06 15:04:20480 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39481 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
[email protected]03ef4b2a2012-03-06 15:04:20482
483 site_identity_details_ += ASCIIToUTF16("\n\n");
estarka3121f6b2015-09-18 21:15:59484 if (security_info.cert_status &
485 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) {
[email protected]03ef4b2a2012-03-06 15:04:20486 site_identity_details_ += l10n_util::GetStringUTF16(
487 IDS_PAGE_INFO_SECURITY_TAB_UNABLE_TO_CHECK_REVOCATION);
estarka3121f6b2015-09-18 21:15:59488 } else if (security_info.cert_status &
489 net::CERT_STATUS_NO_REVOCATION_MECHANISM) {
[email protected]03ef4b2a2012-03-06 15:04:20490 site_identity_details_ += l10n_util::GetStringUTF16(
491 IDS_PAGE_INFO_SECURITY_TAB_NO_REVOCATION_MECHANISM);
492 } else {
493 NOTREACHED() << "Need to specify string for this warning";
494 }
[email protected]03ef4b2a2012-03-06 15:04:20495 } else {
estarkcf305562016-11-15 03:45:39496 // No major or minor errors.
estarka3121f6b2015-09-18 21:15:59497 if (security_info.cert_status & net::CERT_STATUS_IS_EV) {
rsleevi4f8012722014-09-30 01:28:01498 // EV HTTPS page.
estarkcf305562016-11-15 03:45:39499 site_identity_status_ = SITE_IDENTITY_STATUS_EV_CERT;
jam8ae7cad2016-09-08 23:55:21500 DCHECK(!certificate_->subject().organization_names.empty());
501 organization_name_ =
502 UTF8ToUTF16(certificate_->subject().organization_names[0]);
rsleevi4f8012722014-09-30 01:28:01503 // An EV Cert is required to have a city (localityName) and country but
504 // state is "if any".
jam8ae7cad2016-09-08 23:55:21505 DCHECK(!certificate_->subject().locality_name.empty());
506 DCHECK(!certificate_->subject().country_name.empty());
rsleevi4f8012722014-09-30 01:28:01507 base::string16 locality;
jam8ae7cad2016-09-08 23:55:21508 if (!certificate_->subject().state_or_province_name.empty()) {
rsleevi4f8012722014-09-30 01:28:01509 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21510 IDS_PAGE_INFO_ADDRESS,
jam8ae7cad2016-09-08 23:55:21511 UTF8ToUTF16(certificate_->subject().locality_name),
512 UTF8ToUTF16(certificate_->subject().state_or_province_name),
513 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01514 } else {
515 locality = l10n_util::GetStringFUTF16(
lgarronfc1d5e52017-05-03 23:15:21516 IDS_PAGE_INFO_PARTIAL_ADDRESS,
jam8ae7cad2016-09-08 23:55:21517 UTF8ToUTF16(certificate_->subject().locality_name),
518 UTF8ToUTF16(certificate_->subject().country_name));
rsleevi4f8012722014-09-30 01:28:01519 }
jam8ae7cad2016-09-08 23:55:21520 DCHECK(!certificate_->subject().organization_names.empty());
rsleevi4f8012722014-09-30 01:28:01521 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39522 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV_VERIFIED,
jam8ae7cad2016-09-08 23:55:21523 UTF8ToUTF16(certificate_->subject().organization_names[0]),
estarkcf305562016-11-15 03:45:39524 locality, UTF8ToUTF16(certificate_->issuer().GetDisplayName())));
rsleevi4f8012722014-09-30 01:28:01525 } else {
526 // Non-EV OK HTTPS page.
estarkcf305562016-11-15 03:45:39527 site_identity_status_ = SITE_IDENTITY_STATUS_CERT;
rsleevi4f8012722014-09-30 01:28:01528 base::string16 issuer_name(
jam8ae7cad2016-09-08 23:55:21529 UTF8ToUTF16(certificate_->issuer().GetDisplayName()));
rsleevi4f8012722014-09-30 01:28:01530 if (issuer_name.empty()) {
531 issuer_name.assign(l10n_util::GetStringUTF16(
532 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
533 }
[email protected]94c74b42013-12-02 15:19:49534
rsleevi4f8012722014-09-30 01:28:01535 site_identity_details_.assign(l10n_util::GetStringFUTF16(
estarkcf305562016-11-15 03:45:39536 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, issuer_name));
rsleevi4f8012722014-09-30 01:28:01537 }
elawrencebe87bd62017-01-10 16:08:59538 if (security_info.sha1_in_chain) {
539 site_identity_status_ =
540 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM;
541 site_identity_details_ +=
542 UTF8ToUTF16("\n\n") +
543 l10n_util::GetStringUTF16(
544 IDS_PAGE_INFO_SECURITY_TAB_DEPRECATED_SIGNATURE_ALGORITHM);
rsleevi4f8012722014-09-30 01:28:01545 }
[email protected]03ef4b2a2012-03-06 15:04:20546 }
547 } else {
548 // HTTP or HTTPS with errors (not warnings).
549 site_identity_details_.assign(l10n_util::GetStringUTF16(
550 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
jam8ae7cad2016-09-08 23:55:21551 if (!security_info.scheme_is_cryptographic || !security_info.certificate)
[email protected]03ef4b2a2012-03-06 15:04:20552 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT;
553 else
554 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR;
555
[email protected]a04db822013-12-11 19:14:40556 const base::string16 bullet = UTF8ToUTF16("\n • ");
felt2493b4452015-09-17 20:33:59557 std::vector<ssl_errors::ErrorInfo> errors;
estarka3121f6b2015-09-18 21:15:59558 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
jam8ae7cad2016-09-08 23:55:21559 certificate_, security_info.cert_status, url, &errors);
[email protected]03ef4b2a2012-03-06 15:04:20560 for (size_t i = 0; i < errors.size(); ++i) {
561 site_identity_details_ += bullet;
562 site_identity_details_ += errors[i].short_description();
563 }
564
estarka3121f6b2015-09-18 21:15:59565 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
[email protected]03ef4b2a2012-03-06 15:04:20566 site_identity_details_ += ASCIIToUTF16("\n\n");
lgarron1a6300d2017-03-18 03:33:04567 site_identity_details_ +=
568 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
[email protected]03ef4b2a2012-03-06 15:04:20569 }
570 }
571
572 // Site Connection
573 // We consider anything less than 80 bits encryption to be weak encryption.
574 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
575 // weakly encrypted connections.
576 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
577
jshin1fb76462016-04-05 22:13:03578 base::string16 subject_name(GetSimpleSiteName(url));
palmer153af982015-09-15 02:04:19579 if (subject_name.empty()) {
580 subject_name.assign(
581 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
582 }
583
jam8ae7cad2016-09-08 23:55:21584 if (!security_info.certificate || !security_info.scheme_is_cryptographic) {
estarka3121f6b2015-09-18 21:15:59585 // Page is still loading (so SSL status is not yet available) or
586 // loaded over HTTP or loaded over HTTPS with no cert.
[email protected]1c1051d2014-05-10 11:39:58587 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED;
588
589 site_connection_details_.assign(l10n_util::GetStringFUTF16(
590 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
591 subject_name));
estarka3121f6b2015-09-18 21:15:59592 } else if (security_info.security_bits < 0) {
593 // Security strength is unknown. Say nothing.
[email protected]03ef4b2a2012-03-06 15:04:20594 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
estarka3121f6b2015-09-18 21:15:59595 } else if (security_info.security_bits == 0) {
esecklercac56b62016-11-16 13:49:44596 DCHECK_NE(security_info.security_level, security_state::NONE);
[email protected]03ef4b2a2012-03-06 15:04:20597 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
598 site_connection_details_.assign(l10n_util::GetStringFUTF16(
599 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
600 subject_name));
[email protected]03ef4b2a2012-03-06 15:04:20601 } else {
602 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
Adam Langley71c2b59b2014-11-13 00:34:22603
lgarron3e2c33e2016-08-25 06:33:43604 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
Adam Langley71c2b59b2014-11-13 00:34:22605 site_connection_details_.assign(l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04606 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name));
Adam Langley71c2b59b2014-11-13 00:34:22607 } else {
608 site_connection_details_.assign(l10n_util::GetStringFUTF16(
609 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
610 subject_name));
611 }
612
elawrenceb2ac2a232017-03-27 21:46:25613 ReportAnyInsecureContent(security_info, site_connection_status_,
614 site_connection_details_);
[email protected]03ef4b2a2012-03-06 15:04:20615 }
616
avi655876a2015-12-25 07:18:15617 uint16_t cipher_suite =
estarka3121f6b2015-09-18 21:15:59618 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
619 if (security_info.security_bits > 0 && cipher_suite) {
[email protected]03ef4b2a2012-03-06 15:04:20620 int ssl_version =
estarka3121f6b2015-09-18 21:15:59621 net::SSLConnectionStatusToVersion(security_info.connection_status);
[email protected]03ef4b2a2012-03-06 15:04:20622 const char* ssl_version_str;
623 net::SSLVersionToString(&ssl_version_str, ssl_version);
624 site_connection_details_ += ASCIIToUTF16("\n\n");
625 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04626 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, ASCIIToUTF16(ssl_version_str));
[email protected]03ef4b2a2012-03-06 15:04:20627
[email protected]03ef4b2a2012-03-06 15:04:20628 const char *key_exchange, *cipher, *mac;
davidben56a8aece2016-10-14 18:20:56629 bool is_aead, is_tls13;
630 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
631 &is_tls13, cipher_suite);
[email protected]03ef4b2a2012-03-06 15:04:20632
633 site_connection_details_ += ASCIIToUTF16("\n\n");
[email protected]b6c1d9e82013-06-12 17:26:57634 if (is_aead) {
davidben56a8aece2016-10-14 18:20:56635 if (is_tls13) {
636 // For TLS 1.3 ciphers, report the group (historically, curve) as the
637 // key exchange.
638 key_exchange = SSL_get_curve_name(security_info.key_exchange_group);
639 if (!key_exchange) {
640 NOTREACHED();
641 key_exchange = "";
642 }
643 }
[email protected]b6c1d9e82013-06-12 17:26:57644 site_connection_details_ += l10n_util::GetStringFUTF16(
645 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
646 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
647 } else {
648 site_connection_details_ += l10n_util::GetStringFUTF16(
lgarron1a6300d2017-03-18 03:33:04649 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, ASCIIToUTF16(cipher),
650 ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
[email protected]b6c1d9e82013-06-12 17:26:57651 }
[email protected]03ef4b2a2012-03-06 15:04:20652
agl078d2102014-10-20 22:03:22653 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
estark00e83f12016-08-19 18:24:04654 site_connection_status_ <
655 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE) {
agl078d2102014-10-20 22:03:22656 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
657 }
[email protected]03ef4b2a2012-03-06 15:04:20658 }
[email protected]e583f752012-08-30 13:26:21659
[email protected]71cd5ef2014-08-13 21:22:04660 // Check if a user decision has been made to allow or deny certificates with
661 // errors on this site.
662 ChromeSSLHostStateDelegate* delegate =
estark7c6bfbf2015-09-16 22:20:50663 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
[email protected]71cd5ef2014-08-13 21:22:04664 DCHECK(delegate);
jwwf806c362015-06-02 02:00:40665 // Only show an SSL decision revoke button if the user has chosen to bypass
666 // SSL host errors for this host in the past.
667 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
[email protected]03ef4b2a2012-03-06 15:04:20668}
[email protected]0b9fdd72012-04-04 10:00:33669
lgarron617a30f32017-03-24 21:42:07670void PageInfo::PresentSitePermissions() {
[email protected]df818272012-04-20 13:10:50671 PermissionInfoList permission_info_list;
reillyg85f57db2016-01-12 23:14:38672 ChosenObjectInfoList chosen_object_info_list;
[email protected]df818272012-04-20 13:10:50673
lgarron617a30f32017-03-24 21:42:07674 PageInfoUI::PermissionInfo permission_info;
[email protected]df818272012-04-20 13:10:50675 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
676 permission_info.type = kPermissionType[i];
677
csharrisonad1eaa6c2017-05-11 17:14:38678 if (!ShouldShowPermission(permission_info.type, site_url_,
679 content_settings_)) {
mgiucaa319f212016-01-14 03:30:11680 continue;
csharrisonad1eaa6c2017-05-11 17:14:38681 }
mgiucaa319f212016-01-14 03:30:11682
[email protected]df818272012-04-20 13:10:50683 content_settings::SettingInfo info;
dcheng9603ab92016-04-08 04:17:32684 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
685 site_url_, site_url_, permission_info.type, std::string(), &info);
sashab2b2a314f2015-01-17 06:42:21686 DCHECK(value.get());
jdoerriedc72ee942016-12-07 15:43:28687 if (value->GetType() == base::Value::Type::INTEGER) {
sashab2b2a314f2015-01-17 06:42:21688 permission_info.setting =
689 content_settings::ValueToContentSetting(value.get());
[email protected]fe4686a2012-10-19 15:38:26690 } else {
sashab2b2a314f2015-01-17 06:42:21691 NOTREACHED();
[email protected]fe4686a2012-10-19 15:38:26692 }
693
[email protected]8bdf45c32012-08-04 00:12:55694 permission_info.source = info.source;
johnme9ed93882016-01-15 01:13:28695 permission_info.is_incognito = profile_->IsOffTheRecord();
[email protected]df818272012-04-20 13:10:50696
[email protected]b1d113d2012-06-27 21:27:34697 if (info.primary_pattern == ContentSettingsPattern::Wildcard() &&
sashab2b2a314f2015-01-17 06:42:21698 info.secondary_pattern == ContentSettingsPattern::Wildcard()) {
[email protected]b1d113d2012-06-27 21:27:34699 permission_info.default_setting = permission_info.setting;
700 permission_info.setting = CONTENT_SETTING_DEFAULT;
701 } else {
702 permission_info.default_setting =
703 content_settings_->GetDefaultContentSetting(permission_info.type,
704 NULL);
[email protected]df818272012-04-20 13:10:50705 }
palmer0da10b32015-02-11 00:42:19706
patricialor2a4f41a2017-03-08 02:52:56707 // For permissions that are still prompting the user and haven't been
708 // explicitly set by another source, check its embargo status.
709 if (PermissionUtil::IsPermission(permission_info.type) &&
710 permission_info.setting == CONTENT_SETTING_DEFAULT &&
711 permission_info.source ==
712 content_settings::SettingSource::SETTING_SOURCE_USER) {
713 // TODO(raymes): Use GetPermissionStatus() to retrieve information
714 // about *all* permissions once it has default behaviour implemented for
715 // ContentSettingTypes that aren't permissions.
716 PermissionResult permission_result =
717 PermissionManager::Get(profile_)->GetPermissionStatus(
718 permission_info.type, site_url_, site_url_);
719
720 // If under embargo, update |permission_info| to reflect that.
721 if (permission_result.content_setting == CONTENT_SETTING_BLOCK &&
722 (permission_result.source ==
723 PermissionStatusSource::MULTIPLE_DISMISSALS ||
724 permission_result.source ==
725 PermissionStatusSource::SAFE_BROWSING_BLACKLIST))
726 permission_info.setting = permission_result.content_setting;
727 }
728
palmer64a099982016-03-09 21:26:11729 permission_info_list.push_back(permission_info);
[email protected]df818272012-04-20 13:10:50730 }
731
reillyg85f57db2016-01-12 23:14:38732 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
733 ChooserContextBase* context = ui_info.get_context(profile_);
reillyg36a7fab32016-01-28 19:15:10734 const GURL origin = site_url_.GetOrigin();
735 auto chosen_objects = context->GetGrantedObjects(origin, origin);
dcheng9603ab92016-04-08 04:17:32736 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
reillyg85f57db2016-01-12 23:14:38737 chosen_object_info_list.push_back(
lgarron617a30f32017-03-24 21:42:07738 base::MakeUnique<PageInfoUI::ChosenObjectInfo>(ui_info,
739 std::move(object)));
reillyg85f57db2016-01-12 23:14:38740 }
741 }
742
avi09dd4d02016-10-14 20:40:09743 ui_->SetPermissionInfo(permission_info_list,
744 std::move(chosen_object_info_list));
[email protected]0b9fdd72012-04-04 10:00:33745}
746
lgarron617a30f32017-03-24 21:42:07747void PageInfo::PresentSiteData() {
[email protected]df818272012-04-20 13:10:50748 CookieInfoList cookie_info_list;
vabrbab3ffcb2016-10-04 10:08:10749 const LocalSharedObjectsContainer& allowed_objects =
[email protected]e0ac35892012-05-15 12:53:34750 tab_specific_content_settings()->allowed_local_shared_objects();
vabrbab3ffcb2016-10-04 10:08:10751 const LocalSharedObjectsContainer& blocked_objects =
[email protected]e0ac35892012-05-15 12:53:34752 tab_specific_content_settings()->blocked_local_shared_objects();
753
754 // Add first party cookie and site data counts.
lgarron617a30f32017-03-24 21:42:07755 PageInfoUI::CookieInfo cookie_info;
[email protected]e0ac35892012-05-15 12:53:34756 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
757 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
palmerb145264922015-08-28 23:53:15758 cookie_info.is_first_party = true;
[email protected]e0ac35892012-05-15 12:53:34759 cookie_info_list.push_back(cookie_info);
760
761 // Add third party cookie counts.
[email protected]e0ac35892012-05-15 12:53:34762 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
763 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
palmerb145264922015-08-28 23:53:15764 cookie_info.is_first_party = false;
[email protected]df818272012-04-20 13:10:50765 cookie_info_list.push_back(cookie_info);
[email protected]0b9fdd72012-04-04 10:00:33766
[email protected]df818272012-04-20 13:10:50767 ui_->SetCookieInfo(cookie_info_list);
[email protected]0b9fdd72012-04-04 10:00:33768}
[email protected]16de6de2012-04-04 12:24:14769
lgarron617a30f32017-03-24 21:42:07770void PageInfo::PresentSiteIdentity() {
palmerf9b680a2015-07-09 18:56:04771 // After initialization the status about the site's connection and its
772 // identity must be available.
[email protected]24c8818c2012-04-25 09:57:41773 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
774 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
lgarron617a30f32017-03-24 21:42:07775 PageInfoUI::IdentityInfo info;
[email protected]24c8818c2012-04-25 09:57:41776 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
777 info.site_identity = UTF16ToUTF8(organization_name());
778 else
jshin1fb76462016-04-05 22:13:03779 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
[email protected]24c8818c2012-04-25 09:57:41780
781 info.connection_status = site_connection_status_;
lgarron1a6300d2017-03-18 03:33:04782 info.connection_status_description = UTF16ToUTF8(site_connection_details_);
[email protected]24c8818c2012-04-25 09:57:41783 info.identity_status = site_identity_status_;
lgarron1a6300d2017-03-18 03:33:04784 info.identity_status_description = UTF16ToUTF8(site_identity_details_);
jam8ae7cad2016-09-08 23:55:21785 info.certificate = certificate_;
[email protected]71cd5ef2014-08-13 21:22:04786 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
[email protected]24c8818c2012-04-25 09:57:41787 ui_->SetIdentityInfo(info);
788}