| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_policy_backend.h" | 5 #include "chrome/browser/ssl/ssl_policy_backend.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "chrome/browser/profile.h" | 8 #include "chrome/browser/profile.h" |
| 9 #include "chrome/browser/ssl/ssl_host_state.h" | 9 #include "chrome/browser/ssl/ssl_host_state.h" |
| 10 #include "chrome/browser/tab_contents/infobar_delegate.h" | 10 #include "chrome/browser/tab_contents/infobar_delegate.h" |
| 11 #include "chrome/browser/tab_contents/navigation_controller.h" | 11 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 12 #include "chrome/browser/tab_contents/navigation_entry.h" | 12 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 13 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" |
| 14 #include "chrome/common/notification_service.h" | |
| 15 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 16 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
| 17 | 16 |
| 18 class SSLInfoBarDelegate : public ConfirmInfoBarDelegate { | 17 class SSLInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 19 public: | 18 public: |
| 20 SSLInfoBarDelegate(TabContents* contents, | 19 SSLInfoBarDelegate(TabContents* contents, |
| 21 const std::wstring message, | 20 const std::wstring message, |
| 22 const std::wstring& button_label, | 21 const std::wstring& button_label, |
| 23 Task* task) | 22 Task* task) |
| 24 : ConfirmInfoBarDelegate(contents), | 23 : ConfirmInfoBarDelegate(contents), |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 if (entry->ssl().security_style() <= SECURITY_STYLE_UNAUTHENTICATED) | 95 if (entry->ssl().security_style() <= SECURITY_STYLE_UNAUTHENTICATED) |
| 97 return; | 96 return; |
| 98 | 97 |
| 99 if (controller_->tab_contents()) { | 98 if (controller_->tab_contents()) { |
| 100 controller_->tab_contents()->AddInfoBar( | 99 controller_->tab_contents()->AddInfoBar( |
| 101 new SSLInfoBarDelegate(controller_->tab_contents(), msg, link_text, | 100 new SSLInfoBarDelegate(controller_->tab_contents(), msg, link_text, |
| 102 task)); | 101 task)); |
| 103 } | 102 } |
| 104 } | 103 } |
| 105 | 104 |
| 106 void SSLPolicyBackend::MarkHostAsBroken(const std::string& host, int id) { | 105 void SSLPolicyBackend::HostRanInsecureContent(const std::string& host, |
| 107 ssl_host_state_->MarkHostAsBroken(host, id); | 106 int id) { |
| 108 DispatchSSLInternalStateChanged(); | 107 ssl_host_state_->HostRanInsecureContent(host, id); |
| 108 SSLManager::NotifySSLInternalStateChanged(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 bool SSLPolicyBackend::DidMarkHostAsBroken(const std::string& host, | 111 bool SSLPolicyBackend::DidHostRunInsecureContent(const std::string& host, |
| 112 int pid) const { | 112 int pid) const { |
| 113 return ssl_host_state_->DidMarkHostAsBroken(host, pid); | 113 return ssl_host_state_->DidHostRunInsecureContent(host, pid); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void SSLPolicyBackend::DenyCertForHost(net::X509Certificate* cert, | 116 void SSLPolicyBackend::DenyCertForHost(net::X509Certificate* cert, |
| 117 const std::string& host) { | 117 const std::string& host) { |
| 118 ssl_host_state_->DenyCertForHost(cert, host); | 118 ssl_host_state_->DenyCertForHost(cert, host); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void SSLPolicyBackend::AllowCertForHost(net::X509Certificate* cert, | 121 void SSLPolicyBackend::AllowCertForHost(net::X509Certificate* cert, |
| 122 const std::string& host) { | 122 const std::string& host) { |
| 123 ssl_host_state_->AllowCertForHost(cert, host); | 123 ssl_host_state_->AllowCertForHost(cert, host); |
| 124 } | 124 } |
| 125 | 125 |
| 126 net::X509Certificate::Policy::Judgment SSLPolicyBackend::QueryPolicy( | 126 net::X509Certificate::Policy::Judgment SSLPolicyBackend::QueryPolicy( |
| 127 net::X509Certificate* cert, const std::string& host) { | 127 net::X509Certificate* cert, const std::string& host) { |
| 128 return ssl_host_state_->QueryPolicy(cert, host); | 128 return ssl_host_state_->QueryPolicy(cert, host); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void SSLPolicyBackend::DispatchSSLInternalStateChanged() { | |
| 132 NotificationService::current()->Notify( | |
| 133 NotificationType::SSL_INTERNAL_STATE_CHANGED, | |
| 134 Source<NavigationController>(controller_), | |
| 135 NotificationService::NoDetails()); | |
| 136 } | |
| 137 | |
| 138 void SSLPolicyBackend::ShowPendingMessages() { | 131 void SSLPolicyBackend::ShowPendingMessages() { |
| 139 std::vector<SSLMessageInfo>::const_iterator iter; | 132 std::vector<SSLMessageInfo>::const_iterator iter; |
| 140 for (iter = pending_messages_.begin(); | 133 for (iter = pending_messages_.begin(); |
| 141 iter != pending_messages_.end(); ++iter) { | 134 iter != pending_messages_.end(); ++iter) { |
| 142 ShowMessageWithLink(iter->message, iter->link_text, iter->action); | 135 ShowMessageWithLink(iter->message, iter->link_text, iter->action); |
| 143 } | 136 } |
| 144 ClearPendingMessages(); | 137 ClearPendingMessages(); |
| 145 } | 138 } |
| 146 | 139 |
| 147 void SSLPolicyBackend::ClearPendingMessages() { | 140 void SSLPolicyBackend::ClearPendingMessages() { |
| 148 pending_messages_.clear(); | 141 pending_messages_.clear(); |
| 149 } | 142 } |
| OLD | NEW |