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

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

Issue 2408393003: Manage insecure content flags in SSLManager, not WebContentsImpl (Closed)
Patch Set: fix test failure Created 4 years, 2 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
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 #ifndef CONTENT_BROWSER_SSL_SSL_MANAGER_H_ 5 #ifndef CONTENT_BROWSER_SSL_SSL_MANAGER_H_
6 #define CONTENT_BROWSER_SSL_SSL_MANAGER_H_ 6 #define CONTENT_BROWSER_SSL_SSL_MANAGER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "content/browser/ssl/ssl_error_handler.h" 13 #include "content/browser/ssl/ssl_error_handler.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "content/public/browser/global_request_id.h" 15 #include "content/public/browser/global_request_id.h"
16 #include "content/public/browser/ssl_status.h"
16 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
17 #include "net/cert/cert_status_flags.h" 18 #include "net/cert/cert_status_flags.h"
18 #include "url/gurl.h" 19 #include "url/gurl.h"
19 20
20 namespace net { 21 namespace net {
21 class SSLInfo; 22 class SSLInfo;
22 } 23 }
23 24
24 namespace content { 25 namespace content {
25 class BrowserContext; 26 class BrowserContext;
(...skipping 29 matching lines...) Expand all
55 // OnSSLCertificateError whenever possible (ie when you have access to the 56 // OnSSLCertificateError whenever possible (ie when you have access to the
56 // WebContents). 57 // WebContents).
57 static void OnSSLCertificateSubresourceError( 58 static void OnSSLCertificateSubresourceError(
58 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, 59 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate,
59 const GURL& url, 60 const GURL& url,
60 int render_process_id, 61 int render_process_id,
61 int render_frame_id, 62 int render_frame_id,
62 const net::SSLInfo& ssl_info, 63 const net::SSLInfo& ssl_info,
63 bool fatal); 64 bool fatal);
64 65
65 // Called when SSL state for a host or tab changes.
66 static void NotifySSLInternalStateChanged(BrowserContext* context);
67
68 // Construct an SSLManager for the specified tab. 66 // Construct an SSLManager for the specified tab.
69 explicit SSLManager(NavigationControllerImpl* controller); 67 explicit SSLManager(NavigationControllerImpl* controller);
70 virtual ~SSLManager(); 68 virtual ~SSLManager();
71 69
72 // The navigation controller associated with this SSLManager. The 70 // The navigation controller associated with this SSLManager. The
73 // NavigationController is guaranteed to outlive the SSLManager. 71 // NavigationController is guaranteed to outlive the SSLManager.
74 NavigationControllerImpl* controller() { return controller_; } 72 NavigationControllerImpl* controller() { return controller_; }
75 73
76 void DidCommitProvisionalLoad(const LoadCommittedDetails& details); 74 void DidCommitProvisionalLoad(const LoadCommittedDetails& details);
77 void DidStartResourceResponse(const GURL& url, 75 void DidStartResourceResponse(const GURL& url,
78 bool has_certificate, 76 bool has_certificate,
79 net::CertStatus ssl_cert_status); 77 net::CertStatus ssl_cert_status);
80 78
81 // Entry point for insecure mixed content (loaded over HTTP). 79 // The following methods are called when a page includes insecure
82 void DidRunInsecureContent(const GURL& security_origin); 80 // content. These methods update the SSLStatus on the NavigationEntry
83 81 // appropriately. If the result could change the visible SSL state,
84 // Entry point for content loaded with HTTPS certificate errors. 82 // they notify the WebContents of the change via
83 // DidChangeVisibleSSLState();
84 void DidDisplayMixedContent();
85 void DidDisplayContentWithCertErrors();
86 void DidShowPasswordInputOnHttp();
87 void DidShowCreditCardInputOnHttp();
88 void DidRunMixedContent(const GURL& security_origin);
85 void DidRunContentWithCertErrors(const GURL& security_origin); 89 void DidRunContentWithCertErrors(const GURL& security_origin);
86 90
87 // An error occurred with the certificate in an SSL connection. 91 // An error occurred with the certificate in an SSL connection.
88 void OnCertError(std::unique_ptr<SSLErrorHandler> handler); 92 void OnCertError(std::unique_ptr<SSLErrorHandler> handler);
89 93
90 private: 94 private:
91 enum OnCertErrorInternalOptionsMask { 95 enum OnCertErrorInternalOptionsMask {
92 OVERRIDABLE = 1 << 0, 96 OVERRIDABLE = 1 << 0,
93 STRICT_ENFORCEMENT = 1 << 1, 97 STRICT_ENFORCEMENT = 1 << 1,
94 EXPIRED_PREVIOUS_DECISION = 1 << 2 98 EXPIRED_PREVIOUS_DECISION = 1 << 2
95 }; 99 };
96 100
97 // Helper method for handling certificate errors. 101 // Helper method for handling certificate errors.
98 // 102 //
99 // Options should be a bitmask combination of OnCertErrorInternalOptionsMask. 103 // Options should be a bitmask combination of OnCertErrorInternalOptionsMask.
100 // OVERRIDABLE indicates whether or not the user could (assuming perfect 104 // OVERRIDABLE indicates whether or not the user could (assuming perfect
101 // knowledge) successfully override the error and still get the security 105 // knowledge) successfully override the error and still get the security
102 // guarantees of TLS. STRICT_ENFORCEMENT indicates whether or not the site the 106 // guarantees of TLS. STRICT_ENFORCEMENT indicates whether or not the site the
103 // user is trying to connect to has requested strict enforcement of 107 // user is trying to connect to has requested strict enforcement of
104 // certificate validation (e.g. with HTTP Strict-Transport-Security). 108 // certificate validation (e.g. with HTTP Strict-Transport-Security).
105 // EXPIRED_PREVIOUS_DECISION indicates whether a user decision had been 109 // EXPIRED_PREVIOUS_DECISION indicates whether a user decision had been
106 // previously made but the decision has expired. 110 // previously made but the decision has expired.
107 void OnCertErrorInternal(std::unique_ptr<SSLErrorHandler> handler, 111 void OnCertErrorInternal(std::unique_ptr<SSLErrorHandler> handler,
108 int options_mask); 112 int options_mask);
109 113
110 // Updates the NavigationEntry with our current state. This will 114 // Updates the NavigationEntry's |content_status| flags according to
111 // notify the WebContents of an SSL state change if a change was 115 // state in |ssl_host_state_delegate| and
112 // actually made. 116 // |additional_content_status_flags|, a bitmask of
113 void UpdateEntry(NavigationEntryImpl* entry); 117 // SSLStatus::ContentStatusFlags. (Pass 0 to set no additional content
118 // status flags.) This will notify the WebContents of an SSL state
119 // change if a change was actually made.
120 void UpdateEntry(NavigationEntryImpl* entry,
121 int additional_content_status_flags);
122
123 // Helper function for UpdateEntry().
124 void UpdateLastCommittedEntry(int additional_content_status_flags);
114 125
115 // Notifies the WebContents that the SSL state changed. 126 // Notifies the WebContents that the SSL state changed.
116 void NotifyDidChangeVisibleSSLState(); 127 void NotifyDidChangeVisibleSSLState();
117 128
129 // Updates the last committed entries of all |context|'s
130 // SSLManagers. Notifies each WebContents of visible SSL state changes
131 // if necessary.
132 static void NotifySSLInternalStateChanged(BrowserContext* context);
133
118 // The NavigationController that owns this SSLManager. We are responsible 134 // The NavigationController that owns this SSLManager. We are responsible
119 // for the security UI of this tab. 135 // for the security UI of this tab.
120 NavigationControllerImpl* controller_; 136 NavigationControllerImpl* controller_;
121 137
122 // Delegate that manages SSL state specific to each host. 138 // Delegate that manages SSL state specific to each host.
123 SSLHostStateDelegate* ssl_host_state_delegate_; 139 SSLHostStateDelegate* ssl_host_state_delegate_;
124 140
125 DISALLOW_COPY_AND_ASSIGN(SSLManager); 141 DISALLOW_COPY_AND_ASSIGN(SSLManager);
126 }; 142 };
127 143
128 } // namespace content 144 } // namespace content
129 145
130 #endif // CONTENT_BROWSER_SSL_SSL_MANAGER_H_ 146 #endif // CONTENT_BROWSER_SSL_SSL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698