| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/website_settings/website_settings.h" | 5 #include "chrome/browser/ui/website_settings/website_settings.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
| 14 #include "base/metrics/field_trial.h" | |
| 15 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 16 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/values.h" | 17 #include "base/values.h" |
| 19 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" | 18 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" |
| 20 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 19 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
| 21 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 20 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
| 22 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 21 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
| 23 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" | 22 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
| 24 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 23 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| 25 #include "chrome/browser/content_settings/content_settings_utils.h" | 24 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 26 #include "chrome/browser/content_settings/host_content_settings_map.h" | 25 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 27 #include "chrome/browser/content_settings/local_shared_objects_container.h" | 26 #include "chrome/browser/content_settings/local_shared_objects_container.h" |
| 28 #include "chrome/browser/history/history_service_factory.h" | 27 #include "chrome/browser/history/history_service_factory.h" |
| 29 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" | |
| 31 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" | |
| 32 #include "chrome/browser/ssl/ssl_error_info.h" | 29 #include "chrome/browser/ssl/ssl_error_info.h" |
| 33 #include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h
" | 30 #include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h
" |
| 34 #include "chrome/browser/ui/website_settings/website_settings_ui.h" | 31 #include "chrome/browser/ui/website_settings/website_settings_ui.h" |
| 35 #include "chrome/common/chrome_switches.h" | |
| 36 #include "chrome/common/content_settings_pattern.h" | 32 #include "chrome/common/content_settings_pattern.h" |
| 37 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 38 #include "content/public/browser/cert_store.h" | 34 #include "content/public/browser/cert_store.h" |
| 39 #include "content/public/browser/user_metrics.h" | 35 #include "content/public/browser/user_metrics.h" |
| 40 #include "content/public/common/content_switches.h" | 36 #include "content/public/common/content_switches.h" |
| 41 #include "content/public/common/ssl_status.h" | 37 #include "content/public/common/ssl_status.h" |
| 42 #include "content/public/common/url_constants.h" | 38 #include "content/public/common/url_constants.h" |
| 43 #include "grit/chromium_strings.h" | 39 #include "grit/chromium_strings.h" |
| 44 #include "grit/generated_resources.h" | 40 #include "grit/generated_resources.h" |
| 45 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 41 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 WebsiteSettings::SiteIdentityStatus GetSiteIdentityStatusByCTInfo( | 114 WebsiteSettings::SiteIdentityStatus GetSiteIdentityStatusByCTInfo( |
| 119 const content::SignedCertificateTimestampIDStatusList& scts, | 115 const content::SignedCertificateTimestampIDStatusList& scts, |
| 120 bool is_ev) { | 116 bool is_ev) { |
| 121 if (CertificateTransparencyStatusMatch(scts, net::ct::SCT_STATUS_INVALID)) | 117 if (CertificateTransparencyStatusMatch(scts, net::ct::SCT_STATUS_INVALID)) |
| 122 return WebsiteSettings::SITE_IDENTITY_STATUS_ERROR; | 118 return WebsiteSettings::SITE_IDENTITY_STATUS_ERROR; |
| 123 | 119 |
| 124 return is_ev ? WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT | 120 return is_ev ? WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT |
| 125 : WebsiteSettings::SITE_IDENTITY_STATUS_CERT; | 121 : WebsiteSettings::SITE_IDENTITY_STATUS_CERT; |
| 126 } | 122 } |
| 127 | 123 |
| 128 const char kRememberCertificateErrorDecisionsFieldTrialName[] = | |
| 129 "RememberCertificateErrorDecisions"; | |
| 130 const char kRememberCertificateErrorDecisionsFieldTrialDefaultGroup[] = | |
| 131 "Default"; | |
| 132 const char kRememberCertificateErrorDecisionsFieldTrialDisableGroup[] = | |
| 133 "Disable"; | |
| 134 // Returns true if the user is in the experimental group or has the flag enabled | |
| 135 // for remembering SSL error decisions, otherwise false. | |
| 136 // | |
| 137 // TODO(jww): The field trial is scheduled to end 2015/02/28. This should be | |
| 138 // removed at that point unless the field trial or flag continues. | |
| 139 bool InRememberCertificateErrorDecisionsGroup() { | |
| 140 std::string group_name = base::FieldTrialList::FindFullName( | |
| 141 kRememberCertificateErrorDecisionsFieldTrialName); | |
| 142 | |
| 143 // The Default and Disable groups are the "old-style" forget-at-session | |
| 144 // restart groups, so they do not get the button. | |
| 145 bool in_experimental_group = !group_name.empty() && | |
| 146 group_name.compare( | |
| 147 kRememberCertificateErrorDecisionsFieldTrialDefaultGroup) != 0 && | |
| 148 group_name.compare( | |
| 149 kRememberCertificateErrorDecisionsFieldTrialDisableGroup) != 0; | |
| 150 bool has_command_line_switch = CommandLine::ForCurrentProcess()->HasSwitch( | |
| 151 switches::kRememberCertErrorDecisions); | |
| 152 return in_experimental_group || has_command_line_switch; | |
| 153 } | |
| 154 | |
| 155 } // namespace | 124 } // namespace |
| 156 | 125 |
| 157 WebsiteSettings::WebsiteSettings( | 126 WebsiteSettings::WebsiteSettings( |
| 158 WebsiteSettingsUI* ui, | 127 WebsiteSettingsUI* ui, |
| 159 Profile* profile, | 128 Profile* profile, |
| 160 TabSpecificContentSettings* tab_specific_content_settings, | 129 TabSpecificContentSettings* tab_specific_content_settings, |
| 161 InfoBarService* infobar_service, | 130 InfoBarService* infobar_service, |
| 162 const GURL& url, | 131 const GURL& url, |
| 163 const content::SSLStatus& ssl, | 132 const content::SSLStatus& ssl, |
| 164 content::CertStore* cert_store) | 133 content::CertStore* cert_store) |
| 165 : TabSpecificContentSettings::SiteDataObserver( | 134 : TabSpecificContentSettings::SiteDataObserver( |
| 166 tab_specific_content_settings), | 135 tab_specific_content_settings), |
| 167 ui_(ui), | 136 ui_(ui), |
| 168 infobar_service_(infobar_service), | 137 infobar_service_(infobar_service), |
| 169 show_info_bar_(false), | 138 show_info_bar_(false), |
| 170 site_url_(url), | 139 site_url_(url), |
| 171 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN), | 140 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN), |
| 172 cert_id_(0), | 141 cert_id_(0), |
| 173 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN), | 142 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN), |
| 174 cert_store_(cert_store), | 143 cert_store_(cert_store), |
| 175 content_settings_(profile->GetHostContentSettingsMap()), | 144 content_settings_(profile->GetHostContentSettingsMap()) { |
| 176 chrome_ssl_host_state_delegate_( | |
| 177 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)) { | |
| 178 Init(profile, url, ssl); | 145 Init(profile, url, ssl); |
| 179 | 146 |
| 180 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 147 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
| 181 profile, Profile::EXPLICIT_ACCESS); | 148 profile, Profile::EXPLICIT_ACCESS); |
| 182 if (history_service) { | 149 if (history_service) { |
| 183 history_service->GetVisibleVisitCountToHost( | 150 history_service->GetVisibleVisitCountToHost( |
| 184 site_url_, | 151 site_url_, |
| 185 base::Bind(&WebsiteSettings::OnGotVisitCountToHost, | 152 base::Bind(&WebsiteSettings::OnGotVisitCountToHost, |
| 186 base::Unretained(this)), | 153 base::Unretained(this)), |
| 187 &visit_count_task_tracker_); | 154 &visit_count_task_tracker_); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 site_connection_details_ += l10n_util::GetStringUTF16( | 525 site_connection_details_ += l10n_util::GetStringUTF16( |
| 559 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE); | 526 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE); |
| 560 } | 527 } |
| 561 if (no_renegotiation) { | 528 if (no_renegotiation) { |
| 562 site_connection_details_ += ASCIIToUTF16("\n\n"); | 529 site_connection_details_ += ASCIIToUTF16("\n\n"); |
| 563 site_connection_details_ += l10n_util::GetStringUTF16( | 530 site_connection_details_ += l10n_util::GetStringUTF16( |
| 564 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE); | 531 IDS_PAGE_INFO_SECURITY_TAB_RENEGOTIATION_MESSAGE); |
| 565 } | 532 } |
| 566 } | 533 } |
| 567 | 534 |
| 568 // Check if a user decision has been made to allow or deny certificates with | |
| 569 // errors on this site. | |
| 570 ChromeSSLHostStateDelegate* delegate = | |
| 571 ChromeSSLHostStateDelegateFactory::GetForProfile(profile); | |
| 572 DCHECK(delegate); | |
| 573 // Only show an SSL decision revoke button if both the user has chosen to | |
| 574 // bypass SSL host errors for this host in the past and the user is not using | |
| 575 // the traditional "forget-at-session-restart" error decision memory. | |
| 576 show_ssl_decision_revoke_button_ = delegate->HasUserDecision(url.host()) && | |
| 577 InRememberCertificateErrorDecisionsGroup(); | |
| 578 | |
| 579 // By default select the permissions tab that displays all the site | 535 // By default select the permissions tab that displays all the site |
| 580 // permissions. In case of a connection error or an issue with the | 536 // permissions. In case of a connection error or an issue with the |
| 581 // certificate presented by the website, select the connection tab to draw | 537 // certificate presented by the website, select the connection tab to draw |
| 582 // the user's attention to the issue. If the site does not provide a | 538 // the user's attention to the issue. If the site does not provide a |
| 583 // certificate because it was loaded over an unencrypted connection, don't | 539 // certificate because it was loaded over an unencrypted connection, don't |
| 584 // select the connection tab. | 540 // select the connection tab. |
| 585 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS; | 541 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS; |
| 586 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR || | 542 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR || |
| 587 site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_CONTENT || | 543 site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_CONTENT || |
| 588 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR || | 544 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR || |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 info.connection_status = site_connection_status_; | 658 info.connection_status = site_connection_status_; |
| 703 info.connection_status_description = | 659 info.connection_status_description = |
| 704 UTF16ToUTF8(site_connection_details_); | 660 UTF16ToUTF8(site_connection_details_); |
| 705 info.identity_status = site_identity_status_; | 661 info.identity_status = site_identity_status_; |
| 706 info.identity_status_description = | 662 info.identity_status_description = |
| 707 UTF16ToUTF8(site_identity_details_); | 663 UTF16ToUTF8(site_identity_details_); |
| 708 info.cert_id = cert_id_; | 664 info.cert_id = cert_id_; |
| 709 info.signed_certificate_timestamp_ids.assign( | 665 info.signed_certificate_timestamp_ids.assign( |
| 710 signed_certificate_timestamp_ids_.begin(), | 666 signed_certificate_timestamp_ids_.begin(), |
| 711 signed_certificate_timestamp_ids_.end()); | 667 signed_certificate_timestamp_ids_.end()); |
| 712 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; | |
| 713 ui_->SetIdentityInfo(info); | 668 ui_->SetIdentityInfo(info); |
| 714 } | 669 } |
| 715 | 670 |
| 716 void WebsiteSettings::PresentHistoryInfo(base::Time first_visit) { | 671 void WebsiteSettings::PresentHistoryInfo(base::Time first_visit) { |
| 717 if (first_visit == base::Time()) { | 672 if (first_visit == base::Time()) { |
| 718 ui_->SetFirstVisit(base::string16()); | 673 ui_->SetFirstVisit(base::string16()); |
| 719 return; | 674 return; |
| 720 } | 675 } |
| 721 | 676 |
| 722 bool visited_before_today = false; | 677 bool visited_before_today = false; |
| 723 base::Time today = base::Time::Now().LocalMidnight(); | 678 base::Time today = base::Time::Now().LocalMidnight(); |
| 724 base::Time first_visit_midnight = first_visit.LocalMidnight(); | 679 base::Time first_visit_midnight = first_visit.LocalMidnight(); |
| 725 visited_before_today = (first_visit_midnight < today); | 680 visited_before_today = (first_visit_midnight < today); |
| 726 | 681 |
| 727 base::string16 first_visit_text; | 682 base::string16 first_visit_text; |
| 728 if (visited_before_today) { | 683 if (visited_before_today) { |
| 729 first_visit_text = l10n_util::GetStringFUTF16( | 684 first_visit_text = l10n_util::GetStringFUTF16( |
| 730 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY, | 685 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY, |
| 731 base::TimeFormatShortDate(first_visit)); | 686 base::TimeFormatShortDate(first_visit)); |
| 732 } else { | 687 } else { |
| 733 first_visit_text = l10n_util::GetStringUTF16( | 688 first_visit_text = l10n_util::GetStringUTF16( |
| 734 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY); | 689 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY); |
| 735 } | 690 } |
| 736 ui_->SetFirstVisit(first_visit_text); | 691 ui_->SetFirstVisit(first_visit_text); |
| 737 } | 692 } |
| OLD | NEW |