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

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

Issue 2467773002: Notify SSLManager when all password fields on a page are gone (Closed)
Patch Set: tweak SSLManager comment Created 4 years, 1 month 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
« no previous file with comments | « content/browser/ssl/ssl_manager.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/macros.h" 10 #include "base/macros.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 if (!details.is_main_frame) { 177 if (!details.is_main_frame) {
178 // If it wasn't a main-frame navigation, then carry over content 178 // If it wasn't a main-frame navigation, then carry over content
179 // status flags. (For example, the mixed content flag shouldn't 179 // status flags. (For example, the mixed content flag shouldn't
180 // clear because of a frame navigation.) 180 // clear because of a frame navigation.)
181 NavigationEntryImpl* previous_entry = 181 NavigationEntryImpl* previous_entry =
182 controller_->GetEntryAtIndex(details.previous_entry_index); 182 controller_->GetEntryAtIndex(details.previous_entry_index);
183 if (previous_entry) { 183 if (previous_entry) {
184 content_status_flags = previous_entry->GetSSL().content_status; 184 content_status_flags = previous_entry->GetSSL().content_status;
185 } 185 }
186 } 186 }
187 UpdateEntry(entry, content_status_flags); 187 UpdateEntry(entry, content_status_flags, 0);
188 // Always notify the WebContents that the SSL state changed when a 188 // Always notify the WebContents that the SSL state changed when a
189 // load is committed, in case the active navigation entry has changed. 189 // load is committed, in case the active navigation entry has changed.
190 NotifyDidChangeVisibleSSLState(); 190 NotifyDidChangeVisibleSSLState();
191 } 191 }
192 192
193 void SSLManager::DidDisplayMixedContent() { 193 void SSLManager::DidDisplayMixedContent() {
194 UpdateLastCommittedEntry(SSLStatus::DISPLAYED_INSECURE_CONTENT); 194 UpdateLastCommittedEntry(SSLStatus::DISPLAYED_INSECURE_CONTENT, 0);
195 } 195 }
196 196
197 void SSLManager::DidDisplayContentWithCertErrors() { 197 void SSLManager::DidDisplayContentWithCertErrors() {
198 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry(); 198 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry();
199 if (!entry) 199 if (!entry)
200 return; 200 return;
201 // Only record information about subresources with cert errors if the 201 // Only record information about subresources with cert errors if the
202 // main page is HTTPS with a certificate. 202 // main page is HTTPS with a certificate.
203 if (entry->GetURL().SchemeIsCryptographic() && entry->GetSSL().certificate) { 203 if (entry->GetURL().SchemeIsCryptographic() && entry->GetSSL().certificate) {
204 UpdateLastCommittedEntry(SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS); 204 UpdateLastCommittedEntry(SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS, 0);
205 } 205 }
206 } 206 }
207 207
208 void SSLManager::DidShowPasswordInputOnHttp() { 208 void SSLManager::DidShowPasswordInputOnHttp() {
209 UpdateLastCommittedEntry(SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); 209 UpdateLastCommittedEntry(SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP, 0);
210 }
211
212 void SSLManager::DidHideAllPasswordInputsOnHttp() {
213 UpdateLastCommittedEntry(0, SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP);
210 } 214 }
211 215
212 void SSLManager::DidShowCreditCardInputOnHttp() { 216 void SSLManager::DidShowCreditCardInputOnHttp() {
213 UpdateLastCommittedEntry(SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP); 217 UpdateLastCommittedEntry(SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP, 0);
214 } 218 }
215 219
216 void SSLManager::DidRunMixedContent(const GURL& security_origin) { 220 void SSLManager::DidRunMixedContent(const GURL& security_origin) {
217 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry(); 221 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry();
218 if (!entry) 222 if (!entry)
219 return; 223 return;
220 224
221 SiteInstance* site_instance = entry->site_instance(); 225 SiteInstance* site_instance = entry->site_instance();
222 if (!site_instance) 226 if (!site_instance)
223 return; 227 return;
224 228
225 if (ssl_host_state_delegate_) { 229 if (ssl_host_state_delegate_) {
226 ssl_host_state_delegate_->HostRanInsecureContent( 230 ssl_host_state_delegate_->HostRanInsecureContent(
227 security_origin.host(), site_instance->GetProcess()->GetID(), 231 security_origin.host(), site_instance->GetProcess()->GetID(),
228 SSLHostStateDelegate::MIXED_CONTENT); 232 SSLHostStateDelegate::MIXED_CONTENT);
229 } 233 }
230 UpdateEntry(entry, 0); 234 UpdateEntry(entry, 0, 0);
231 NotifySSLInternalStateChanged(controller_->GetBrowserContext()); 235 NotifySSLInternalStateChanged(controller_->GetBrowserContext());
232 } 236 }
233 237
234 void SSLManager::DidRunContentWithCertErrors(const GURL& security_origin) { 238 void SSLManager::DidRunContentWithCertErrors(const GURL& security_origin) {
235 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry(); 239 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry();
236 if (!entry) 240 if (!entry)
237 return; 241 return;
238 242
239 SiteInstance* site_instance = entry->site_instance(); 243 SiteInstance* site_instance = entry->site_instance();
240 if (!site_instance) 244 if (!site_instance)
241 return; 245 return;
242 246
243 if (ssl_host_state_delegate_) { 247 if (ssl_host_state_delegate_) {
244 ssl_host_state_delegate_->HostRanInsecureContent( 248 ssl_host_state_delegate_->HostRanInsecureContent(
245 security_origin.host(), site_instance->GetProcess()->GetID(), 249 security_origin.host(), site_instance->GetProcess()->GetID(),
246 SSLHostStateDelegate::CERT_ERRORS_CONTENT); 250 SSLHostStateDelegate::CERT_ERRORS_CONTENT);
247 } 251 }
248 UpdateEntry(entry, 0); 252 UpdateEntry(entry, 0, 0);
249 NotifySSLInternalStateChanged(controller_->GetBrowserContext()); 253 NotifySSLInternalStateChanged(controller_->GetBrowserContext());
250 } 254 }
251 255
252 void SSLManager::OnCertError(std::unique_ptr<SSLErrorHandler> handler) { 256 void SSLManager::OnCertError(std::unique_ptr<SSLErrorHandler> handler) {
253 bool expired_previous_decision = false; 257 bool expired_previous_decision = false;
254 // First we check if we know the policy for this error. 258 // First we check if we know the policy for this error.
255 DCHECK(handler->ssl_info().is_valid()); 259 DCHECK(handler->ssl_info().is_valid());
256 SSLHostStateDelegate::CertJudgment judgment = 260 SSLHostStateDelegate::CertJudgment judgment =
257 ssl_host_state_delegate_ 261 ssl_host_state_delegate_
258 ? ssl_host_state_delegate_->QueryPolicy( 262 ? ssl_host_state_delegate_->QueryPolicy(
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 const GURL& request_url = handler->request_url(); 355 const GURL& request_url = handler->request_url();
352 ResourceType resource_type = handler->resource_type(); 356 ResourceType resource_type = handler->resource_type();
353 GetContentClient()->browser()->AllowCertificateError( 357 GetContentClient()->browser()->AllowCertificateError(
354 web_contents, cert_error, ssl_info, request_url, resource_type, 358 web_contents, cert_error, ssl_info, request_url, resource_type,
355 overridable, strict_enforcement, expired_previous_decision, 359 overridable, strict_enforcement, expired_previous_decision,
356 base::Bind(&OnAllowCertificate, base::Owned(handler.release()), 360 base::Bind(&OnAllowCertificate, base::Owned(handler.release()),
357 ssl_host_state_delegate_)); 361 ssl_host_state_delegate_));
358 } 362 }
359 363
360 void SSLManager::UpdateEntry(NavigationEntryImpl* entry, 364 void SSLManager::UpdateEntry(NavigationEntryImpl* entry,
361 int additional_content_status_flags) { 365 int add_content_status_flags,
366 int remove_content_status_flags) {
362 // We don't always have a navigation entry to update, for example in the 367 // We don't always have a navigation entry to update, for example in the
363 // case of the Web Inspector. 368 // case of the Web Inspector.
364 if (!entry) 369 if (!entry)
365 return; 370 return;
366 371
367 SSLStatus original_ssl_status = entry->GetSSL(); // Copy! 372 SSLStatus original_ssl_status = entry->GetSSL(); // Copy!
368 entry->GetSSL().initialized = true; 373 entry->GetSSL().initialized = true;
369 entry->GetSSL().content_status |= additional_content_status_flags; 374 entry->GetSSL().content_status |= add_content_status_flags;
375 entry->GetSSL().content_status &= ~remove_content_status_flags;
370 376
371 SiteInstance* site_instance = entry->site_instance(); 377 SiteInstance* site_instance = entry->site_instance();
372 // Note that |site_instance| can be NULL here because NavigationEntries don't 378 // Note that |site_instance| can be NULL here because NavigationEntries don't
373 // necessarily have site instances. Without a process, the entry can't 379 // necessarily have site instances. Without a process, the entry can't
374 // possibly have insecure content. See bug https://crbug.com/12423. 380 // possibly have insecure content. See bug https://crbug.com/12423.
375 if (site_instance && ssl_host_state_delegate_) { 381 if (site_instance && ssl_host_state_delegate_) {
376 std::string host = entry->GetURL().host(); 382 std::string host = entry->GetURL().host();
377 int process_id = site_instance->GetProcess()->GetID(); 383 int process_id = site_instance->GetProcess()->GetID();
378 if (ssl_host_state_delegate_->DidHostRunInsecureContent( 384 if (ssl_host_state_delegate_->DidHostRunInsecureContent(
379 host, process_id, SSLHostStateDelegate::MIXED_CONTENT)) { 385 host, process_id, SSLHostStateDelegate::MIXED_CONTENT)) {
380 entry->GetSSL().content_status |= SSLStatus::RAN_INSECURE_CONTENT; 386 entry->GetSSL().content_status |= SSLStatus::RAN_INSECURE_CONTENT;
381 } 387 }
382 388
383 // Only record information about subresources with cert errors if the 389 // Only record information about subresources with cert errors if the
384 // main page is HTTPS with a certificate. 390 // main page is HTTPS with a certificate.
385 if (entry->GetURL().SchemeIsCryptographic() && 391 if (entry->GetURL().SchemeIsCryptographic() &&
386 entry->GetSSL().certificate && 392 entry->GetSSL().certificate &&
387 ssl_host_state_delegate_->DidHostRunInsecureContent( 393 ssl_host_state_delegate_->DidHostRunInsecureContent(
388 host, process_id, SSLHostStateDelegate::CERT_ERRORS_CONTENT)) { 394 host, process_id, SSLHostStateDelegate::CERT_ERRORS_CONTENT)) {
389 entry->GetSSL().content_status |= SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS; 395 entry->GetSSL().content_status |= SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS;
390 } 396 }
391 } 397 }
392 398
393 if (!entry->GetSSL().Equals(original_ssl_status)) 399 if (!entry->GetSSL().Equals(original_ssl_status))
394 NotifyDidChangeVisibleSSLState(); 400 NotifyDidChangeVisibleSSLState();
395 } 401 }
396 402
397 void SSLManager::UpdateLastCommittedEntry(int additional_content_status_flags) { 403 void SSLManager::UpdateLastCommittedEntry(int add_content_status_flags,
404 int remove_content_status_flags) {
398 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry(); 405 NavigationEntryImpl* entry = controller_->GetLastCommittedEntry();
399 if (!entry) 406 if (!entry)
400 return; 407 return;
401 UpdateEntry(entry, additional_content_status_flags); 408 UpdateEntry(entry, add_content_status_flags, remove_content_status_flags);
402 } 409 }
403 410
404 void SSLManager::NotifyDidChangeVisibleSSLState() { 411 void SSLManager::NotifyDidChangeVisibleSSLState() {
405 WebContentsImpl* contents = 412 WebContentsImpl* contents =
406 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); 413 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents());
407 contents->DidChangeVisibleSecurityState(); 414 contents->DidChangeVisibleSecurityState();
408 } 415 }
409 416
410 // static 417 // static
411 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { 418 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) {
412 SSLManagerSet* managers = 419 SSLManagerSet* managers =
413 static_cast<SSLManagerSet*>(context->GetUserData(kSSLManagerKeyName)); 420 static_cast<SSLManagerSet*>(context->GetUserData(kSSLManagerKeyName));
414 421
415 for (std::set<SSLManager*>::iterator i = managers->get().begin(); 422 for (std::set<SSLManager*>::iterator i = managers->get().begin();
416 i != managers->get().end(); ++i) { 423 i != managers->get().end(); ++i) {
417 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry(), 0); 424 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry(), 0, 0);
418 } 425 }
419 } 426 }
420 427
421 } // namespace content 428 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/ssl/ssl_manager.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698