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

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

Issue 2395663002: Collapse SSLPolicy/SSLPolicyBackend into SSLManager (Closed)
Patch Set: fix test flake 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/browser/ssl/ssl_policy_backend.h"
15 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
16 #include "content/public/browser/global_request_id.h" 15 #include "content/public/browser/global_request_id.h"
17 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
18 #include "net/cert/cert_status_flags.h" 17 #include "net/cert/cert_status_flags.h"
19 #include "url/gurl.h" 18 #include "url/gurl.h"
20 19
21 namespace net { 20 namespace net {
22 class SSLInfo; 21 class SSLInfo;
23 } 22 }
24 23
25 namespace content { 24 namespace content {
26 class BrowserContext; 25 class BrowserContext;
27 class NavigationEntryImpl; 26 class NavigationEntryImpl;
28 class NavigationControllerImpl; 27 class NavigationControllerImpl;
29 class SSLPolicy; 28 class SSLHostStateDelegate;
30 struct LoadCommittedDetails; 29 struct LoadCommittedDetails;
31 struct ResourceRedirectDetails;
32 struct ResourceRequestDetails;
33 30
34 // The SSLManager SSLManager controls the SSL UI elements in a WebContents. It 31 // The SSLManager controls the SSL UI elements in a WebContents. It
jam 2016/10/05 16:36:02 nit: extra space after SSLManager
estark 2016/10/05 16:53:04 Done.
35 // listens for various events that influence when these elements should or 32 // listens for various events that influence when these elements should or
36 // should not be displayed and adjusts them accordingly. 33 // should not be displayed and adjusts them accordingly.
37 // 34 //
38 // There is one SSLManager per tab. 35 // There is one SSLManager per tab.
39 // The security state (secure/insecure) is stored in the navigation entry. 36 // The security state (secure/insecure) is stored in the navigation entry.
40 // Along with it are stored any SSL error code and the associated cert. 37 // Along with it are stored any SSL error code and the associated cert.
41
42 class CONTENT_EXPORT SSLManager { 38 class CONTENT_EXPORT SSLManager {
43 public: 39 public:
44 // Entry point for SSLCertificateErrors. This function begins the process 40 // Entry point for SSLCertificateErrors. This function begins the process
45 // of resolving a certificate error during an SSL connection. SSLManager 41 // of resolving a certificate error during an SSL connection. SSLManager
46 // will adjust the security UI and either call |CancelSSLRequest| or 42 // will adjust the security UI and either call |CancelSSLRequest| or
47 // |ContinueSSLRequest| of |delegate|. 43 // |ContinueSSLRequest| of |delegate|.
48 // 44 //
49 // Called on the IO thread. 45 // Called on the IO thread.
50 static void OnSSLCertificateError( 46 static void OnSSLCertificateError(
51 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, 47 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate,
(...skipping 11 matching lines...) Expand all
63 const GURL& url, 59 const GURL& url,
64 int render_process_id, 60 int render_process_id,
65 int render_frame_id, 61 int render_frame_id,
66 const net::SSLInfo& ssl_info, 62 const net::SSLInfo& ssl_info,
67 bool fatal); 63 bool fatal);
68 64
69 // Called when SSL state for a host or tab changes. 65 // Called when SSL state for a host or tab changes.
70 static void NotifySSLInternalStateChanged(BrowserContext* context); 66 static void NotifySSLInternalStateChanged(BrowserContext* context);
71 67
72 // Construct an SSLManager for the specified tab. 68 // Construct an SSLManager for the specified tab.
73 // If |delegate| is NULL, SSLPolicy::GetDefaultPolicy() is used.
74 explicit SSLManager(NavigationControllerImpl* controller); 69 explicit SSLManager(NavigationControllerImpl* controller);
75 virtual ~SSLManager(); 70 virtual ~SSLManager();
76 71
77 SSLPolicy* policy() { return policy_.get(); }
78 SSLPolicyBackend* backend() { return &backend_; }
79
80 // The navigation controller associated with this SSLManager. The 72 // The navigation controller associated with this SSLManager. The
81 // NavigationController is guaranteed to outlive the SSLManager. 73 // NavigationController is guaranteed to outlive the SSLManager.
82 NavigationControllerImpl* controller() { return controller_; } 74 NavigationControllerImpl* controller() { return controller_; }
83 75
84 void DidCommitProvisionalLoad(const LoadCommittedDetails& details); 76 void DidCommitProvisionalLoad(const LoadCommittedDetails& details);
85 void DidStartResourceResponse(const ResourceRequestDetails& details); 77 void DidStartResourceResponse(const GURL& url,
86 void DidReceiveResourceRedirect(const ResourceRedirectDetails& details); 78 bool has_certificate,
79 net::CertStatus ssl_cert_status);
87 80
88 // Entry point for insecure mixed content (loaded over HTTP). 81 // Entry point for insecure mixed content (loaded over HTTP).
89 void DidRunInsecureContent(const GURL& security_origin); 82 void DidRunInsecureContent(const GURL& security_origin);
90 83
91 // Entry point for content loaded with HTTPS certificate errors. 84 // Entry point for content loaded with HTTPS certificate errors.
92 void DidRunContentWithCertErrors(const GURL& security_origin); 85 void DidRunContentWithCertErrors(const GURL& security_origin);
93 86
87 // An error occurred with the certificate in an SSL connection.
88 void OnCertError(std::unique_ptr<SSLErrorHandler> handler);
89
94 private: 90 private:
91 enum OnCertErrorInternalOptionsMask {
92 OVERRIDABLE = 1 << 0,
93 STRICT_ENFORCEMENT = 1 << 1,
94 EXPIRED_PREVIOUS_DECISION = 1 << 2
95 };
96
97 // Helper method for handling certificate errors.
98 //
99 // Options should be a bitmask combination of OnCertErrorInternalOptionsMask.
100 // OVERRIDABLE indicates whether or not the user could (assuming perfect
101 // knowledge) successfully override the error and still get the security
102 // guarantees of TLS. STRICT_ENFORCEMENT indicates whether or not the site the
103 // user is trying to connect to has requested strict enforcement of
104 // certificate validation (e.g. with HTTP Strict-Transport-Security).
105 // EXPIRED_PREVIOUS_DECISION indicates whether a user decision had been
106 // previously made but the decision has expired.
107 void OnCertErrorInternal(std::unique_ptr<SSLErrorHandler> handler,
108 int options_mask);
109
95 // Updates the NavigationEntry with our current state. This will 110 // Updates the NavigationEntry with our current state. This will
96 // notify the WebContents of an SSL state change if a change was 111 // notify the WebContents of an SSL state change if a change was
97 // actually made. 112 // actually made.
98 void UpdateEntry(NavigationEntryImpl* entry); 113 void UpdateEntry(NavigationEntryImpl* entry);
99 114
100 // Notifies the WebContents that the SSL state changed. 115 // Notifies the WebContents that the SSL state changed.
101 void NotifyDidChangeVisibleSSLState(); 116 void NotifyDidChangeVisibleSSLState();
102 117
103 // The backend for the SSLPolicy to actuate its decisions.
104 SSLPolicyBackend backend_;
105
106 // The SSLPolicy instance for this manager.
107 std::unique_ptr<SSLPolicy> policy_;
108
109 // The NavigationController that owns this SSLManager. We are responsible 118 // The NavigationController that owns this SSLManager. We are responsible
110 // for the security UI of this tab. 119 // for the security UI of this tab.
111 NavigationControllerImpl* controller_; 120 NavigationControllerImpl* controller_;
112 121
122 // Delegate that manages SSL state specific to each host.
123 SSLHostStateDelegate* ssl_host_state_delegate_;
124
113 DISALLOW_COPY_AND_ASSIGN(SSLManager); 125 DISALLOW_COPY_AND_ASSIGN(SSLManager);
114 }; 126 };
115 127
116 } // namespace content 128 } // namespace content
117 129
118 #endif // CONTENT_BROWSER_SSL_SSL_MANAGER_H_ 130 #endif // CONTENT_BROWSER_SSL_SSL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698