Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Side by Side Diff: content/browser/ssl/ssl_manager.cc

Issue 403933002: Set SSL info when an HTTP auth dialog is triggered by direct navigation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Set SSL status in ResourceLoader Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/browser/ssl/ssl_manager.h" 5 #include "content/browser/ssl/ssl_manager.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 id, 73 id,
74 resource_type, 74 resource_type,
75 url, 75 url,
76 render_process_id, 76 render_process_id,
77 render_frame_id, 77 render_frame_id,
78 ssl_info, 78 ssl_info,
79 fatal))); 79 fatal)));
80 } 80 }
81 81
82 // static 82 // static
83 void SSLManager::OnAuthDialog(int render_process_id,
84 int render_frame_host,
85 const std::string& serialized_security_info,
86 bool is_main_frame) {
87 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
88 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
89 base::Bind(SSLManager::OnAuthDialog,
90 render_process_id,
91 render_frame_host,
92 serialized_security_info,
93 is_main_frame));
94 return;
95 }
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
nasko 2014/07/24 09:32:34 This DCHECK seems useless because of the if statem
meacer 2014/07/24 17:32:32 Done.
97 RenderFrameHost* host =
98 RenderFrameHostImpl::FromID(render_process_id, render_frame_host);
99 WebContentsImpl* web_contents =
100 static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host));
nasko 2014/07/24 09:32:34 Why do you need to cast this? GetController() is a
meacer 2014/07/24 17:32:32 I agree it's confusing. It's now casting Navigatio
101 if (!web_contents)
102 return;
103
104 NavigationControllerImpl* controller = &web_contents->GetController();
nasko 2014/07/24 09:32:34 Ah, this is the place where a cast will be needed.
meacer 2014/07/24 17:32:32 Acknowledged.
105 NavigationEntryImpl* entry =
106 NavigationEntryImpl::FromNavigationEntry(controller->GetVisibleEntry());
107
108 scoped_ptr<SSLManager> ssl_manager(new SSLManager(controller));
nasko 2014/07/24 09:32:34 Why do we need to construct a SSLManager? The nav
meacer 2014/07/24 17:32:32 Done.
109 ssl_manager->UpdateEntry(serialized_security_info,
110 is_main_frame,
111 entry);
112 }
113
114 // static
83 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { 115 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) {
84 SSLManagerSet* managers = static_cast<SSLManagerSet*>( 116 SSLManagerSet* managers = static_cast<SSLManagerSet*>(
85 context->GetUserData(kSSLManagerKeyName)); 117 context->GetUserData(kSSLManagerKeyName));
86 118
87 for (std::set<SSLManager*>::iterator i = managers->get().begin(); 119 for (std::set<SSLManager*>::iterator i = managers->get().begin();
88 i != managers->get().end(); ++i) { 120 i != managers->get().end(); ++i) {
89 (*i)->UpdateEntry(NavigationEntryImpl::FromNavigationEntry( 121 (*i)->UpdateEntry(NavigationEntryImpl::FromNavigationEntry(
90 (*i)->controller()->GetLastCommittedEntry())); 122 (*i)->controller()->GetLastCommittedEntry()));
91 } 123 }
92 } 124 }
(...skipping 16 matching lines...) Expand all
109 SSLManager::~SSLManager() { 141 SSLManager::~SSLManager() {
110 SSLManagerSet* managers = static_cast<SSLManagerSet*>( 142 SSLManagerSet* managers = static_cast<SSLManagerSet*>(
111 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName)); 143 controller_->GetBrowserContext()->GetUserData(kSSLManagerKeyName));
112 managers->get().erase(this); 144 managers->get().erase(this);
113 } 145 }
114 146
115 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) { 147 void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) {
116 NavigationEntryImpl* entry = 148 NavigationEntryImpl* entry =
117 NavigationEntryImpl::FromNavigationEntry( 149 NavigationEntryImpl::FromNavigationEntry(
118 controller_->GetLastCommittedEntry()); 150 controller_->GetLastCommittedEntry());
151 UpdateEntry(details.serialized_security_info,
152 details.is_main_frame,
153 entry);
154 }
119 155
120 if (details.is_main_frame) { 156 void SSLManager::UpdateEntry(const std::string& serialized_security_info,
nasko 2014/07/24 09:32:34 nit: all params should be on new lines
meacer 2014/07/24 17:32:32 Done.
121 if (entry) { 157 bool is_main_frame,
122 // Decode the security details. 158 NavigationEntryImpl* entry) {
123 int ssl_cert_id; 159 if (is_main_frame && entry) {
124 net::CertStatus ssl_cert_status; 160 // Decode the security details.
125 int ssl_security_bits; 161 int ssl_cert_id;
126 int ssl_connection_status; 162 net::CertStatus ssl_cert_status;
127 SignedCertificateTimestampIDStatusList 163 int ssl_security_bits;
128 ssl_signed_certificate_timestamp_ids; 164 int ssl_connection_status;
129 DeserializeSecurityInfo(details.serialized_security_info, 165 SignedCertificateTimestampIDStatusList
130 &ssl_cert_id, 166 ssl_signed_certificate_timestamp_ids;
131 &ssl_cert_status, 167 DeserializeSecurityInfo(serialized_security_info,
132 &ssl_security_bits, 168 &ssl_cert_id,
133 &ssl_connection_status, 169 &ssl_cert_status,
134 &ssl_signed_certificate_timestamp_ids); 170 &ssl_security_bits,
171 &ssl_connection_status,
172 &ssl_signed_certificate_timestamp_ids);
135 173
136 // We may not have an entry if this is a navigation to an initial blank 174 // We may not have an entry if this is a navigation to an initial blank
137 // page. Reset the SSL information and add the new data we have. 175 // page. Reset the SSL information and add the new data we have.
138 entry->GetSSL() = SSLStatus(); 176 entry->GetSSL() = SSLStatus();
139 entry->GetSSL().cert_id = ssl_cert_id; 177 entry->GetSSL().cert_id = ssl_cert_id;
140 entry->GetSSL().cert_status = ssl_cert_status; 178 entry->GetSSL().cert_status = ssl_cert_status;
141 entry->GetSSL().security_bits = ssl_security_bits; 179 entry->GetSSL().security_bits = ssl_security_bits;
142 entry->GetSSL().connection_status = ssl_connection_status; 180 entry->GetSSL().connection_status = ssl_connection_status;
143 entry->GetSSL().signed_certificate_timestamp_ids = 181 entry->GetSSL().signed_certificate_timestamp_ids =
144 ssl_signed_certificate_timestamp_ids; 182 ssl_signed_certificate_timestamp_ids;
145 }
146 } 183 }
147
148 UpdateEntry(entry); 184 UpdateEntry(entry);
149 } 185 }
150 186
151 void SSLManager::DidDisplayInsecureContent() { 187 void SSLManager::DidDisplayInsecureContent() {
152 UpdateEntry( 188 UpdateEntry(
153 NavigationEntryImpl::FromNavigationEntry( 189 NavigationEntryImpl::FromNavigationEntry(
154 controller_->GetLastCommittedEntry())); 190 controller_->GetLastCommittedEntry()));
155 } 191 }
156 192
157 void SSLManager::DidRunInsecureContent(const std::string& security_origin) { 193 void SSLManager::DidRunInsecureContent(const std::string& security_origin) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 250
215 WebContentsImpl* contents = 251 WebContentsImpl* contents =
216 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); 252 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents());
217 policy()->UpdateEntry(entry, contents); 253 policy()->UpdateEntry(entry, contents);
218 254
219 if (!entry->GetSSL().Equals(original_ssl_status)) 255 if (!entry->GetSSL().Equals(original_ssl_status))
220 contents->DidChangeVisibleSSLState(); 256 contents->DidChangeVisibleSSLState();
221 } 257 }
222 258
223 } // namespace content 259 } // namespace content
OLDNEW
« content/browser/loader/resource_loader.cc ('K') | « content/browser/ssl/ssl_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698