| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/ssl/ssl_blocking_page.h" | 5 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 6 | 6 |
| 7 #include "base/histogram.h" |
| 7 #include "base/string_piece.h" | 8 #include "base/string_piece.h" |
| 8 #include "base/values.h" | 9 #include "base/values.h" |
| 9 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
| 10 #include "chrome/browser/cert_store.h" | 11 #include "chrome/browser/cert_store.h" |
| 11 #include "chrome/browser/dom_operation_notification_details.h" | 12 #include "chrome/browser/dom_operation_notification_details.h" |
| 12 #include "chrome/browser/ssl/ssl_error_info.h" | 13 #include "chrome/browser/ssl/ssl_error_info.h" |
| 13 #include "chrome/browser/tab_contents/navigation_controller.h" | 14 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 14 #include "chrome/browser/tab_contents/navigation_entry.h" | 15 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 15 #include "chrome/browser/tab_contents/web_contents.h" | 16 #include "chrome/browser/tab_contents/web_contents.h" |
| 16 #include "chrome/common/jstemplate_builder.h" | 17 #include "chrome/common/jstemplate_builder.h" |
| 17 #include "chrome/common/l10n_util.h" | 18 #include "chrome/common/l10n_util.h" |
| 18 #include "chrome/common/notification_service.h" | 19 #include "chrome/common/notification_service.h" |
| 19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 20 #include "chrome/common/pref_service.h" | 21 #include "chrome/common/pref_service.h" |
| 21 #include "chrome/common/resource_bundle.h" | 22 #include "chrome/common/resource_bundle.h" |
| 22 #include "grit/browser_resources.h" | 23 #include "grit/browser_resources.h" |
| 23 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 24 | 25 |
| 26 namespace { |
| 27 |
| 28 enum SSLBlockingPageEvent { |
| 29 SHOW, |
| 30 PROCEED, |
| 31 DONT_PROCEED, |
| 32 }; |
| 33 |
| 34 void RecordSSLBlockingPageStats(SSLBlockingPageEvent event) { |
| 35 static LinearHistogram histogram("interstial.ssl", 0, 2, 4); |
| 36 histogram.SetFlags(kUmaTargetedHistogramFlag); |
| 37 histogram.Add(event); |
| 38 } |
| 39 |
| 40 } // namespace |
| 41 |
| 25 // Note that we always create a navigation entry with SSL errors. | 42 // Note that we always create a navigation entry with SSL errors. |
| 26 // No error happening loading a sub-resource triggers an interstitial so far. | 43 // No error happening loading a sub-resource triggers an interstitial so far. |
| 27 SSLBlockingPage::SSLBlockingPage(SSLManager::CertError* error, | 44 SSLBlockingPage::SSLBlockingPage(SSLManager::CertError* error, |
| 28 Delegate* delegate) | 45 Delegate* delegate) |
| 29 : InterstitialPage(error->GetWebContents(), true, error->request_url()), | 46 : InterstitialPage(error->GetWebContents(), true, error->request_url()), |
| 30 error_(error), | 47 error_(error), |
| 31 delegate_(delegate), | 48 delegate_(delegate), |
| 32 delegate_has_been_notified_(false) { | 49 delegate_has_been_notified_(false) { |
| 50 RecordSSLBlockingPageStats(SHOW); |
| 33 } | 51 } |
| 34 | 52 |
| 35 SSLBlockingPage::~SSLBlockingPage() { | 53 SSLBlockingPage::~SSLBlockingPage() { |
| 36 if (!delegate_has_been_notified_) { | 54 if (!delegate_has_been_notified_) { |
| 37 // The page is closed without the user having chosen what to do, default to | 55 // The page is closed without the user having chosen what to do, default to |
| 38 // deny. | 56 // deny. |
| 39 NotifyDenyCertificate(); | 57 NotifyDenyCertificate(); |
| 40 } | 58 } |
| 41 } | 59 } |
| 42 | 60 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 105 |
| 88 void SSLBlockingPage::CommandReceived(const std::string& command) { | 106 void SSLBlockingPage::CommandReceived(const std::string& command) { |
| 89 if (command == "1") { | 107 if (command == "1") { |
| 90 Proceed(); | 108 Proceed(); |
| 91 } else { | 109 } else { |
| 92 DontProceed(); | 110 DontProceed(); |
| 93 } | 111 } |
| 94 } | 112 } |
| 95 | 113 |
| 96 void SSLBlockingPage::Proceed() { | 114 void SSLBlockingPage::Proceed() { |
| 115 RecordSSLBlockingPageStats(PROCEED); |
| 116 |
| 97 // Accepting the certificate resumes the loading of the page. | 117 // Accepting the certificate resumes the loading of the page. |
| 98 NotifyAllowCertificate(); | 118 NotifyAllowCertificate(); |
| 99 | 119 |
| 100 // This call hides and deletes the interstitial. | 120 // This call hides and deletes the interstitial. |
| 101 InterstitialPage::Proceed(); | 121 InterstitialPage::Proceed(); |
| 102 } | 122 } |
| 103 | 123 |
| 104 void SSLBlockingPage::DontProceed() { | 124 void SSLBlockingPage::DontProceed() { |
| 125 RecordSSLBlockingPageStats(DONT_PROCEED); |
| 126 |
| 105 NotifyDenyCertificate(); | 127 NotifyDenyCertificate(); |
| 106 InterstitialPage::DontProceed(); | 128 InterstitialPage::DontProceed(); |
| 107 } | 129 } |
| 108 | 130 |
| 109 | |
| 110 void SSLBlockingPage::NotifyDenyCertificate() { | 131 void SSLBlockingPage::NotifyDenyCertificate() { |
| 111 DCHECK(!delegate_has_been_notified_); | 132 DCHECK(!delegate_has_been_notified_); |
| 112 | 133 |
| 113 delegate_->OnDenyCertificate(error_); | 134 delegate_->OnDenyCertificate(error_); |
| 114 delegate_has_been_notified_ = true; | 135 delegate_has_been_notified_ = true; |
| 115 } | 136 } |
| 116 | 137 |
| 117 void SSLBlockingPage::NotifyAllowCertificate() { | 138 void SSLBlockingPage::NotifyAllowCertificate() { |
| 118 DCHECK(!delegate_has_been_notified_); | 139 DCHECK(!delegate_has_been_notified_); |
| 119 | 140 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 130 L"moreInfo1", L"moreInfo2", L"moreInfo3", L"moreInfo4", L"moreInfo5" | 151 L"moreInfo1", L"moreInfo2", L"moreInfo3", L"moreInfo4", L"moreInfo5" |
| 131 }; | 152 }; |
| 132 int i; | 153 int i; |
| 133 for (i = 0; i < static_cast<int>(extra_info.size()); i++) { | 154 for (i = 0; i < static_cast<int>(extra_info.size()); i++) { |
| 134 strings->SetString(keys[i], extra_info[i]); | 155 strings->SetString(keys[i], extra_info[i]); |
| 135 } | 156 } |
| 136 for (;i < 5; i++) { | 157 for (;i < 5; i++) { |
| 137 strings->SetString(keys[i], L""); | 158 strings->SetString(keys[i], L""); |
| 138 } | 159 } |
| 139 } | 160 } |
| OLD | NEW |